Hypergeometric Probability Calculator
Sampling without replacement: how likely is it to draw exactly k successes from a finite population? Enter the population, the successes in it, your draws, and the successes you want.
Population
Sample
P(X = k) = C(K,k) × C(N−K, n−k) ÷ C(N,n). Use for card hands, quality-control sampling, and lottery-style draws — anywhere each draw changes the odds of the next.
You draw five cards from a deck and wonder about the odds of getting exactly two aces. A quality inspector pulls ten parts from a batch of two hundred and asks how likely three defectives are. These are not coin-flip problems, because every draw changes the odds of the next one. That is the world of the hypergeometric distribution.
The Hypergeometric Probability Calculator solves these without-replacement problems. You enter the population size (N), the number of successes hidden in it (K), how many items you draw (n), and the number of successes you are asking about (k). It returns the exact probability, the cumulative odds, and the expected value.
Students meet this distribution in probability class, but it shows up everywhere in real life: card games, lottery draws, audit sampling, genetics, and manufacturing quality control. Anywhere you sample from a finite group without putting items back, this calculator has the answer.
What Does the Hypergeometric Probability Calculator Do?
This calculator answers the question: if I draw n items from a population of N that contains K successes, what is the chance I get exactly k successes? It computes P(X = k) using the hypergeometric formula with combinations.
It also computes the two cumulative probabilities that matter in practice: P(X at most k), the chance of getting k or fewer successes, and P(X at least k), the chance of getting k or more. Quality inspectors live on these tails: they want to know the chance of finding at least a certain number of defects.
Finally, it shows the expected value, the average number of successes you would see if you repeated the draw many times, plus the standard deviation so you know how much individual draws typically wander from that average.
How to Use the Hypergeometric Probability Calculator
Enter the population size (N): the total number of items. For a card problem this is 52; for a factory batch it might be 200.
Enter the successes in the population (K): how many of those items count as successes. There are 4 aces in a deck; a batch might contain 12 defective parts.
Enter your draws (n), the sample size, and the successes wanted (k), the exact count you are asking about. Press Calculate. The headline shows P(X = k) as a percentage, with the cumulative probabilities and expected value below.
Without Replacement: The Key Idea
Flip a coin ten times and the odds never change: always 50-50. That is sampling with replacement, or equivalently, from an infinite population. Draw cards from a deck without putting them back and everything shifts with each draw.
After you draw one ace from a full deck, only 3 aces remain among 51 cards, so the chance the next card is an ace drops from 4/52 to 3/51. The hypergeometric distribution is the mathematics of this shifting probability. Use the binomial distribution instead and your answers will be wrong whenever the sample is a sizable fraction of the population.
The Formula, Piece by Piece
The formula is:
P(X = k) = C(K,k) × C(N−K, n−k) ÷ C(N,n)
Read it as a counting argument. C(N,n) is the total number of ways to draw your sample. The numerator counts the favorable ones: C(K,k) ways to choose which k successes you got, times C(N−K, n−k) ways to fill the rest of your draw with failures. Favorable divided by total is the probability.
You never need to compute this by hand. The combinations explode quickly: C(52,5) is 2,598,960. The calculator's combination routine multiplies and divides step by step to stay exact without overflowing.
N, K, n, k: Keeping the Letters Straight
Capital N is the whole population, capital K is the successes hiding inside it. Lowercase n is how many you draw, lowercase k is the number of successes you are asking about. The capitals describe the world; the lowercase letters describe your sample.
A handy check: k can never exceed n (you cannot draw more successes than cards), k can never exceed K (there are not that many successes to find), and n can never exceed N (you cannot draw more items than exist). The calculator enforces all of these and tells you plainly which rule you broke.
Exact vs. Cumulative Probability
P(X = k) answers "exactly two aces." But real questions are often "at least two aces" or "no more than one defective." Those are cumulative probabilities, sums of exact probabilities across a range of k values.
The calculator sums the exact probabilities from 0 up to k for P(X ≤ k), and from k up to the maximum possible for P(X ≥ k). Note that these two overlap at exactly k, so they sum to more than 100%. That is correct: "at most 2" and "at least 2" both include the outcome of exactly 2.
Expected Value and Spread
The expected number of successes is beautifully simple: n × K / N. Draw 5 cards from a deck with 4 aces and you expect 5 × 4/52, about 0.38 aces. Expectation scales proportionally, which matches intuition.
The standard deviation measures the typical wobble around that average. It shrinks as your sample approaches the whole population: if you draw all 52 cards, there is no randomness left and the spread is zero. The calculator shows both so you can judge whether an observed result is ordinary luck or something surprising.
When the Binomial Approximation Works
When the population is huge relative to the sample, removing a few items barely changes the odds, and the simpler binomial distribution gives nearly the same answer. The rule of thumb: if n is less than 5% of N, the binomial approximation is fine.
Drawing 10 parts from a batch of 10,000 is effectively binomial. Drawing 10 from 200 is not, and the hypergeometric correction matters. When in doubt, use this calculator: it is exact, so it is right in both cases.
Worked Example: Two Aces in Five Cards
First: note the inputs. N = 52 cards, K = 4 aces, n = 5 drawn, k = 2 wanted.
Then: count the favorable hands. C(4,2) = 6 ways to pick the aces, times C(48,3) = 17,296 ways to pick the other cards, giving 103,776 favorable hands.
Then: count all possible hands. C(52,5) = 2,598,960.
Then: divide. 103,776 / 2,598,960 = 0.03993.
Answer: about 3.99%. Getting at least 2 aces is about 4.30%, and the expected number of aces in five cards is 0.38.
Worked Example: Defective Parts in a Batch
First: note the inputs. N = 200 parts, K = 12 defective, n = 10 sampled, k = 0 wanted.
Then: the chance of zero defectives is C(12,0) × C(188,10) / C(200,10).
Then: this works out to about 0.5229.
Then: the chance of finding at least one defective is 1 minus that, about 0.4771.
Answer: P(X = 0) ≈ 52.29%, so there is a 47.71% chance the sample catches at least one bad part. Expected defectives: 0.60.
Worked Example: Lottery-Style Draw
First: note the inputs. N = 50 balls, K = 6 winning balls, n = 6 drawn, k = 3 wanted.
Then: favorable outcomes are C(6,3) × C(44,3) = 20 × 13,244 = 264,880.
Then: total outcomes are C(50,6) = 15,890,700.
Then: divide to get about 0.01667.
Answer: about 1.67% chance of matching exactly 3 of 6. The chance of matching at least 3 is about 1.77%.
Worked Example: Committee Selection
First: note the inputs. N = 30 club members, K = 12 women, n = 5 chosen, k = 3 wanted.
Then: favorable selections are C(12,3) × C(18,2) = 220 × 153 = 33,660.
Then: total selections are C(30,5) = 142,506.
Then: divide to get about 0.2362.
Answer: about 23.62% chance of exactly 3 women on the committee. Expected number: 2.0.
Common Hypergeometric Mistakes
The classic mistake is using the binomial formula for without-replacement draws. If the sample is more than 5% of the population, the binomial answer is noticeably off, always understating how much the changing odds matter.
Another is mixing up K and k. K is the successes in the whole population (a fixed fact about the world), k is the count you are asking about in your sample. Swapping them produces nonsense or an error message.
People also forget that "at least" and "at most" overlap at exactly k. If your two cumulative probabilities sum to more than 100%, nothing is broken; both include the exact-k outcome.
Where Hypergeometric Calculations Are Useful
Quality control is the biggest real-world user: given a batch with an unknown defect rate, inspectors compute the chance a sample of n catches the problem. Auditors use the same math when sampling transactions for fraud.
Card players use it to evaluate drawing odds in poker, bridge, and collectible card games. Biologists use it for gene-set enrichment: given K marked genes in a genome of N, how surprising is it that k of them appear in a sample of n? Lottery designers use it to set prize tiers.
How to Interpret Your Result Correctly
Read the headline as a long-run frequency. A 3.99% chance of two aces means that in 10,000 five-card deals, you would see about 399 with exactly two aces. It says nothing about the next deal, which is always a fresh 3.99%.
Use the cumulative cards for decision questions. "Should I worry about at least 2 defectives in my sample?" is a P(X ≥ 2) question, not a P(X = 2) question. And compare the expected value to what you actually observed: an observation many standard deviations from the mean deserves a second look.
Frequently Asked Questions
1. What is the hypergeometric distribution?
It is the probability distribution for the number of successes in a sample drawn without replacement from a finite population. It applies whenever each draw changes the odds of the next one.
2. What is the hypergeometric formula?
P(X=k) = C(K,k) x C(N-K,n-k) / C(N,n). The numerator counts favorable samples, the denominator counts all possible samples, and C(a,b) is the combination function.
3. How is this different from the binomial distribution?
The binomial assumes each trial has the same success probability, like coin flips. The hypergeometric handles draws without replacement, where the probability shifts after every draw. For large populations relative to the sample, the two nearly agree.
4. What do N, K, n, and k stand for?
N is the population size, K is the number of successes in the population, n is the number of draws, and k is the number of successes you are asking about. Capitals describe the population; lowercase letters describe the sample.
5. Can k be larger than K?
No. You cannot draw more successes than exist in the population. The calculator rejects such inputs with an explanation, along with the other impossible cases like n larger than N.
6. Why do "at most k" and "at least k" sum to more than 100%?
Because both include the outcome of exactly k. P(X ≤ k) + P(X ≥ k) = 100% + P(X = k). This is correct behavior, not a bug.
7. What is the expected value?
The mean number of successes, equal to n x K / N. Draw 5 cards from a deck and you expect 5 x 4/52, about 0.38 aces. It is the long-run average over many repetitions.
8. When can I use the binomial approximation instead?
When your sample is less than about 5% of the population. Then removing items barely changes the odds. For larger sampling fractions, use the exact hypergeometric calculation.
9. How do lotteries use this math?
A 6-from-50 lottery is exactly hypergeometric: N = 50 balls, K = 6 winning balls, n = 6 drawn. The jackpot odds are 1 / C(50,6), about 1 in 15.9 million.
10. What is a combination C(n,r)?
The number of ways to choose r items from n without regard to order, equal to n! / (r! x (n-r)!). C(52,5) = 2,598,960 is the number of possible 5-card poker hands.
11. Can the calculator handle large populations?
Yes, within reason. The combination routine multiplies and divides incrementally to avoid overflow. Extremely large values (populations in the billions) may lose precision; use the binomial approximation there.
12. What does the standard deviation tell me?
How far typical results stray from the expected value. An observed count several standard deviations from the mean is evidence that something unusual is happening, such as a biased process.
13. Is drawing with replacement ever hypergeometric?
No. With replacement, each draw is independent with fixed probability, which is the binomial setup. Hypergeometric is specifically the without-replacement case.
14. How do auditors use this?
An auditor sampling n transactions from N wants the probability of catching at least one fraudulent one, given an assumed fraud count K. That is a P(X ≥ 1) calculation, which this calculator handles.
15. Why is P(X = 0) sometimes the most useful answer?
In quality control, P(X = 0) is the chance your sample misses every defective. If that chance is high, your sampling plan is too weak. One minus that value is the detection probability.