What the distribution describes
The hypergeometric distribution answers one specific question: if you take a fixed number of items from a finite collection without putting any back, how many of a particular kind will you end up with? A hand of cards drawn from a deck is the textbook case.
You need four numbers:
- N: the total number of cards in the deck.
- K: how many of those cards are the type you care about.
- n: how many cards you draw.
- k: how many of the target type you want to find in those n cards.
The chance of getting exactly k is:
P(k) = [ways to choose k of the K target cards] times [ways to choose n minus k of the N minus K other cards], divided by [ways to choose n of the N cards].
In symbols this is written with binomial coefficients, but the words say the same thing. Every possible hand is equally likely; you are counting the hands that contain exactly k target cards and dividing by all hands.
Why order does not matter
The formula counts hands as sets of cards, not sequences. Whether you draw the target card first or fifth makes no difference to what ends up in your hand. That is the reason the formula uses combinations rather than permutations. The distinction between the two is a common stumbling block, and it is explained in more detail in the material on permutations and combinations. If you ever find yourself multiplying a long chain of fractions for each draw, you can reach the same answer, but the set-based count is shorter.
Worked example one: hearts in a five-card hand
A standard 52-card deck has 13 hearts. What is the chance that a five-card hand contains exactly two hearts?
- Choose 2 of the 13 hearts: 78 ways.
- Choose 3 of the 39 non-hearts: 9,139 ways.
- Multiply: 78 times 9,139 = 712,842 favourable hands.
- Total five-card hands: 2,598,960.
- Divide: 712,842 / 2,598,960, about 0.274, or 27.4 percent.
The same setup tells you the chance of at least one heart. The chance of no hearts is the number of ways to choose all five from the 39 non-hearts divided by 2,598,960, and subtracting that from one gives about 0.778, or roughly 78 percent.
Worked example two: one key card in a 60-card deck
A deck has 60 cards, four of which are a card you want. What is the chance your opening seven cards include exactly one of them?
- Choose 1 of the 4 copies: 4 ways.
- Choose 6 of the 56 other cards: 32,468,436 ways.
- Multiply: 129,873,744 favourable hands.
- Total seven-card hands: 386,206,920.
- Divide: about 0.336, or 33.6 percent.
For exactly two copies the same method gives about 5.9 percent. Combined with the 33.6 percent for exactly one, and smaller amounts for three or four copies, this adds up to roughly 40 percent for at least one copy, matching the quicker complement calculation: one minus the chance of drawing none.
Mean and spread
The expected number of target cards is n times K divided by N. For 17 resource cards in a 40-card deck and a seven-card hand, that is 7 times 17 divided by 40, or 2.975.
The variance is n times (K/N) times (1 minus K/N) times ((N minus n) divided by (N minus 1)). For the same example, that is 7 times 0.425 times 0.575 times (33/39), approximately 1.45, giving a standard deviation of about 1.2 cards. That tells you that typical hands will sit within a card or so of three resource cards, which matches the table of exact chances.
The final fraction, (N minus n) divided by (N minus 1), is the finite-population correction. It is less than one, so the spread is smaller than it would be if cards were replaced. This is the numerical footprint of drawing without replacement: because the deck is small and each card taken changes what remains, outcomes cluster a little more tightly around the average.
The binomial shortcut and how far off it is
Many people use the binomial formula instead, which treats every draw as an independent trial with the same probability. For the 40-card, 17-resource deck, each draw would be treated as a 42.5 percent chance of a resource.
The shortcut gets the average right, but the details differ. It gives a chance of zero resources in a seven-card hand of about 2.1 percent, while the exact hypergeometric figure is about 1.3 percent. The binomial standard deviation is roughly 1.31 compared with 1.20. For quick estimates the shortcut is often tolerable, but for small decks and small hands, the exact version is more accurate and just as easy once you have a calculator or spreadsheet.
The difference shrinks as the deck grows relative to the hand. For a very large collection and a small sample, replacing versus not replacing barely matters, which is why the binomial works well for something like dice and poorly for a short deck.
Multiple target types
Real decks have more than two categories, and the same logic extends. If you want the chance of a hand with exactly two of card A and one of card B, count the ways to choose each group and multiply them, then fill the rest of the hand from the remaining cards and divide by all hands. This is the multiplication rule applied to counting rather than to sequential events.
It is easy to make mistakes here, so a good habit is to check that the probabilities for all possible outcomes add up to one. If they do not, a category has been missed or double-counted.
Practical advice
- Write down N, K, n and k before you start, and make sure you can say which of them each number refers to.
- Decide whether you want exactly k, at least k or at most k. Add the exact probabilities for the cases you want.
- Use a spreadsheet function or a short script for the arithmetic. Numbers like 386,206,920 are not meant to be worked out by hand.
- If you want an independent check, run a quick game simulation. A few tens of thousands of simulated hands should land close to the calculated figure.
- Remember what the result means: a long-run frequency across many hands, not a prediction about the next one.
Limits of the model
The hypergeometric distribution assumes a uniformly shuffled deck, a fixed number of cards, and no changes in between. Real games often break these assumptions. Cards that search the deck, put cards back or draw extra cards alter N, K or n part-way through, so the calculation has to be redone for the new situation. Shuffle quality also matters, which is covered in the discussion of shuffle randomness. And the formula says nothing about whether the cards you draw are good, only how often you will see them.