1
$\begingroup$

The player chooses two ranked cards. 52 cards are dealt alternately to the player and dealer, ending up with 26 cards each. What is the probability the player matches the two cards (any suit) before the dealer?
I've tried breaking the 8 cards into 8-blocks of winning patterns and then using combinations to work out the total number of winning patterns, as inserting rounds of non-hits in these blocks also has the same result.
It reminds me of the first problem in the famous 20 Problems in Probability book about boarding a plane and matching a seat.
The game with one card (for example, first to land a 5 of any suit), can be calculated easily with recursion and has probability of 0.519807923 for the player to win.

$\endgroup$
6
  • $\begingroup$ Welcome to MSE: What have you tried? $\endgroup$
    – J.D
    Commented Jun 5 at 6:26
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Commented Jun 5 at 6:28
  • $\begingroup$ This problem is not nearly as difficult as the plane boarding one. Try for example to find the probability of a chosen card( with a certain rank and suit) being dealt to the player. If you can understand this is just $1/2$ because of odd and even positions, then you can proceed onto this with ease $\endgroup$
    – EnEm
    Commented Jun 5 at 6:55
  • $\begingroup$ A single chosen rank and suit, is easier then the stated problem. As in the problem, the dealer can match the 2 ranked cards before the player resulting in a loss, even if the player has 2 matches themselves. $\endgroup$ Commented Jun 5 at 7:06
  • $\begingroup$ The win condition is not clearly stated. Is it drawing one of each chosen rank? If so, there is the possibility that there is no winner. $\endgroup$ Commented Jun 5 at 23:33

1 Answer 1

0
$\begingroup$

The result is

$$ \mathbb{P}(\text{player wins}) = \frac{143067}{279650} = 0.511593062757018 $$

We can use recursion with two ranks too. We can consider the deck to consist of four $0$'s, four $1$'s (take 0 and 1 as chosen ranks) and the rest 44 are $2$'s (representing the other cards).

Take as a state the vector

$$ (v_0, v_1, a) $$

where $v_0=(v_{00}, v_{01})$ is the indicator vector of the values the player going first has gotten. The vector $v_1$ similarly for the player going second. And $a=(a_0,a_1,a_2)$ is the "amounts left" vector: $a_j = $ amount of cards of rank $j$ left in the deck.

Denote by $p_0(v_0,v_1,a)$ the winning probability of the player going first from the state $(v_0,v_1,a)$. And $p_1$ for the player going second. The recursion is

$$ p_0(v_0,v_1,a) = \frac{a_0}{\sum a}p_1(v_1, (1,v_{01}), (a_0-1, a_1, a_2)) + \frac{a_1}{\sum a}p_1(v_1, (v_{00}, 1), (a_0, a_1-1, a_2)) + \frac{a_2}{\sum a}p_1(v_1, v_0, (a_0, a_1, a_2-1)) $$

and similarly for $p_1$. The formula comes from conditioning on the next card. Notice the turns alternate so we use $p_1$ and swap the $v$ vectors in the formula for $p_0$ because it is then the second the player. There are the obvious base cases of a player winning: $v_k=(1,1)$; and the deck being empty: $\sum a = 0$.

This way, as a byproduct, we also get the probability of the dealer winning, which is $\mathbb{P}(\text{dealer wins}) = \frac{8455229}{17617950} = 0.479921273473929$.

Python code (I used Sage, so the output is rational numbers):

def calcPRec(k=13, n=4, r=2):
    winVec = (1,)*r
    #state = (1st gotten, second gotten, (0s, 1s,.., (r-1)s, empties) )
    memo = {}
    def rec(v0, v1, a):
        #if v0==winVec: return 1,0 #never happens
        if v1==winVec: return 0,1
        totLeft = sum(a)
        if totLeft==0: return 0,0
        memoKey = (v0,v1,a)
        if memoKey in memo: return memo[memoKey]
        p0,p1 = 0,0
        for c in range(r+1):
            if a[c]==0: continue
            pOfC = a[c]/totLeft
            v02 = tuple(v0[j] if c!=j else 1 for j in range(r))
            a2 = tuple(a[j] - (1 if c==j else 0) for j in range(r+1))
            p12, p02 = rec(v1, v02, a2)
            p0 += pOfC*p02
            p1 += pOfC*p12
        memo[memoKey] = (p0,p1)
        return p0, p1
    pWin,pDealerWin = rec((0,)*r, (0,)*r, (n,)*r+(n*(k-r),))
    #print ("P(dealer win) = %s = %.15f" %(pDealerWin,pDealerWin) )
    return pWin
    

p = calcPRec(k=13, n=4, r=2)
print (  "%s = %.15f" %(p,p))    

Try the code at online-python

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .