+ Reply to Thread
Results 1 to 7 of 7

Thread: Probabilty of picking a card in a deck

  1. #1
    Points: 92, Level: 1
    Level completed: 84%, Points required for next Level: 8

    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Probabilty of picking a card in a deck




    I've never been very good in probability but I want to know how to calculate this. This is not a homework assignment or anything I am just curious.
    I sometimes (when I'm bored) go through a deck of card and calling out a card name while flipping the top card face up, if the card I flipped face up is NOT the card I called, I continue otherwise I shuffle and start over. I start saying "Ace" then "2" then "3" then "4, 5, 6, 7, 8, 9, 10, jack, queen, king" then start from Ace again until the deck is finished or I pick the card I called out.
    It's actually pretty hard to finish the deck, but I want to know the exact probability of finishing the deck.
    I know the probability of calling out the first card is 4/52 but what is the probability of finishing the deck without calling out any turned card?

  2. #2
    TS Contributor
    Points: 22,410, Level: 93
    Level completed: 6%, Points required for next Level: 940

    Posts
    3,020
    Thanks
    12
    Thanked 565 Times in 537 Posts

    Re: Probabilty of picking a card in a deck

    Just google about it, and it seems like a derangement for multiset. See

    http://en.wikipedia.org/wiki/Derangement

    for the generalization part. As someone in the other forum suggested (and listed in the above wiki page as well) it involves the integration of a certain polynomial. I have just read this method, maybe other experts here could help.

  3. #3
    Devorador de queso
    Points: 95,754, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent Poster
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,932
    Thanks
    307
    Thanked 2,629 Times in 2,245 Posts

    Re: Probabilty of picking a card in a deck

    Seems like it would be too much work to do by hand. So I just simulated it 10000000 times and in the simulations it appears that about 98.3795% times I got a match at some point in the deck. So the chance of not seeing a match is somewhere around 1.62%

    R code for anybody interested - it's a pretty simple simulation
    Code: 
    # will call out 'ace' (coded as 1)
    # then 2 (coded as 2)
    # ...
    # then jack (coded as 11)
    # queen (12)
    # king (13)
    # then repeats 3 additional times.
    call <- rep(1:13,4)
    sim <- function(){
        # We don't care about suit so we just need
        # To permute the calls that would be made
        # which is identical to shuffling the deck
        # and just identifying the number of the card
        deck <- sample(call)
        # All we care about is if any of the calls made
        # Match the corresponding card in the deck
        return(any(deck == call))
    }
    
    # Do the simulation 10000000 times
    trials <- replicate(10000000, sim())
    # Probability there is a match at some point
    mean(trials)
    # Probability there isn't a match at some point
    1 - mean(trials)
    Last edited by Dason; 11-02-2013 at 03:04 PM.
    I don't have emotions and sometimes that makes me very sad.

  4. #4
    Human
    Points: 12,676, Level: 73
    Level completed: 57%, Points required for next Level: 174
    Awards:
    Master Tagger
    GretaGarbo's Avatar
    Posts
    1,362
    Thanks
    455
    Thanked 462 Times in 402 Posts

    Re: Probabilty of picking a card in a deck

    1.62%

    And how “uncertain” is that?

    It is difficult to count all the zeros but I believe that it is 10 million repeats.

    I wonder if the computing Dason maybe has made an “over kill” here?
    (That was intended as a small joke.)

    Since each run is a trial with “success” and “failure” (match or not) and they are independent and the number of runs are counted, then it (the sum of matches) will be binomial distributed. Then we can compute a confidence interval with the good old formula: p +/- 1.96sqrt(p(1-p)/n)

    Like in this fantastic “program”:


    Code: 
    p <- 0.0162
    n <- 10000000  # 10 millions
    
    low <- 100*(p - 1.96*sqrt(p*(1-p)/n))
    high <- 100*(p + 1.96*sqrt(p*(1-p)/n))
    
    print(c(low,high))
    #[1] 1.612175 1.627825
    There seems to be some “over kill”.

  5. #5
    Devorador de queso
    Points: 95,754, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent Poster
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,932
    Thanks
    307
    Thanked 2,629 Times in 2,245 Posts

    Re: Probabilty of picking a card in a deck

    Overkill? Does it matter? It's not like it takes much time to run...
    I don't have emotions and sometimes that makes me very sad.

  6. #6
    Human
    Points: 12,676, Level: 73
    Level completed: 57%, Points required for next Level: 174
    Awards:
    Master Tagger
    GretaGarbo's Avatar
    Posts
    1,362
    Thanks
    455
    Thanked 462 Times in 402 Posts

    Re: Probabilty of picking a card in a deck

    Quote Originally Posted by Dason View Post
    Overkill? Does it matter? It's not like it takes much time to run...
    Long enough to be bored!

    The boredom exceeds the desire to know yet another decimal in that percentage.

    When the Destroyer-of-hope uses 10 millions replications anyone of us simple users might believe that that is an example that must be followed. I simply wanted to remind that everyone can evaluate the needed number.

    Besides, I know a professor who used to say that when a statistician does simulations they tend to forget that they are statisticians.

  7. #7
    TS Contributor
    Points: 22,410, Level: 93
    Level completed: 6%, Points required for next Level: 940

    Posts
    3,020
    Thanks
    12
    Thanked 565 Times in 537 Posts

    Re: Probabilty of picking a card in a deck


    With Dason's simulation backup, now we can try out the method in listed in wiki.

    http://en.wikipedia.org/wiki/Laguerre_polynomials

    The number of derangements is given by

    \left|\int_0^{+\infty} L_4(x)^{13}e^{-x}dx\right|

    = \left|\int_0^{+\infty} \left[\frac {1} {24}(x^4-16x^3+72x^2-96x+24)\right]^{13}e^{-x}dx\right|

    = 1493804444499093354916284290188948031229880469556 (according to wolfram alpha)

    The number of distinct permutation is

    \frac {52!} {(4!)^{13}}

    So the probability is

    1493804444499093354916284290188948031229880469556 \times \frac {(4!)^{13}} {52!}

    \approx 0.016232727467194636748129556513278694417463496025641203345388

    which agree with Dason's simulation result.

  8. The Following User Says Thank You to BGM For This Useful Post:

    GretaGarbo (11-03-2013)

+ Reply to Thread

           




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats