[Math] Probability of no king, queen or jack before the first ace occurs

card-gamescombinatoricsprobability

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

Best Answer

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$