# Thread: Probabilty of picking a card in a deck

1. ## 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. ## 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. ## 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)

4. ## 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. ## Re: Probabilty of picking a card in a deck

Overkill? Does it matter? It's not like it takes much time to run...

6. ## Re: Probabilty of picking a card in a deck

Originally Posted by Dason
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. ## 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

(according to wolfram alpha)

The number of distinct permutation is

So the probability is

which agree with Dason's simulation result.

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

GretaGarbo (11-03-2013)

 Tweet

#### Posting Permissions

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