The hypergeometric distribution is a discrete probability distribution for the number of items of a specified type in a fixed-size sample drawn without replacement from a finite population. If a population contains items, of which are classified as successes, and every sample of distinct items is equally likely, then the number of sampled successes has a hypergeometric distribution. Unlike the binomial distribution, it accounts for the dependence introduced when sampled items are not returned to the population.
Definition and probability mass function
Let:
- be the total population size, with ;
- be the number of successes in the population, with ;
- be the sample size, with ;
- be the number of successes in the sample.
All three parameters are integers. One common notation is
although the order and names of parameters vary among textbooks and software packages.
The probability mass function is
for integer values satisfying
It is zero otherwise.
The binomial coefficient counts the ways to choose items from distinct items. There are possible unordered samples. A sample with exactly successes consists of a choice of items from the successes and items from the failures, giving the numerator.
The lower support bound matters when the sample is too large to consist entirely of failures. For example, if only three failures exist and five items are sampled, at least two successes must be observed.
Normalization follows from Vandermonde’s identity:
where the sum extends over the admissible values of .
Sampling assumptions
The defining condition is that all subsets of size are equally likely. This is the usual model of simple random sampling without replacement.
The population labels may be fixed rather than random: randomness in the sample selection alone produces the distribution. “Success” is simply a category label and need not denote a desirable outcome.
Sampling without replacement is not, by itself, sufficient to justify a hypergeometric model. If some items are more likely to be selected than others, or items are selected together in clusters, the ordinary hypergeometric distribution generally does not apply.
Example
Suppose a shipment contains 20 components, including 7 defective components. Five components are selected uniformly without replacement. If counts the defective components selected, then
The probability of selecting exactly two defective components is
The probability of finding at least one defective component is most easily calculated by taking the complement:
A binomial model with success probability would not be exact here: removing a defective component changes the composition of the remaining shipment.
Mean, variance, and dependence
Write . The expected value is
For , the variance is
The factor
is the finite-population correction to the binomial variance. It is close to 1 when the sample is small relative to the population, and becomes 0 when the entire population is sampled.
If , the sample contains exactly successes, so with probability 1. Other degenerate cases include , , and . When , the distribution is also degenerate for every permitted sample size; the variance is zero rather than the undefined value suggested by directly substituting into the formula.
Why the variance is smaller than the binomial variance
Imagine drawing the sample sequentially. Let equal 1 if the -th draw is a success and 0 otherwise. Then
Each indicator has a Bernoulli distribution with success probability , but the indicators do not have statistical independence. For distinct draws and ,
and their covariance is
A success on one draw reduces the proportion of successes remaining. Summing the individual variances and pairwise covariances gives the hypergeometric variance.
For , the sample proportion is an unbiased estimator of the population proportion , with
This expression describes uncertainty due to the sampling design, with the finite population held fixed.
Distribution function and symmetries
Let
The cumulative distribution function is
with for and for .
Several transformations are useful:
Exchange success and failure labels. If , then
Count successes outside the sample.
Interchange and . The distributions
are identical.
The last identity follows from viewing as the size of the intersection between a fixed subset and a uniformly selected subset.
Relationships and approximations
Conditional binomial representation
Let
be independent, with . The conditional distribution of given is
Conditioning fixes the total number of successes among all positions. The common success probability cancels from the conditional probability.
Binomial approximation
When the sample is a small fraction of the population, removing an item changes the success proportion only slightly. Consequently,
More formally, for fixed , if tends to infinity and , the hypergeometric distribution converges to .
There is no universal sampling-fraction threshold guaranteeing adequate accuracy for every purpose. Tail probabilities can require greater accuracy than probabilities near the center. The variance ratio
shows how strongly the binomial approximation neglects finite-population effects.
Normal approximation
When the distribution is sufficiently spread out and not strongly affected by its support boundaries, a normal distribution can approximate it:
where
A continuity correction gives, for integer ,
where is the standard normal distribution function.
The expected counts of successes and failures in both the sampled and unsampled portions help indicate whether this approximation is reasonable. Large sample size alone does not suffice if the distribution remains concentrated near a boundary.
Poisson approximation
In a rare-success regime, a Poisson distribution may be appropriate. One sufficient asymptotic setting is
Then the limiting distribution is . The negligible sampling fraction is important: rarity alone does not remove the effects of sampling without replacement.
Applications in statistical inference
Fisher’s exact test
The hypergeometric distribution is the basis of Fisher’s exact test for a contingency table. Consider
| Success | Failure | Total | |
|---|---|---|---|
| Group 1 | |||
| Group 2 | |||
| Total |
Under the null hypothesis of no association, conditioning on the margins gives a hypergeometric distribution for the upper-left cell.
A one-sided p-value is obtained by summing probabilities in the relevant tail. Two-sided exact p-values require a definition of which tables count as at least as extreme as the observed table. Different conventions can give different results because the distribution is discrete; simply doubling a one-sided probability is not universally equivalent to a probability-ordering calculation.
Acceptance sampling and finite-population inference
In acceptance sampling, a lot of items containing defective items is accepted if a sample contains at most defectives. Its acceptance probability is
When is unknown, the same probability model supplies a likelihood function for , with and fixed. Inverting exact tests can produce a confidence interval for the population count or proportion. Because the parameter and observations are discrete, nonrandomized exact procedures may have coverage exceeding their nominal level.
Overlap and enrichment analysis
Suppose a universe contains elements, a designated category contains , and a selected set contains . Under a null model in which the selected set is uniform among all size- subsets, its overlap with the category is hypergeometric.
Upper-tail probabilities are used to assess overrepresentation, including in analyses of gene-expression results. Interpretation depends on the chosen universe and on whether the selection mechanism supports the uniform-subset null model. Testing many categories also introduces a multiple testing problem.
Extensions and related distributions
Multivariate hypergeometric distribution
If the population is partitioned into categories with sizes , where , the sampled category counts follow a multivariate hypergeometric distribution:
subject to and . The ordinary hypergeometric distribution is the two-category case.
Negative hypergeometric distribution
The negative hypergeometric distribution arises when sampling without replacement continues until a specified number of successes or failures has been observed. Its random variable usually counts draws, or opposite-category outcomes, before stopping. This differs from the fixed sample size of the ordinary hypergeometric model.
Noncentral hypergeometric distributions
Noncentral hypergeometric distributions model certain forms of unequal selection between categories. Fisher’s and Wallenius’ versions describe different mechanisms: the former arises through conditioning independent binomial counts with unequal odds, while the latter arises from sequential weighted sampling without replacement. They coincide with the ordinary hypergeometric distribution when the category weights are equal, but are not generally interchangeable otherwise.
Numerical computation
Direct evaluation using factorials can overflow even when the final probability is moderate. Implementations commonly use logarithms of binomial coefficients, specialized probability algorithms, or a recurrence relation between neighboring probabilities:
whenever both values lie in the support.
This ratio also explains the distribution’s name: its successive probability terms have a rational ratio in the index, connecting them with hypergeometric series.
For numerical stability, algorithms can start near the mode and generate probabilities outward before normalization. Very small upper-tail probabilities are preferably evaluated directly rather than by subtracting a cumulative probability close to 1, which can lose significant digits.