# Counting poker hands

April 11, 2024 at 12:13 PM by Dr. Drang

In this morning’s blog post, John D. Cook talks about poker hands and their probabilities. In particular, he says

For a five-card hand, the probabilities of 0, 1, or 2 pair are 0.5012, 0.4226, and 0.0475 respectively.

Upon reading this, I assumed there’d be an explanation of how these probabilities were calculated. But no, he just leaves us hanging. So I sat down and worked them out.

The probabilities are going to be calculated by dividing the number of ways we can get a certain type of hand by the total number of possible hands. So let’s start by working out the denominator. There are 52 cards, so if we deal out 5 cards, there are

$$\left(\genfrac{}{}{0ex}{}{52}{5}\right)=\mathrm{2,598,960}$$possible ways to do it. The symbol that looks sort of like a fraction without the dividing line represents the binomial coefficient,

$$\left(\genfrac{}{}{0ex}{}{n}{k}\right)=\frac{n!}{k!\phantom{\rule{thickmathspace}{0ex}}(n-k)!}$$This is not only the coefficient of binomial expansions, it’s also the number of ways we can choose *k* items out of *n* without regard to order, also referred to as the number of combinations.

To figure out the number of one-pair hands, imagine the deck laid out in 13 piles: a pile of aces, a pile of kings, a pile of queens, and so on. We then do the following:

- Pick one of the piles. There are 13 ways to do this.
From that pile, choose 2 cards. There are

$$\left(\genfrac{}{}{0ex}{}{4}{2}\right)=6$$ways to do this.

Pick three other piles. There are

$$\left(\genfrac{}{}{0ex}{}{12}{3}\right)=220$$ways to do this.

- Pick one card from each of these three piles. Since there are 4 cards in each pile, there are ${4}^{3}=64$ ways to do this.

So the total number of one-pair hands is

$$13\times 6\times 220\times 64=\mathrm{1,098,240}$$and the probability of getting a one-pair hand is

$$\frac{\mathrm{1,098,240}}{\mathrm{2,598,960}}=0.42257$$Moving on to two-pair hands, we start with the same 13 piles we had before. We then do the following:

Pick two of the piles:

$$\left(\genfrac{}{}{0ex}{}{13}{2}\right)=78$$Pick two cards from each of these piles:

$$\left(\genfrac{}{}{0ex}{}{4}{2}\right)\times \left(\genfrac{}{}{0ex}{}{4}{2}\right)=6\times 6=36$$- At this point, any of the remaining 44 cards will give us a two-pair hand.

Therefore, the total is

$$78\times 36\times 44=\mathrm{123,552}$$and the probability of drawing a two-pair hand is

$$\frac{\mathrm{123,552}}{\mathrm{2,598,960}}=0.04754$$Counting the number of no-pair hands is a little trickier because we have to make sure we don’t mistakenly count better hands, i.e., straights and flushes. Starting again with our 13 piles, we do the following:

Pick 5 piles

$$\left(\genfrac{}{}{0ex}{}{13}{5}\right)=\mathrm{1,287}$$Eliminate all the straights from this number. The number of straights is most easily done through simple enumeration:

A–5, 2–6, 3–7, 4–8, 5–9, 6–10, 7–J, 8–Q, 9–K, 10–A

So 10 of our 1,287 possible pile selections will give us a straight. That leaves 1,277 non-straight possibilities.

- Pick one card from each of the selected piles. That gives ${4}^{5}=\mathrm{1,024}$ possibilities.
- Eliminate the flushes from this set of possibilites. There are 4 flushes, leaving 1,020 possibilities.

These steps give us

$$\mathrm{1,277}\times \mathrm{1,020}=\mathrm{1,302,540}$$hands that are worse than one-pair. The probability of getting such a hand is

$$\frac{\mathrm{1,302,540}}{\mathrm{2,598,960}}=0.50118$$I kept one more digit in my answers than John did, but they all match.