# Probability of no king, queen or jack before the first ace occurs?

A deck of cards is shuffled well. The cards are dealt one by one, until the first time an Ace appears. Find the probability that no kings, queens, or jacks appear before the first ace. (Introduction to Probability, p. 36)

My solution:

• Assume $k^{th}$ card is the first ace
• The possible number of hand before the first ace is then $\binom{48}{k-1}$, and the possible number of hands without a king, queen or jack before the first ace is $\binom{36}{k-1}$, so the probability is $\frac{\binom{36}{k-1}}{\binom{48}{k-1}}$.
• The probability that the first ace occurs at the $k^{th}$ position is $\frac{1}{52!} \binom{48}{k-1}(k-1)! \binom{4}{1}(52-k)!$, because there are $52!$ possible ordered decks, $\binom{48}{k-1}(k-1)!$ is the number of possibilities withouth an ace in the first $k$ cards, $\binom{4}{1}$ possibilities to draw an ace at the $k^{th}$ position and $(52-k)!$ possibilities to arrange the remaining cards in order.
• $\sum_{k=1}^{k=37} \frac{\binom{36}{k-1}}{\binom{48}{k-1}} \frac{1}{52!} \binom{48}{k-1}(k-1)! \binom{4}{1}(52-k)! = 0.25$

The computation of the above in R:

    pr <- numeric(37)
for(k in 1:37){
pr_ace_at_k <- 1/factorial(52)*choose(48,k-1)*factorial(k-1) * choose(4,1)*factorial(52-k)
pr_no_before_k <- choose(36,k-1)/choose(48,k-1)
pr[k] <- pr_no_before_k * pr_ace_at_k
}
sum(pr)
> 0.25


However, a simulation yields:

    deck <- c(rep(1:4, 4), rep(5, 52-4*4))
out <- replicate(1e6,{
deck <- sample(deck) # shuffle deck
k <- which(deck == 4)[1] # get index of first ace
all(deck[1:(k-1)] == 5) # check if only rest occured before kth card
})
mean(out)
> 0.173099


Is there anything wrong in my calculation? A result of 0.25 looks somehow persuasive.

EDIT

Finally, I found the nasty bug in the code. Problem was the special case when the ace occured at the first position. Corrected code would be

    deck <- c(rep(1:4, 4), rep(5, 52-4*4))
out <- replicate(1e6,{
deck <- sample(deck) # shuffle deck
k <- which(deck == 4)[1] # get index of first ace
if(k == 1) TRUE
else all(deck[1:(k-1)] == 5)
})
mean(out)
> 0.249877

• It's the probability that among $16$ particular cards, the first to show up is an ace. We have equally likely outcomes here... – David Mitra Dec 7 '14 at 15:05
• Call Ace, King, Queen, and Jack the picture cards. You are asking for the probability that the first picture card is an Ace. But all picture cards are equally likely. Therefore, by symmetry, the probability is...? – TonyK Dec 7 '14 at 15:09
• The issue is why the simulation is so grossly wrong. The usual answer is programming error. – André Nicolas Dec 7 '14 at 15:19
• The simulation result is clearly an anomaly. I don't see any error in the R code, but maybe someone on stackoverflow can. – David K Dec 7 '14 at 15:25
• The simulation probability is likely either 4/23 or 9/52 – Empy2 Dec 7 '14 at 16:22

The easiest way to think about it is to ignore all the other cards in the deck. Now you stack up the $16$ cards of interest. What is the chance the top one is an ace? There are $4$ aces among the $16$, so $\frac 4{16}=\frac 14$

• That makes perfect sense, good explanation and intuition! – NoBackingDown Dec 7 '14 at 15:23

Although it is not the simplest approach, we can use recursive conditioning, which is a useful approach in a lot of somewhat more complicated problems.

To see the intuition, let's check the cases in words. Suppose the first card is a queen/jack/king; then you stop and it doesn't count. Suppose it's an ace; then you stop and it counts. Suppose it's neither; then you run the experiment again with 1 fewer card.

Mathematically we'll say that the desired event when starting with a $k$ card deck is $A_k$. Then we have

$$P(A_k)=P(A_k|\text{ first card is an ace })P(\text{ first card is an ace }) \\ +P(A_k|\text{ first card is queen/jack/king })P(\text{ first card is queen/jack/king })\\ +P(A_k|\text{ first card is neither })P(\text{ first card is neither }) \\ = 1 \cdot \frac{4}{k} + 0 + \frac{k-16}{k} P(A_{k-1})$$

Now take $k=52$ and solve the recurrence relation. Here the base case can be read off from the recurrence itself: we get $P(A_{16})=4/16+0+0=1/4$ for free. Here solving the recurrence proves particularly simple, because if $P(A_{k-1})=1/4$ then $P(A_k)=1/4$, since

$$\frac{4}{k} + \frac{k-16}{k} \frac{1}{4} = \frac{4}{k} + \frac{1}{4} - \frac{4}{k} = \frac{1}{4}.$$

This is an algebraic manifestation of the intuitive observation that we can "ignore all the other cards".

Total probability x Probability of only 1st drawing = Probability of event occuring

Total probability x (1 - Probability of another drawing) = Probability of event occuring on 1st drawing

Total probability = Probability of event occuring on 1st drawing / (1 - Probability of another drawing) = $\frac{\frac1{13}}{1-\frac9{13}}=\frac14$

• Could you elaborate on your answer? I don't understand how you arrive at your equation. – NoBackingDown Dec 7 '14 at 15:25
• More rigorous than RossMillikan's answer? How so? – Did Dec 7 '14 at 15:35
• I don't think this quite works, because the replacement means that the process is not simply being "restarted" upon drawing another card. My answer does essentially what you're attempting to do, I think. That is, you have that $a=1/13 + 9/13 b$ where $b$ is the probability for the corresponding event with a deck containing 12 queen/jack/king, 4 aces, and 51-16=35 other cards. – Ian Dec 7 '14 at 15:39
• 1. Hope my answer is clear enough now. 2. RossMillikian's answer is sufficient, I just used a formula instead of intuition. – ghosts_in_the_code Dec 7 '14 at 16:25
• I don't think this works still: you have that the total probability is the probability of the event occurring given that the process stops on the first draw, times the probability that the process stops on the first draw, plus the probability of the event occurring given that the process stops on the second draw, times the probability that it stops on the second draw, etc. There is an independence assumption implicit in your formula which is correct but not justified. – Ian Dec 7 '14 at 17:30

One of these $4$ sorts of cards (aces, kings, queens, jacks) will appear as the first. Each sort (also the aces) has the same probability of doing so, hence with probability $\frac{1}{4}$.