Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: [OT] Stats problem

by salva (Abbot)
on Feb 26, 2015 at 11:40 UTC ( #1117935=note: print w/replies, xml ) Need Help??

in reply to [OT] Stats problem

if I understand your question correctly (and I am not completely sure I do) what you suggest is equivalent to the following problems:

What are the odds of picking the ace of spades from a shuffled deck of cards?

Now, pick a card, insert it back in the deck and shuffle. What are the odds of picking the same card again?

Finally, pick cards from the deck until you get a face card, insert all them back and shuffle. If you pick a card now, what are the odds of it being that face card again?

Replies are listed 'Best First'.
Re^2: [OT] Stats problem
by BrowserUk (Pope) on Feb 26, 2015 at 11:57 UTC
    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
      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 ;-)


        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%

      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!

      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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1117935]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2020-06-06 15:22 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (41 votes). Check out past polls.