How to use the hypergeometric distribution calculator
- Enter the group size (N), the number of marked items in the group (K), the number you draw (n), and the number of marked items you want in the draw (k). Items are drawn without putting any back.
- The headline gives the chance of exactly k marked items. The list below it gives the chance of at most k, fewer than k, at least k and more than k, with the mean, variance and standard deviation.
- The table shows the chance of each count near your k, with your row highlighted. Counts that cannot happen, for example more marked items than were drawn, show a probability of 0.
- Use Copy, Print or CSV to keep the result.
Formula
P(X = k) = C(K, k) x C(N - K, n - k) / C(N, n)
Mean = n x K / N
Variance = n x (K / N) x (1 - K / N) x (N - n) / (N - 1)
C(a, b) is the number of ways to choose b items from a. The numerator counts the draws with exactly k marked items, and the denominator counts all possible draws.
A box of 50 with 10 marked
Draw 5 items from 50, where 10 are marked. The chance of exactly 1 marked item is C(10, 1) x C(40, 4) / C(50, 5) = 10 x 91,390 / 2,118,760 = 0.431337. The chance of 1 or fewer is 0.7419, and the mean number of marked items in a draw is 5 x 10 / 50 = 1.
If the draws were made with replacement, the chance of 1 marked item in 5 draws at 20% each would be 5 x 0.2 x 0.8^4 = 0.4096. The hypergeometric answer, 0.4313, is different because each draw changes what is left. For 5 cards from a 52 card deck, the chance of exactly 2 hearts is C(13, 2) x C(39, 3) / C(52, 5) = 712,842 / 2,598,960 = 0.27428.
When to use this distribution
Use it when you draw a fixed number of items from a group that has two kinds of items, and you do not put any back. Examples are cards from a deck, defective parts in a sample taken from a batch, or winners among tickets drawn from a pool. If you replace each item before the next draw, the chances stay the same each time, and the binomial probability calculator fits better. When the group is very large compared with the draw, the two give nearly the same answer.
The mean n x K / N is the same as for the binomial case, but the spread is smaller, because drawing without replacement removes some of the chance. The last factor of the variance formula, (N - n) / (N - 1), is the amount of that reduction. It is 1 for very large groups and falls to 0 when you draw the whole group.
Exact counts, large groups
The counts of ways to draw are huge whole numbers even for modest groups, so the tool works with exact whole-number arithmetic and divides only at the end. That keeps the answer accurate for groups up to 5,000 items, where the number of possible draws has over a thousand digits. Probabilities smaller than one in a million are shown in scientific notation, and anything below 1e-300 is reported as such rather than as a misleading zero.
For events with no fixed group, such as arrivals per hour, see the Poisson distribution calculator, and for independent trials with a fixed chance each time, use the binomial one. The probability calculator handles the basic combinations of events.
Assumptions and limits
- Every item in the group is equally likely to be drawn at each step, and drawn items are not replaced.
- The group has only two kinds of items: marked and unmarked.
- The group size is limited to 5,000 items.
- Probabilities are shown to six decimal places, or in scientific notation when smaller than one in a million.
Frequently asked questions
What is the difference between hypergeometric and binomial?
The binomial model puts each item back before the next draw. The hypergeometric model does not, so each draw changes the chances of the next one.
Why is the probability of some counts exactly 0?
Some counts are impossible. You cannot draw more marked items than exist, or more than you draw, and a draw may have to include some marked items if few unmarked ones remain.
What does the variance correction mean?
It is the factor (N - n) / (N - 1). It reduces the spread compared with drawing with replacement, and it disappears as the group becomes very large compared with the draw.
Why is the group limited to 5,000?
Exact counts for larger groups take noticeably longer to compute in a browser. The limit keeps the page quick while covering most real sampling problems.