Quick Definition — What Is the Hypergeometric Distribution?
The hypergeometric distribution is a discrete probability distribution that models the number of successes X in a sample of size n drawn without replacement from a finite population of N items containing exactly K successes. Unlike the binomial distribution, which assumes each trial is independent, the hypergeometric accounts for the fact that each draw changes the composition of the remaining population. Its PMF is: P(X = x) = [C(K, x) × C(N−K, n−x)] / C(N, n).
Hypergeometric Probability Calculator
What Is the Hypergeometric Distribution?
The hypergeometric distribution models a specific sampling situation: you have a finite population of N items, of which K are "successes" (or items of interest). You draw n items at random, without replacing each item before the next draw. The random variable X counts how many of those n drawn items are successes.
This differs fundamentally from the binomial distribution, which assumes each draw is independent (sampling with replacement, or from an infinite population). In the hypergeometric case, drawing one success reduces the number of remaining successes, making successive draws dependent on prior ones.
Classic example: A lot of 20 items contains 8 defective units. A quality inspector samples 5 items without replacement. What is the probability that exactly 2 of the 5 are defective? Here N = 20, K = 8, n = 5, x = 2. This is a hypergeometric problem because sampling is done without replacing items.
The Four Parameters: N, K, n, and x
Every hypergeometric probability depends on exactly four values. Understanding each parameter is the first step to reading any hypergeometric table or applying the formula correctly.
Hypergeometric Distribution Formula
The Probability Mass Function (PMF) gives the exact probability of observing exactly x successes in a sample of n:
Where C(a, b) = a! / [b! × (a−b)!] is the binomial coefficient ("a choose b").
Valid Range of x
x cannot exceed the number of successes available (K), and x cannot be so small that the remaining draws cannot all come from non-successes (N−K).
Expected Value & Variance
Var(X) = n × (K/N) × ((N−K)/N) × ((N−n)/(N−1))
The factor (N−n)/(N−1) is the finite population correction, reducing variance versus the binomial.
Hypergeometric Distribution PMF Table
The table below shows P(X = x) for common parameter combinations. Select the scenario tab to view the corresponding probability table. Click any cell to highlight and load the result above.
PMF = P(X = x) = [C(K,x) × C(N−K,n−x)] / C(N,n). CDF = P(X ≤ x) = cumulative sum of PMF. Values computed using exact combinatorial formulas. Source: see NIST/SEMATECH e-Handbook of Statistical Methods.
How to Read the Hypergeometric Distribution Table
The table has three key columns: the value of x (number of successes in the sample), the PMF probability P(X = x), and the cumulative CDF probability P(X ≤ x). Here is how to interpret each:
Step 1 — Identify Your Parameters
Determine N (total population), K (successes in population), n (sample size), and the value of x you are interested in. Match these to a scenario in the table or use the calculator above with your own values.
Step 2 — Find the Row for x
Locate the row where x equals the number of successes you want to evaluate. The PMF column gives the exact probability of that specific outcome. The CDF column gives the probability of getting that many or fewer successes.
Step 3 — Use the CDF for Inequality Probabilities
For probabilities of the form P(X ≤ x), read the CDF column directly. For P(X ≥ x), calculate 1 − P(X ≤ x−1). For P(a ≤ X ≤ b), calculate P(X ≤ b) − P(X ≤ a−1).
P(X ≥ x) → = 1 − CDF at (x−1)
P(X = x) → Read PMF column directly
P(a ≤ X ≤ b) → = CDF(b) − CDF(a−1)
Step 4 — Verify the Range of x
The hypergeometric distribution has a restricted support. If you ask for a value of x below max(0, n+K−N) or above min(n, K), the probability is exactly 0. The table only shows rows for x values with non-zero probability.
Worked Examples Using the Hypergeometric Distribution Table
Example 1 — Quality Control Inspection
Scenario: A manufacturer ships a lot of N = 20 items. Quality control knows that K = 8 of these are defective. An inspector randomly selects n = 5 items without replacement. What is the probability that exactly x = 2 are defective?
| Step | Action | Calculation |
|---|---|---|
| 1 | Identify parameters | N=20, K=8, n=5, x=2 |
| 2 | Check valid range | max(0, 5+8−20)=0 ≤ x ≤ min(5,8)=5 ✓ |
| 3 | Compute C(K, x) = C(8, 2) | 8! / (2! × 6!) = 28 |
| 4 | Compute C(N−K, n−x) = C(12, 3) | 12! / (3! × 9!) = 220 |
| 5 | Compute C(N, n) = C(20, 5) | 20! / (5! × 15!) = 15,504 |
| 6 | Divide | P(X=2) = (28 × 220)/15,504 = 6,160/15,504 ≈ 0.3973 |
Interpretation: There is approximately a 39.7% probability that exactly 2 of the 5 inspected items are defective. This is the most likely outcome (the modal value). The expected number of defectives is E(X) = 5 × (8/20) = 2.
Example 2 — Card Game (Drawing Hearts)
Scenario: A standard deck has N = 52 cards, K = 13 of which are hearts. Five cards are dealt (n = 5) without replacement. What is the probability of getting exactly x = 2 hearts?
= 78 × 9,139 / 2,598,960
= 712,842 / 2,598,960 ≈ 0.2743
Interpretation: There is a 27.4% chance of drawing exactly 2 hearts in a 5-card hand. Note that using the binomial distribution here (incorrectly assuming independence) would give a slightly different and less accurate answer because cards are dealt without replacement.
Example 3 — Clinical Trial Patient Allocation
Scenario: A clinic has N = 30 eligible patients, K = 12 of whom have a specific genetic marker. A researcher randomly selects n = 8 patients for a study. What is the probability that at most x = 3 carry the marker (i.e., P(X ≤ 3))?
= 0.0011 + 0.0173 + 0.1017 + 0.2647 ≈ 0.3848
Interpretation: There is about a 38.5% chance that 3 or fewer of the 8 selected patients carry the genetic marker. The most likely outcome is E(X) = 8 × (12/30) = 3.2 patients. This calculation uses the CDF, which sums individual PMF values. Use the CDF column in the table for questions about "at most" or "at least" probabilities.
Example 4 — Small Lot Sampling (N=10, K=4, n=3)
Scenario: A box contains N = 10 bolts, K = 4 of which are oversized. A technician tests n = 3 bolts without replacement. Find the complete probability distribution for X.
| x (oversized) | P(X = x) — PMF | P(X ≤ x) — CDF | Interpretation |
|---|---|---|---|
| 0 | 0.1667 | 0.1667 | No oversized bolts |
| 1 | 0.5000 | 0.6667 | Most likely outcome |
| 2 | 0.3000 | 0.9667 | Two oversized |
| 3 | 0.0333 | 1.0000 | All three oversized |
E(X) = 3 × (4/10) = 1.2. Note: all PMF values sum to 1.0000. ✓
PMF vs CDF: Which Probability Do You Need?
The type of probability question determines whether to use the PMF column or the CDF column in the hypergeometric table. The distinction is straightforward once you identify the key words in the problem.
| Question Phrasing | Use | Formula | Table Column |
|---|---|---|---|
| "exactly x successes" | PMF | P(X = x) | PMF column, row x |
| "at most x" / "x or fewer" | CDF | P(X ≤ x) | CDF column, row x |
| "at least x" / "x or more" | Complement | 1 − P(X ≤ x−1) | 1 − CDF at row (x−1) |
| "between a and b (inclusive)" | Difference | P(X≤b) − P(X≤a−1) | CDF(b) − CDF(a−1) |
| "more than x" / "fewer than x" | Strict Complement | 1 − P(X ≤ x) or P(X ≤ x−1) | Adjust row by ±1 |
Hypergeometric vs Binomial vs Poisson: Decision Guide
Choosing the right distribution is essential. The table below summarizes when each distribution applies. The key question for the hypergeometric is always: Is sampling done without replacement from a finite population?
| Feature | Hypergeometric | Binomial | Poisson |
|---|---|---|---|
| Population | Finite (known N) | Finite or infinite | Infinite / rate-based |
| Sampling method | Without replacement | With replacement | Count-based |
| Trial independence | Dependent | Independent | Independent |
| Success probability | Changes each draw | Constant (p) | Rate λ per interval |
| Example scenario | Card hands, lots inspection | Coin flips, large surveys | Defects per hour, arrivals |
| Approximation rule | Use when n/N > 0.05 | Approximates Hypergeom. when n/N ≤ 0.05 | Approximates Binomial when n large, p small |
Key Rule of Thumb
If the sample size n is more than 5% of the population (n/N > 0.05), use the hypergeometric distribution. If n/N ≤ 0.05, the binomial distribution is a good approximation because drawing without replacement barely changes the remaining population's composition. For example, sampling 50 people from a city of 1,000,000 is essentially sampling with replacement — use binomial. Sampling 5 from a batch of 30 requires the hypergeometric. See Statistics & Probability for more distribution guidance.
Calculating Hypergeometric Probabilities in Software
All major statistical software packages include built-in hypergeometric functions. The example below uses N=20, K=8, n=5, x=2 throughout.
Microsoft Excel / Google Sheets
=HYPGEOM.DIST(2, 5, 8, 20, FALSE)
// CDF: P(X ≤ 2)
=HYPGEOM.DIST(2, 5, 8, 20, TRUE)
// Arguments: (x, sample_s, pop_s, n_pop, cumulative)
// Older Excel: =HYPGEOMDIST(2, 5, 8, 20) — PMF only
Note: Excel argument order is (x, n, K, N) — not the same as the mathematical formula. The 5th argument TRUE gives the CDF; FALSE gives the PMF. Google Sheets uses the same HYPGEOM.DIST syntax.
R
dhyper(x=2, m=8, n=12, k=5)
# CDF: P(X ≤ 2)
phyper(q=2, m=8, n=12, k=5)
# Arguments: m=K, n=N-K, k=sample_size
# Complete distribution table:
data.frame(x=0:5, pmf=dhyper(0:5, 8, 12, 5), cdf=phyper(0:5, 8, 12, 5))
R uses m (successes in population), n (non-successes = N−K), k (sample size). Be careful — R's "n" is not the same as the mathematical formula's n (which is the sample size).
Python (SciPy)
# Parameters: M=N, n=K, N=sample_size
rv = hypergeom(M=20, n=8, N=5)
# PMF: P(X = 2)
rv.pmf(2) # → 0.3973
# CDF: P(X ≤ 2)
rv.cdf(2) # → 0.6987
# Full distribution
import numpy as np
x_vals = np.arange(0, 6)
print(list(zip(x_vals, rv.pmf(x_vals).round(4))))
SciPy's hypergeom uses M=N (population), n=K (successes in population), N=sample_size. The argument naming differs from standard notation — always verify by checking M > n and N ≤ M.
Real-World Applications of the Hypergeometric Distribution
The hypergeometric distribution appears in any situation where a fixed number of items are drawn without replacement from a categorized population. Here are the most common domains.
Quality Control & Manufacturing
Lot acceptance sampling: inspecting a batch of n items from a lot of N to determine whether to accept or reject the lot, knowing that K items are defective. Used widely in ISO standards and acceptance sampling plans (MIL-STD-1916).
Clinical Trials & Healthcare
Randomizing patients into treatment arms without replacement, evaluating genetic marker prevalence in selected subgroups, or assessing adverse event rates in subpopulations. Fisher's exact test for 2×2 contingency tables is directly derived from the hypergeometric distribution.
Ecology & Biological Research
Mark-recapture experiments estimate population size. A researcher marks K animals, releases them, then recaptures n. The number of marked animals in the recapture follows the hypergeometric distribution. This is also the basis for the Lincoln-Petersen population estimator.
Survey Sampling & Social Science
When sampling from small, well-defined populations (a classroom, a department, a committee), the hypergeometric provides exact probabilities. Applies to stratified sampling without replacement, oversampling of minority groups, and committee composition analyses.
Card Games & Combinatorics
Computing exact probabilities in poker (5-card hands from a 52-card deck), bridge, and Magic: The Gathering deck analysis. The hypergeometric is the standard model for calculating hand probabilities in any card game where cards are dealt without replacement.
Auditing & Fraud Detection
Auditors sample financial records from a finite set of transactions. The hypergeometric distribution tells auditors the probability of detecting a given number of errors when sampling without replacement, enabling statistically sound sampling plans under auditing standards such as PCAOB AS 2315.
Common Mistakes When Using the Hypergeometric Distribution
Mistake 1 — Using Binomial When Sampling Is Without Replacement
The most frequent error: applying the binomial formula to a without-replacement scenario. If you draw cards from a deck, inspect items from a finite lot, or sample people from a small group, successive draws are not independent. The hypergeometric is required. Only use binomial when n/N ≤ 0.05 as an approximation.
Mistake 2 — Confusing PMF and CDF
P(X = 2) and P(X ≤ 2) are completely different quantities. The PMF gives the probability of exactly that value; the CDF gives the probability of that value or any smaller value. "At most 2" → CDF. "Exactly 2" → PMF. "At least 2" → 1 − CDF at x=1. Mixing these up leads to answers that are off by a factor of 2–5.
Mistake 3 — Wrong Argument Order in Software
Excel, R, and Python all use different argument orderings for their hypergeometric functions. In Excel: (x, n, K, N). In R: (x, K, N−K, n). In SciPy: (M=N, n=K, N=sample_size). Entering arguments in the wrong order produces silent wrong answers. Always verify with a simple case where you know the result.
Mistake 4 — Requesting Probabilities Outside the Valid Range
If you ask for P(X = 6) when K = 4 (you can't draw more successes than exist in the population), the probability is 0 — but some calculators return errors rather than zero. Always verify x is within max(0, n+K−N) ≤ x ≤ min(n, K). Requests outside this range are physically impossible.
Mistake 5 — Confusing N (population) with n (sample)
The notation N (population size) and n (sample size) are case-sensitive and represent completely different quantities. N is always larger than n. K is always ≤ N. x is always ≤ min(n, K). Swapping N and n in calculations produces completely wrong probabilities and is one of the most common exam errors.
Symbol & Concept Glossary
| Symbol / Term | Full Name | Definition | Range |
|---|---|---|---|
| N | Population Size | Total number of items in the finite population | N ≥ 1 |
| K | Successes in Population | Items of interest or "successes" in the population | 0 ≤ K ≤ N |
| n | Sample Size | Number of items drawn without replacement | 1 ≤ n ≤ N |
| x | Observed Successes | Number of successes in the sample (random variable) | max(0,n+K−N) ≤ x ≤ min(n,K) |
| C(a,b) | Binomial Coefficient | a! / [b!(a−b)!] — number of ways to choose b from a | Integer ≥ 0 |
| PMF | Probability Mass Function | P(X = x) — exact probability of one outcome | 0 ≤ PMF ≤ 1 |
| CDF | Cumulative Distribution Function | P(X ≤ x) — probability of x or fewer successes | 0 ≤ CDF ≤ 1 |
| E(X) | Expected Value | Mean of the distribution: n × (K/N) | [0, min(n,K)] |
| Var(X) | Variance | n×(K/N)×((N−K)/N)×((N−n)/(N−1)) | ≥ 0 |
| FPC | Finite Population Correction | (N−n)/(N−1) — reduces variance vs binomial | (0, 1] |
Frequently Asked Questions
Is the hypergeometric distribution discrete or continuous?
The hypergeometric distribution is discrete. X can only take integer values within its valid range. It belongs to the family of discrete probability distributions alongside the binomial, Poisson, and geometric distributions. This is why it has a PMF (not a PDF, which applies to continuous distributions).
What is Fisher's exact test and how does it relate to the hypergeometric?
Fisher's exact test, developed by Ronald Fisher, uses the hypergeometric distribution to test for independence in a 2×2 contingency table. Given fixed row and column totals, the probability of the observed table (and all more extreme tables) is computed using the hypergeometric PMF. It is the preferred test over chi-square when sample sizes are small or expected cell counts are below 5. See Hypothesis Testing for more on Fisher's exact test.
What is the finite population correction factor?
The finite population correction (FPC) is the factor (N−n)/(N−1) that appears in the hypergeometric variance formula. It quantifies how much the variance is reduced compared to binomial sampling because once an item is drawn, it cannot appear again. As n → N (sampling nearly the whole population), FPC → 0, meaning there is almost no variance — you would know almost exactly how many successes there are. As n/N → 0, FPC → 1, and the hypergeometric variance approaches the binomial variance.
Can the hypergeometric distribution be approximated by the normal distribution?
Yes, for large sample sizes the hypergeometric distribution is approximately normal with mean μ = n(K/N) and standard deviation σ = √[n(K/N)(1−K/N)(N−n)/(N−1)]. This approximation works well when both n(K/N) ≥ 5 and n(1−K/N) ≥ 5. For smaller samples, use the exact hypergeometric table or calculator. The normal distribution approximation can be improved with a continuity correction of ±0.5.
What is the multivariate hypergeometric distribution?
When the population has more than two categories (not just successes and failures), the multivariate hypergeometric distribution generalizes the standard formula. If the population has categories of sizes K₁, K₂, …, Kc (summing to N), the probability of drawing exactly x₁ from category 1, x₂ from category 2, etc., in a sample of n is: P = [C(K₁,x₁) × C(K₂,x₂) × … × C(Kc,xc)] / C(N,n). This arises in race/gender composition analyses, multi-arm clinical trials, and multi-species ecological sampling.
Is the hypergeometric distribution used in genetics?
Yes, extensively. Gene set enrichment analysis (GSEA) uses the hypergeometric distribution to test whether a list of differentially expressed genes is enriched for a particular biological pathway. Given N total genes, K genes in a pathway, a hit list of n genes, and x genes in the intersection, P(X ≥ x) from the hypergeometric distribution gives the p-value for enrichment. Tools like GOstats, clusterProfiler, and GOrilla use this exact calculation. This is one of the most widespread applications of the hypergeometric distribution in modern biology.
Related Statistical Distributions
Binomial Distribution
Models the number of successes in n independent Bernoulli trials with constant probability p. The hypergeometric converges to the binomial as N → ∞ with K/N → p. The binomial distribution is the sampling-with-replacement counterpart.
Negative Hypergeometric Distribution
Describes the number of non-successes encountered before achieving the r-th success in without-replacement sampling. Analogous to the relationship between the binomial and negative binomial distributions. Less commonly tabulated but used in sequential sampling inspection.
Poisson Distribution
When N is large, K is small, n is small, and K/N is small, the hypergeometric can be approximated by the Poisson with λ = nK/N. This is the approximation commonly used in rare-event problems like defect rates in high-volume manufacturing. See our Poisson distribution guide.
References & Further Reading
- NIST/SEMATECH e-Handbook of Statistical Methods. Hypergeometric Distribution. itl.nist.gov
- Walpole, R. E., Myers, R. H., Myers, S. L., & Ye, K. (2012). Probability & Statistics for Engineers and Scientists (9th ed.). Pearson. Chapter 5.
- DeGroot, M. H., & Schervish, M. J. (2012). Probability and Statistics (4th ed.). Pearson. §5.4 The Hypergeometric Distribution.
- Fisher, R. A. (1922). On the interpretation of χ² from contingency tables. Journal of the Royal Statistical Society. JSTOR
- SciPy Documentation. scipy.stats.hypergeom. docs.scipy.org
Why the Hypergeometric Distribution Table Matters
Exact Probabilities Without Approximation
The hypergeometric table gives exact probabilities for any finite sampling problem. Unlike the normal or Poisson approximations, which introduce errors (especially for small samples), the hypergeometric formula is exact. For quality control decisions involving small lot sizes, this precision is not optional — it directly affects accept/reject thresholds.
The Foundation of Fisher's Exact Test
Ronald Fisher's exact test — one of the most widely used tests in medicine, genetics, and social science — is built entirely on the hypergeometric distribution. Every 2×2 contingency table analysis with small expected cell counts relies on the hypergeometric PMF to compute exact p-values. Understanding this table means understanding the mechanics of Fisher's test. See the Fisher's exact test guide for examples.
Correct Model for Real Sampling Situations
Real sampling processes — drawing cards, inspecting items, allocating patients — are almost always done without replacement. Using the binomial distribution for these scenarios is a modeling error that overstates variance and can lead to incorrect conclusions. The hypergeometric distribution is the statistically correct model whenever the sampling fraction n/N exceeds 5%. Learn about study design principles to select the right model every time.