# What is the probability that 5 randomly chosen cards in a deck add up to 40 or greater?

I have made a probability game, where you have to pull out any 5 cards without looking (from a deck of 52 cards), and if all five cards add up to 40 or more, they player pulling the 5 cards from the deck wins. What is the probability of winning the game?

Face and Ace Card values:

Ace = 1

Jack = 11

Queen = 12

King = 13

The value of the number cards are the ones that are stated on the card: for example a card that has 2 on it has a value of 2.

There is also a grand prize, and it would be if it just added up to 40. How many combinations are there and why?

• It is no easy to get a good estimate by hand. Simulation may be the way to go. Commented May 27, 2015 at 3:57
• I am uncomfortable because of the smallness of $5$. Commented May 27, 2015 at 5:05
• @AndréNicolas: Oh for uniform distributions sample size of $5$ is really very good. Just to make sure I did a simulation of that! It fits the normal distribution closely. If the required cutoff was far from the mean (into the tails) then I would also worry about the normal approximation. Commented May 27, 2015 at 5:12

Normal approximation:

Consider a single card draw from the deck:

E(X)=7

Var(X)=14

With the sum of 5 cards (drawn without replacement):

$E(X)=7 \times 5$

$\text{Var}(X)=14\times 5\times \frac{52-5}{52-1}$

(the last term being the 'finite population correction', which applies as much to the variance of the sum as it does to the variance of the mean).

The approach to normality in this situation is reasonably rapid.

This suggests the sum on 5 cards might be be roughly approximated by a normal distribution with mean $35$ and variance $70\times\frac{47}{51}\approx 64.5098$. Using a continuity correction this gives an approximate probability of totalling at least 40 on 5 cards of:

$$1-\Phi(\frac{39.5-35}{\sqrt{70\times\frac{_{47}}{^{51}}}})\approx 0.288$$

Simulation (in R) of ten million five-card draws indicates the probability is
about $0.293$ (with s.e. $\approx 1.4\times 10^{-4}$):

 res=replicate(10000000,sum(sample(rep(1:13,4),5,replace=FALSE)));mean(res>=40)
[1] 0.2927447


As a check on the earlier calculation of the variance, the standard deviation of of those simulated sums was 8.0316; the previous calculation gives 8.0318.

Edit: Here's a comparison of the empirical cdf of the simulated data with the above normal approximation; they're pretty close:

More extensive simulations are consistent with the other two answers based on complete enumeration:

• What website did you use to make the graph? Commented May 28, 2015 at 4:03
• No website -- I used $\mathbf{R}$ to make both, though with the second one I added some details (such as the names in the blue line) by editing afterward. (It would be possible to do the whole thing pretty much as is in R.) Commented May 28, 2015 at 10:25
• Thanks a lot! Commented May 28, 2015 at 13:25

Glen_b's answer is good enough for all practical purposes, but I'll include here the computation of the exact probability (computer-assisted, but I think it could be done by hands with enough time, courage and a few additional tricks). There are 2598960 possibilities of choosing 5 cards among 52. It is fast enough for a computer to test every possibility, but we can be smarter.

When choosing 5 cards among 52, how many cards of different heights can we get? There are 6 possibilities, or partitions (the partition number of 5 minus 1, because we can't get 5 cards of the same height):

• (1,1,1,1,1) (all the heights are distinct)
• (1,1,1,2) (a pair)
• (1,2,2) (double pair)
• (1,1,3) (three of a kind)
• (2,3) (full house)
• (1,4) (four of a kind)

In addition, there are respectively 1024, 384, 144, 64, 24 and 4 different ways of realizing one of these hands when the number of cards at each height are given (e.g. if I tell you that you have one "eigth" and four "King", that corresponds to 4 differents hands, depending on the colour of the "eigth"). These numbers are weights.

Now, for each partition, we compute how many heigths give rise to a sum of at least 40. For instance, for (1,4), we have to find the number of solutions of $x+4y \geq 40$ under the constraints $1 \leq x,y \leq 13$ and $x \neq y$. For the last four partitions, it can be done manually (it is easy for the last two ones), but the computer is very handy for the first two. We find respectively 337, 916, 291, 326, 59 and 64 favourable outcomes. If we multiply by the weights and sum, this yields 760092 favourable outcomes.

Hence, the probability of getting at least 40 is:

$$\frac{761272}{2598960} = \frac{95159}{324870} \simeq 0,293$$

This method may seem complicated, especially given that the problem can be brute-forced, but we have reduced the number of possibilities to check from 2,5 millions to about 5 thousands, not too far from being doable without a computer (and, at least, there are some interesting mathematics).

Edit: the error has been corrected. I just made a typo when I computed $337*1024+916*384+291*144+326*64+59*24+64*4 = 761272$ (my message initially gave this sum at 760092). The reasoning is sound.

• Thank's a lot for the helpful answer! Commented May 27, 2015 at 8:59
• I don't find the same answer, but I have a doubt :) Do you take the number of possibilities of combinations into account? I mean for the (1,1,1,2) case for instance, there are $5 \choose 2$ ways to place the pair. You don't seem to take the order into account at all (hence the 2598960), but I'm not sure it's correct, since the different "patterns" ((1,1,1,1,1), (1,1,1,2)...) don't have the same number of possibilities. Commented May 27, 2015 at 9:32
• @jca: I think there is an error, but this is not the one you pointed out (I'd bet on an error in my program). I don't care about the order of the cards in my hand. As for the patterns, there are two things : the number of cards of each heigth (I didn't write these numbers), and the number of ways to colour these cards when the heigths are given. The weigths are the second series of numbers. I didn't write the first series, but I computed them and they are consistent. Commented May 27, 2015 at 10:54
• @jca: I found my error. My enumeration is sound, but I made a typo when I computed the final answer. Commented May 27, 2015 at 11:00
• Looks good now. Commented May 27, 2015 at 11:24

Here is a brute force solution in Python

def prob():
n = 13
u = [4]*n
p = q = 0
for a in range(n):
pa = u[a]
u[a] -= 1
for b in range(n):
pb = u[b]
u[b] -= 1
for c in range(n):
pc = u[c]
u[c] -= 1
for d in range(n):
pd = u[d]
u[d] -= 1
for e in range(n):
if u[e] == 0:
continue
pe = u[e]
if a + b + c + d + e >= 35:
p += pa*pb*pc*pd*pe
q += pa*pb*pc*pd*pe
u[d] += 1
u[c] += 1
u[b] += 1
u[a] += 1
return p, q

p, q = prob()
q - 52*51*50*49*48      # 0
g = gcd(p, q)
p//g                    # 95159
q//g                    # 324870


The program is straightforward: update the numerator and denominator of the probability for each choice of $a,b,c,d,e$, the card values. The sum is compared to $35$ instead of $40$ since indices run from $0$ to $12$.

The product $pa\cdot pb\cdot pc\cdot pd\cdot pe$ takes into account the fact that outcomes are not equiprobable: u[i] represents the number of available cards with value $i$, before each card is chosen. For example, for the cards (1,1,1,1,2), the update would be $4\cdot3\cdot2\cdot1\cdot4$, while for (1,2,3,4,5) is would be $4^5$. The denominator is always $52\cdot51\cdot50\cdot49\cdot48$, and $q$ is compared to this value in the end, as a check.

The probability is thus

$$\frac{95159}{324870}\approx 0.292914$$

For completeness, the code above uses a gcd function:

def gcd(a, b):
while b != 0:
a, b = b, a%b
return a