What's the expected number of cards drawn to get a three of a kind?

50 Views Asked by At

The deck contains 52 cards as usual, and we draw cards without replacement. How would the result change if we draw with replacement and shuffle after every draw?

1

There are 1 best solutions below

0
On

I computed this as a finite-state absorbing Markov chain, as discussed in the comments, and the answer turned out to be $13.55$. I found thing surprisingly low (I had guessed it would be around $17$ or $18$), but I confirmed it with a simulation of $100,000$ trials, and it was bang on.

Here's the code if anyone is interested:

import numpy as np
'''
Draw cards froma starndard 52-card deck without replacement.
What is the expecetd number of darws until 3 of the same rank have been drawn?
Absorbing markov chain
States are (p,s) where p is the number of different pairs that have
been drawn, and s the number of different singletons.
Assume we start in state (0,1) (so one card drawn already.)  We have 0<s+p<=13.

'''
states=sorted([(p,s) for p in range(14) for s in range(14) if 0<s+p<=13])
n=len(states)
state2index = { }
for idx, state in enumerate(states):
    state2index[state] = idx
Q = np.zeros((n,n))
for (p,s) in states:
    cards = 52-s-2*p   # remaining cards in deck
    start = state2index[(p,s)]
    if p+s < 13:
        # draw one of 4 cards in each unseen rank
        single = state2index[(p,s+1)]
        Q[start,single] = 4*(13-p-s)/cards   
    if s > 0:
        #draw one of 3 cards in rank of each singleton
        pair = state2index[(p+1,s-1)]
        Q[start,pair] = 3*s/cards 
I = np.eye(n)
N = np.linalg.inv(I-Q)
steps=  ([email protected](n))[0]
print(1+steps)

and here's a histogram of the simulation.

enter image description here

I don't see how anyone could possibly do this as an interview question, but I think you could win a lot of bar bets with this.