Problem of drawing poker

88 Views Asked by At

Randomly shuffle a deck of poker cards (52) and continually draw the card without replacement. On average how many cards you need to draw in order to get a card which has a same value as the cards you've drawn? That is to say, if the card you've drawn is 1->2->3->4, then you would stop at the next step if you draw one of the 1,2,3 or 4.

This is a problem I came upwith when I was playing desk card games...

I thought "on average" it could be seen as $E(\sum_{i=1}^{52}I_i)$ of which $I_i$ means the i-th card has already been seen (0) or not (1). Then $E(\sum_{i=1}^{52}I_i) = \sum_{i=1}^{52}P_i$ of which $P_i$ is the prob that the i-th card is a new card (not seen before). But apparently the $P_i$ depends on $i$....so what can I do next?

=============== The original post is "stop when you draw a card with a same face value as the first card". I think that's just splitting the remaining deck (52-1=51 cards) by 3 cards, i.e. we have (51-3)/4 cards per subdeck. Then the answer could be (51-3)/4 + 1 + 1. But not so sure...

The background comes from a Chinese desk card game. The game aims to kill other characters (lower down the life points). One special hero has a special skill, i.e. when he is almost dying (life point goes from 1 to 0 due to the attack) he could draw a card from the deck and collect it, if the card has a same face value compared to the cards he collected by this method (i.e. draw a card when life point goes from 1 to 0) then he dies. I am just wondering on average how many cards he could collect (or how many times you need to "attack" him).

1

There are 1 best solutions below

3
On BEST ANSWER

This answer is for the game where you stop once some value is repeated for the first time. In the words of the OP "if the card you've drawn is 1->2->3->4, then you would stop at the next step if you draw one of the 1,2,3 or 4.".

Model the deck by dependent random variables $X_1,\ldots,X_{52}$ that each take values in the set $\{1,\ldots,13\}$.

Let $N$ denote a random variable modeling the rank of the first repeated value. Note that $P(N>n) = 0$ when $n\geq 14$ by the pigeonhole principle.

Fix $n\in \{1,\ldots, 13\}$. Note that $$\begin{aligned} P(N>n) &= P(X_1,\ldots,X_n \text{ are all distinct}) \\&= \sum_{v_1\neq\ldots\neq v_n \in \{1,\ldots,13\} } P(X_1=v_1,\ldots,X_n=v_n) \\&\stackrel{(1)}{=} P(X_1=1,\ldots,X_n=n) \times |\{(v_1,\ldots,v_n) \in \{1,\ldots,13\}^n: v_1,\ldots,v_n \text{ are all distinct}\}| \\&= P(X_n=n|X_{n-1}=n-1,\ldots, X_1=1)\times \ldots\times P(X_2=2|X_1=1)P(X_1=1) \frac{13!}{(13-n)!} \\&= \frac{13!}{52!} 4^n \frac{(52-n)!}{(13-n)!}. \end{aligned}$$

Equality (1) holds by symmetry.

Finally, $E[N] = \sum_{n=0}^{13} P(N>n) = 1+ \sum_{n=1}^{13} \frac{13!}{52!} 4^n \frac{(52-n)!}{(13-n)!} = \frac{226087256246}{39688347475} \approx 5.696$.

This value is confirmed by the following simulation.

import numpy as np 

def find(arr):
    seen = set()
    for (i,el) in enumerate(arr):
        if el in seen:
            return i+1
        else:
            seen.add(el)

res = []
deck = np.repeat(np.arange(1,14),4)
for _ in range(10000):
    np.random.shuffle(deck)
    res.append(find(deck))
print(np.mean(res))

The same approach applies for the other game where you stop once the first value is repeated.

Note that $P(N>0)=P(N>1)=1$, $P(N>n)=0$ if $n\geq 50$ and for $n\in \{2,\ldots, 49 \}$, by similar techniques as above $$\begin{aligned} P(N>n)&=13 P(X_2,\ldots,X_n \text{ all distinct from }1 | X_1=1) P(X_1=1) \\&= 4\times 13 \times \frac{48!}{52!} \frac{(52-n)!}{(48-n+1)!}. \end{aligned}$$

Thus $E[N] = 2 + \sum_{n=2}^{49} 4\times 13 \times \frac{48!}{52!} \frac{(53-n)!}{(50-n)!} = 14.$

This value is confirmed by the following simulation.

import numpy as np

def find2(arr):
    val = arr[0]
    for (i,el) in enumerate(arr[1:]):
        if el == val:
            return i+2

res = []
deck = np.repeat(np.arange(1,14),4)
for _ in range(10000):
    np.random.shuffle(deck)
    res.append(find2(deck))
print(np.mean(res))