Hypergeometric Distribution Calculator
Find exact, at-most, at-least and range probabilities when you draw from a small population without putting items back. See the full working, the mean and spread, and a chart of every possible outcome.
Last updated October 15, 2026 • Written by Mark, StatsSolve • Free, no sign-up
Hypergeometric Calculator
Enter the population, the number of successes in it, your sample size and k. Results update as you type.
Working appears here.Summary appears here.Show the full distribution table
| k | P(X = k) | P(X ≤ k) | P(X ≥ k) |
|---|
Solve P(X = k), at most, fewer than, at least, more than, or any span of values between a and b.
Every answer comes with the combination counts and the substitution, so it works for homework checks too.
See the with-replacement estimate beside the exact answer and judge how much the shortcut would have cost.
What Does a Hypergeometric Calculator Do?
A hypergeometric calculator works out the probability of drawing a certain number of “successes” when you pick items from a small group and don’t put them back. You give it four numbers: the size of the population, how many of those items count as successes, how many you draw, and how many successes you’re asking about. It does the counting for you.
This one goes a step beyond a single answer. It handles exact, at-most, at-least and between-two-values questions, shows the working with the real combination counts, reports the mean and standard deviation, sets the result next to the binomial shortcut, and draws every possible outcome as a bar chart. The sample buttons above the calculator load a card hand, a factory lot, a lottery ticket and a trading-card opening hand, so you can see the pattern before you type your own numbers.
If you’ve ever asked “what are the odds my five-card hand holds two aces?” or “how likely is it that the inspector finds a bad part in eight samples?”, you were asking a hypergeometric question. The catch is that every draw changes what’s left in the pile, and overlooking that is the most common way people get these problems slightly wrong.
What Is the Hypergeometric Distribution?
The hypergeometric distribution is a discrete probability distribution that describes the number of successes in a sample drawn without replacement from a finite population. It applies whenever a fixed group of items falls into two categories and you take a random handful from it.
Four conditions need to hold. The population has a fixed size, N. Exactly K of those items are successes and the other N − K are failures. You draw a sample of n items at random, and once an item is drawn it stays out. Then you count how many successes landed in the sample, and that count is the random variable X.
“Success” is only a label for whatever you’re tracking: defective parts, red marbles, winning numbers, aces. The name comes from a family of series in mathematics, but you don’t need any of that background to use the distribution.
What Is the Hypergeometric Distribution Formula?
The probability of getting exactly k successes in the sample is:
C(a, b) means “a choose b”, the number of ways to pick b items out of a. If you want those counts for a whole row at once, the binomial expansion calculator lists C(n, 0) to C(n, n) for any n up to 100. The top of the fraction counts the samples that contain exactly k successes: choose k of the K successes, then fill the rest of the sample with n − k of the N − K failures. The bottom counts every possible sample of n items. Favorable samples divided by all samples gives the probability.
The value of k can’t be just anything. It has to sit between max(0, n − (N − K)) and min(n, K), because you can’t draw more successes than exist and you can’t dodge successes once the failures run out. Outside that window the probability is zero, and the calculator prints the valid range beside your result.
The summary measures are short:
The standard deviation is the square root of the variance. The mean matches a binomial distribution with p = K/N, but the variance is smaller by the factor (N − n) / (N − 1), which statisticians call the finite population correction. It captures something intuitive: sampling without replacement leaves less room for surprises, because each draw uses up part of the pool.
How Do You Use This Hypergeometric Calculator?
Fill in the four boxes, choose the type of probability, and the results update as you type. Here is what goes where:
- Population size (N): the total number of items you draw from, such as the 52 cards in a deck.
- Successes in population (K): how many of those items are the kind you’re counting, such as the 4 aces.
- Sample size (n): how many items you draw, such as a 5-card hand.
- Successes in sample (k): the count you want the probability for, such as 2 aces.
Pick Exact for P(X = k), Cumulative for at most, fewer than, at least or more than k, or Between to get the probability that the number of successes falls from a lower limit to an upper limit, both included. The working panel spells out each combination count, so you can follow the arithmetic on paper if you’re checking homework.
If an answer looks odd, check the basics first. K can’t be larger than N, and n can’t be larger than N. The calculator flags both and tells you which box to fix.
Example 1: What Are the Odds of Exactly Two Aces in a Five-Card Hand?
About 3.99%, or roughly 1 in 25. Here N = 52, K = 4, n = 5 and k = 2.
Now flip the question: what’s the chance of holding at least one ace? Adding up the one-, two-, three- and four-ace hands is tedious, so use the complement. A hand with no aces has probability C(48, 5) / C(52, 5) = 1,712,304 / 2,598,960 ≈ 0.6588, which leaves 1 − 0.6588 = 0.3412, about 34%. Set the calculator to Cumulative, choose “≥ At least k” and enter k = 1 to see the same number.
The expected number of aces in a five-card hand is 5 × 4 / 52 ≈ 0.385, with a standard deviation near 0.572.
Example 2: How Likely Is a Sample to Pass a Lot With Defective Parts?
About 75.8%. A supplier ships a lot of 50 gadgets and 6 of them are defective. An inspector pulls 8 at random and tests them, and the lot passes if the sample holds at most 1 defective gadget. So N = 50, K = 6, n = 8.
A lot with 12% defects still gets through about three times out of four. That is the weakness of small samples, and it’s why acceptance sampling plans are designed with these numbers in hand. Raise the sample to 15 and the pass chance drops to about 40.9%, which you can confirm by changing n in the calculator. The expected number of defective gadgets in the original 8-item sample is 8 × 6 / 50 = 0.96.
Example 3: What Are the Chances of Matching Three Numbers in a 6-of-49 Lottery?
Roughly 1.77%, or about 1 in 57. Treat the 6 winning numbers as the successes: N = 49, K = 6, you choose n = 6 numbers, and you want k = 3 matches.
Matching all six numbers has probability 1 / 13,983,816, which is about 0.000007%. Lottery formats differ from state to state and game to game, so check the rules of the one you play. The 6-from-49 layout is simply the classic textbook version of the problem.
Example 4: How Often Does a Four-Copy Card Show Up in an Opening Hand?
In a 60-card deck with 4 copies of a card, a 7-card opening hand contains at least one copy about 39.9% of the time. Here N = 60, K = 4 and n = 7.
Draw into 10 cards and the chance climbs to about 52.8%. That’s why deck builders talk about “seeing” a key card by the third or fourth turn. Players of trading-card games lean on hypergeometric calculations more than almost anyone, even if they never use the word.
How Does the Hypergeometric Distribution Differ From the Binomial Distribution?
The hypergeometric distribution samples without replacement, so the chance of a success changes with every draw. The binomial distribution samples with replacement, or from a population so large that removing one item hardly matters, so the chance of a success stays fixed. The conditions for a binomial distribution explain when that shortcut is safe, including the 10% rule.
| Feature | Hypergeometric | Binomial |
|---|---|---|
| Sampling | Without replacement | With replacement, or a huge population |
| Draws independent? | No | Yes |
| Parameters | N, K, n | n, p |
| Mean | nK / N | np |
| Variance | np(1 − p)(N − n)/(N − 1) | np(1 − p) |
| Typical use | Card hands, inspection lots, small pools | Coin flips, repeated trials |
When can you swap one for the other? A common rule of thumb says the binomial is a fine stand-in when the sample is under about 5% of the population. Take N = 1,000, K = 100 and n = 10, and ask for exactly 2 successes. The hypergeometric answer is 0.1945, while a binomial with p = 0.1 gives 0.1937. For most purposes that’s the same number. If you draw with replacement and stop at the first success instead, the geometric distribution calculator is the right tool.
Shrink the population and the gap opens up. The two-aces problem gives 0.0399 with the exact method, but a binomial with p = 4/52 says 0.0465, about 17% too high. The calculator prints the binomial estimate next to every result so you can see what the shortcut would have cost you.
If the binomial version is what you need, our binomial distribution calculator and binomial probability calculator cover exact, at-most, at-least and between questions. When you’re counting events over a stretch of time instead of out of a fixed pool, the Poisson distribution calculator is the better fit, and for continuous measurements such as heights or test scores, try the normal curve calculator.
Where Is the Hypergeometric Distribution Used in Real Life?
Anywhere a fixed pool is sampled without replacement and someone counts the hits. A few places it turns up:
- Quality control. Acceptance sampling pulls a handful of units from a lot and decides whether the lot is good enough, exactly like Example 2.
- Auditing and election checks. Auditors sample invoices or ballots from a known batch and ask how likely it is that errors would slip past the sample.
- Games. Card hands, bingo and lotteries all draw from a finite set without putting anything back.
- Ecology. In mark-and-recapture studies, biologists tag K animals in a population of N, catch n later, and count the tagged ones. That count follows a hypergeometric pattern, and the logic can be turned around to estimate N.
- Medicine and genetics. Fisher’s exact test for a 2×2 table builds its p-value from hypergeometric probabilities, and gene-set enrichment tests ask whether a pathway shows up in a gene list more often than chance would allow.
In each case the population is limited and the sample takes a real bite out of it, which is the situation where the binomial model starts to drift.
How Do You Calculate Hypergeometric Probabilities in Excel, R, and Python?
Each has a built-in function, and each orders the inputs differently, which is where most slips happen. These examples use the two-aces problem (N = 52, K = 4, n = 5, k = 2).
Excel =HYPGEOM.DIST(2, 5, 4, 52, FALSE) -> 0.0399
=HYPGEOM.DIST(2, 5, 4, 52, TRUE) -> 0.9982 (P(X <= 2))
# order: sample_s, number_sample, population_s, number_pop, cumulative
R dhyper(2, 4, 48, 5) -> 0.0399
phyper(2, 4, 48, 5) -> 0.9982
# order: successes, failures, sample size
Python from scipy.stats import hypergeom
hypergeom.pmf(2, 52, 4, 5) -> 0.0399
hypergeom.cdf(2, 52, 4, 5) -> 0.9982
# order: k, population size, successes in population, sample size
Excel wants the sample numbers first, R wants the count of failures instead of the population size, and SciPy asks for the population size first. Running the same problem through this calculator is a quick way to check you passed the arguments in the right order.
What Mistakes Do People Make With Hypergeometric Problems?
The most frequent one is mixing up K and n. K is the number of successes sitting in the whole population; n is how many items you pull out. Swap them and you get a perfectly valid probability for a different question, which makes the error hard to spot.
The second is using the distribution when the draws are replaced. If each item goes back before the next draw, you’re in binomial territory and the finite population correction no longer applies.
Third, people read “at least” as “exactly”. P(X = 2) and P(X ≥ 2) are different questions with different answers, so choose Cumulative when the wording says at most, at least, fewer than or more than.
Fourth, asking for an impossible count. With only 4 aces in the deck, five aces in a hand has probability 0, not a small number. The calculator shows the valid range of k so you can see where the possible outcomes start and stop.
Last, forgetting that the labels are interchangeable. The chance of 2 aces in a five-card hand is the same as the chance of 3 non-aces, so you can define “success” either way as long as K, k and the wording all follow the same choice.
Key Points to Remember
- The hypergeometric distribution counts successes in a sample taken without replacement from a finite population.
- The formula is P(X = k) = C(K, k) × C(N − K, n − k) / C(N, n).
- The mean is nK/N, and the variance carries the finite population correction (N − n)/(N − 1).
- Use Cumulative for “at most” and “at least” questions, and the complement rule for “at least one”.
- When the sample is under about 5% of the population, the binomial distribution gives nearly the same answer.
- Counts outside max(0, n − (N − K)) to min(n, K) have probability zero.
- Excel, R and SciPy order their arguments differently, so double-check them against a known example.
Frequently Asked Questions
What is the difference between a hypergeometric and a binomial distribution?
A hypergeometric distribution models draws without replacement from a finite population, so each draw changes the odds of the next one. A binomial distribution models independent trials with a constant success probability, which means sampling with replacement or from a very large population. The hypergeometric mean equals the binomial mean, but its variance is smaller by the factor (N − n)/(N − 1).
How do I find the probability of at least one success?
Find the probability of zero successes and subtract it from 1. In this calculator you can also choose Cumulative, pick “≥ At least k” and enter k = 1. For a five-card hand and the 4 aces in a deck, P(at least one ace) = 1 − C(48, 5)/C(52, 5) ≈ 0.3412.
What do N, K, n and k stand for?
N is the population size, K is the number of successes in that population, n is the sample size, and k is the number of successes you are asking about in the sample. In a 52-card deck, N = 52 and K = 4 aces. A 5-card hand makes n = 5, and k = 2 asks about exactly two aces.
Why does the calculator show a probability of zero?
The number of successes you entered is outside the possible range. The sample can hold at most min(n, K) successes and at least max(0, n − (N − K)). Five aces from a 52-card deck is impossible because only four exist, so the probability is exactly zero. The valid range is shown in the results.
Is the hypergeometric distribution the same as Fisher’s exact test?
They are closely linked but not identical. Fisher’s exact test for a 2×2 table calculates its p-value by adding hypergeometric probabilities with the row and column totals held fixed. The distribution is the probability model, and the test is a procedure that uses it.
How large a population can this calculator handle?
Population sizes up to 1,000,000 are supported. For very large inputs the combination counts in the working panel appear in scientific notation, and the probabilities are computed with logarithms to stay accurate.
Is this hypergeometric calculator free, and how accurate is it?
It is free with no sign-up. Probabilities come from the exact hypergeometric formula, and StatsSolve checks the output against SciPy’s hypergeom functions for a range of test cases.
Further reading: Penn State STAT 414, Lesson 7 (hypergeometric distribution) and Microsoft Support: HYPGEOMDIST function.
Related Calculators
Working on a different statistics problem? Try these StatsSolve tools, or browse the full list of free statistics calculators:
Binomial Distribution CalculatorExact, cumulative, and interval binomial probabilities with full statistics.
Binomial Probability CalculatorExact, at most, at least, and between-value binomial probabilities.
Normal Curve CalculatorZ-scores and normal / bell-curve probabilities.
All StatsSolve CalculatorsBrowse the full directory of free statistics tools, including Poisson and Gaussian.

