Probability of specific cumulative sum when drawing cards

156 Views Asked by At

I have a question regarding the probability of reaching a specific cumulative sum when drawing cards. Let's say we have a regular deck of 52 playing cards and we want to know what the chance is of drawing a total value of 6 in as many draws as are needed.

What I did so far was come up with all possible combinations of terms for 6: [1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 2] [1, 1, 2, 2] [2, 2, 2] [2, 4] [6] [1, 2, 3] [3, 3] [1, 5] [1, 1, 4] [1, 1, 1, 3] and calculate their individual probability of being drawn.

Obviously, in the 1-deck case, the first combination is impossible.

I interpreted reaching the sum via different combinations as the logic equivalent "through combo 1 OR combo 2 OR ... OR combo 11", thus calculating the overall chance as the sum of the individual ones. This does not appear to be correct as I reach probabilities that seem way too high (11.72% for the sum of 6).

What am I not taking into account? I guess it has something to do with the variable amount of draws. In former exercises or courses, this amount was usually, if not always, fixed.

This post seems to be similar, with that exception that the probabilities of a dice roll stay the same over time. Contrary to taking previously drawn cards into account when calculating probablities in this situation.

Many thanks for any tips!

Code for calculating probability of a combination of terms, given a deck:

def prob_of_combo(list, deck):
    deck_length = len(deck.cards)
    prob = 1
    for elem in list:
        if histo_data[elem] == 0:
            return 0
        else:
            prob *= (histo_data[elem]/deck_length)
            histo_data[elem] -= 1
            if elem == 1:
                histo_data[11] -= 1
            elif elem == 11:
                histo_data[1] -= 1
            deck_length -= 1
    return prob*math.factorial(len(list))

With histo_data a dictionary keeping track of the amounts per value that are in the deck. Also note that an ace can have either the value 1 or 11.

And for the total probability, I have:

prob = 0
for j in range(10,16):
    for combo in combinations[j]:
            prob += probs.prob_of_combo(combo,deck)

With combinations[j] a dictionary containing all possible term combinations for j.

1

There are 1 best solutions below

1
On BEST ANSWER

There are probably lots of ways to go about this, but from the approaches I've tried, I liked this one best for this particular problem. Doesn't seem easy to find a generalization.

Let $T_k$ be the total value of the first $k$ cards. The latest we could hope to get a total value of $6$ is with $k=5$, with cards drawn being four $1$s and a $2$. We are thus interested in

$$\sum_{k=1}^5 \Bbb P(T_k = 6).$$

Now, let $[x_1,x_2,\dots,x_n]$ denote the event that the values of the first $n$ cards drawn are $x_1\leqslant x_2\leqslant \dots \leqslant x_n$ (Not necessarily drawn in this order). We have

$$ \begin{align} &\Bbb P(T_1 = 6) = \Bbb P([6]) = \frac4{52} = \frac1{13} \\&\Bbb P(T_2 = 6) = \Bbb P([1,5])+ \Bbb P([2,4]) + \Bbb P([3,3]) = \frac{4\cdot 4 + 4\cdot 4 + \binom42}{\binom{52}2} \\&\Bbb P(T_3 = 6) = \Bbb P([1,1,4])+ \Bbb P([1,2,3]) + \Bbb P([2,2,2]) = \frac{\binom42\cdot 4 + 4\cdot 4\cdot 4 + \binom43}{\binom{52}3} \\&\Bbb P(T_4 = 6) = \Bbb P([1,1,1,3])+ \Bbb P([1,1,2,2]) = \frac{\binom43\cdot 4 + \binom42\cdot \binom42}{\binom{52}4} \\&\Bbb P(T_5 = 6) = \Bbb P([1,1,1,1,2]) = \frac{\binom44\cdot 4}{\binom{52}5} \end{align}$$

This gives us a total of

$$\frac1{13} + \frac{38}{1326} + \frac{92}{22100} + \frac{52}{270725}+\frac{4}{2598960} = \frac{7003}{63700}\approx 0.10994.$$

This suggests either some mistake on my part, or an overcounting on yours.


Here is some simple python code to verify results:

from random import shuffle
deck = [1,2,3,4,5,6,7,8,9,10,11,12,13]*4

num_iter = 10**7
total_value = 6

successes = 0
for i in range(num_iter):
    sample_deck = deck.copy()
    shuffle(sample_deck)
    cumulative_sum = 0

    while cumulative_sum < total_value:
        cumulative_sum += sample_deck.pop(0)

    if cumulative_sum == total_value:
        successes += 1;

successes/num_iter

On my machine I got $0.1099681$.