### Re^2: [OT] Stats problem

by BrowserUk (Pope)
 on Feb 26, 2015 at 11:57 UTC ( #1117938=note: print w/replies, xml ) Need Help??

in reply to Re: [OT] Stats problem

Now, pick a card...

I wish I had thought of that analogy.

Recouched in terms of that analogy the problem becomes:

Assume the 'standard ordering' of a pack of cards (minus jokers) is A..K of Spades, A..K of Diamonds, A..K of Clubs, A..K of Hearts.

|Shuffle the pack fairly. Now go through the pack and check how many (if any) of the cards end up in their 'standard position'. Repeat many times.

How often after does a card end up in its standard position? What are the odds of a card ending up in its standard position?

Its not quite right because each card can only end up in one position; whereas with memory corruption; a value may (and usually will) be repeated.

Also, all the possible values (cards) will appear; but in memory, it takes 4-bytes to hold the offset of a single byte. But then again, we are only interested in offsets %8...and only half of the values in memory...I'm lost again.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^3: [OT] Stats problem
by syphilis (Bishop) on Feb 26, 2015 at 14:04 UTC
What are the odds of a card ending up in its standard position?

That's easy enough - it's 1 in 52.
A card can be in any one of 52 positions, only one of which is its "standard position" - and there's no bias that favours one position over another.

UPDATE What follows doesn't scale correctly ... it aint right IOW - probably the linkage that salva was getting at.

The chance that none of the cards are in their standard position is simply (51/52) ** 52, which is around 0.3643 or approximately 1 in 3.
Therefore the chance that 1 or more cards are in their standard position is 1 - ((51/52) ** 52) which is around 0.6357 or approximately 2 in 3.
(You could turn this into a rather boring game of patience/solitaire.)

As for what you're actually trying to calculate, I'm still trying ot get my head around it.
(Please stick to cards in future ;-)

Cheers,
Rob

Just for fun, a simulation to confirm:

```use List::Util qw/shuffle sum/;
my \$RUNS = 1_000_000;
my %counts;
for (1..\$RUNS) {
my @deck = shuffle 0..51;
my \$in_correct_loc = grep {\$_==\$deck[\$_]} 0..51;
\$counts{\$in_correct_loc}++;
}
print "Number of cards in the correct position: % of runs\n";
printf "% 4d: %.4f%%\n", \$_, 100*\$counts{\$_}/\$RUNS
for sort {\$a<=>\$b} keys %counts;
my \$one_or_more = sum map {\$_//0} @counts{1..52};
printf "1-52: %.4f%%\n", 100*\$one_or_more/\$RUNS;

__END__

Number of cards in the correct position: % of runs
0: 36.8130%
1: 36.8086%
2: 18.3846%
3: 6.1085%
4: 1.5349%
5: 0.2926%
6: 0.0487%
7: 0.0080%
8: 0.0010%
9: 0.0001%
1-52: 63.1870%
Re^3: [OT] Stats problem
by Anonymous Monk on Feb 26, 2015 at 13:11 UTC

Perhaps a better analogy is this: Imagine six six-sided dice, and six boxes labeled 1 to 6 on the table in front of you*; i.e. one die per box into which it will be rolled. Assuming the die rolls are independent of one another, the probability of each die showing the label of its box is 1/6 - no matter what that label is! The probability of one die showing its box's label and also a second die independently showing its box's label is (1/6)*(1/6); N dice, (1/6)^N.

However, this all changes if the die rolls are not truly random or not truly independent of one another!

* That's just for simplicity; it's too easy to get hung up on those numbers - the number of dice, boxes, and sides, or even whether they are labeled with numbers or hieroglyphs does not matter!

Re^3: [OT] Stats problem
by Anonymous Monk on Feb 26, 2015 at 12:10 UTC

If I'm remembering my probabilities correctly, the probability of event A happening and event B happening independently is P(A)*P(B), so the probability an event A occurring independently N times is P(A)^N.

This is going way off topic, but anyway.

The events are not independent. If the first 51 cards are in their places, the probability of the card 52 being in its place is 1.

If the first 51 cards are in their places, the probability of the card 52 being in its place is 1

Yes, that's one scenario that will see the 52 card in its correct place - but, having shuffled a pack, the chance that the 52 card will be in its place is 1 in 52.
To determine the probability of a specific card being in a specific position one does not need to concern oneself with what might be in the other positions.

Consider a deck of 3 cards - say 2 of hearts, 3 of hearts and 4 of hearts. Let's designate that the correct position for the 2 of hearts is the top of the deck, the correct position for the 3 of hearts is the middle of the deck and the correct position for the 4 of hearts is the bottom of the deck.
Clearly the chance of the 2 of hearts being in its correct place after shuffling is 1 in 3(same as for the other 2 cards). The fact that that the 2 of hearts *has* to be in its correct place if both the 3 & 4 of hearts are in their correct places doesn't warrant any special consideration ... that I can see, anyway.

Cheers,
Rob
The events are not independent.

In the case of cards, yes! I think this is correct: http://www.wolframalpha.com/input/?i=product+of+1%2F%2853-n%29+for+n%3D1+to+52

But BrowserUk said:

Its not quite right because each card can only end up in one position; whereas with memory corruption; a value may (and usually will) be repeated.

Create A New User
Node Status?
node history
Node Type: note [id://1117938]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2020-06-05 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Do you really want to know if there is extraterrestrial life?

Results (35 votes). Check out past polls.

Notices?