AI Glossary / Statistics and probability / Intermediate

Hypergeometric distribution

Definition

The hypergeometric distribution gives the number of items of a specified type in a fixed-size simple random sample drawn without replacement from a finite population. It assumes the population contains a fixed number of those items and that every subset of the chosen size is equally likely. Success is simply the label for the type being counted, not a judgment about whether the outcome is desirable.

What it means

When items are not replaced, each draw changes what remains available. Selecting one defective item removes a defect from the population, affecting the chance of finding another on the next draw.
The distribution accounts for that dependence. It is useful for audit samples, quality checks, and overlap calculations involving a fixed collection. It describes a sampling process under stated population counts, rather than estimating those counts automatically from an observed sample.

How it works

Let M be the population size, K the number of success items, and n the number drawn. Define X as the number of successes in the sample. All counts are integers, with 0 at most K at most M and 0 at most n at most M.
The probability of exactly k successes is choose(K,k)*choose(M-K,n-k)/choose(M,n). The numerator counts samples containing k success items and n minus k other items. The denominator counts all equally likely samples of size n. Here choose(a,b) is the number of unordered ways to select b objects from a.
The feasible values run from max(0,n-(M-K)) to min(n,K). Outside this range, the probability is zero. Checking these bounds is useful because a sample cannot contain more successes than exist or more items than it contains.
For M greater than zero, the expected count is n*K/M. For M greater than one, its variance is n*(K/M)*(1-K/M)*(M-n)/(M-1). The final factor accounts for sampling without replacement and reduces variability relative to the corresponding independent-draw binomial model.
A census, with n equal to M, has no uncertainty about the success count under the fixed-population model. Degenerate populations and sample sizes should be handled directly rather than mechanically dividing by zero in a formula outside its stated domain.
The binomial distribution instead models a fixed number of independent trials with a constant success probability. It can approximate the hypergeometric when the sampling fraction is sufficiently small for the required accuracy, but the approximation is not automatically adequate for rare tail probabilities.
Calculate at-least probabilities carefully. P(X at least k) equals P(X greater than k minus 1), so the survival-function argument often differs by one from the verbal threshold. For extreme tails, a library's direct survival function can avoid numerical cancellation from subtracting a cumulative probability from one.
Software parameter names vary. SciPy uses population size M, success count n, and draw count N; R uses counts of the two population types and a draw count. Map meanings explicitly rather than copying parameter letters between systems.
If selection probabilities differ across items, the ordinary hypergeometric model generally does not apply. Likewise, clustering, replacement, changing population membership, or uncertainty about the success count can require a different model or an additional inferential layer.

Three practical examples

  • An AI audit estimates the chance that a simple random sample includes at least one of a known set of problematic records.
  • A quality team calculates the distribution of defective items found in a sample from a fixed batch.
  • An analyst evaluates overlap between a selected item set and a fixed reference category under a uniform-selection null model.

Think of it this way

Think of drawing labeled counters from a bag without putting them back. Every counter drawn changes the bag. The hypergeometric distribution counts how many counters of one label appear in your handful, while keeping track of the finite supply.

Worked example

A fixed batch contains 20 records, of which 5 have a specified issue. An auditor selects 4 distinct records uniformly without replacement. There are choose(20,4) = 4,845 possible samples.
Exactly two issue records can be chosen in choose(5,2)*choose(15,2) = 10*105 = 1,050 ways. Therefore P(X = 2) = 1,050/4,845 = 70/323, approximately 0.216718.
The probability of finding at least one issue is 1 - choose(15,4)/choose(20,4) = 1 - 1,365/4,845 = 232/323, approximately 0.718266.
The expected issue count is 4*(5/20) = 1. Its variance is 4*(1/4)*(3/4)*(16/19) = 12/19, approximately 0.631579.
A binomial calculation with four independent trials and success probability 1/4 would give probability 1 - (3/4)^4 = 0.683594 of at least one issue. The discrepancy reflects the different sampling mechanism. These calculations assume the five-issue population count is known; observing no issues would not establish that the batch is issue-free.

Illustrative case study

In this fictional case, Cedar Evaluation maintains a benchmark with known issue-labeled records. Before a random audit, its analyst calculates how often a proposed sample would encounter at least one issue. Management initially uses a replacement-based calculator, then corrects the design to match selection of distinct records. The team also confirms that manual preference for certain record types would invalidate the uniform-sampling assumption behind the calculation.

Common misconceptions and mistakes

Without replacement does not mean independent draws. The hypergeometric distribution is not the negative hypergeometric distribution, which concerns a stopping-rule sampling scheme. A known success proportion does not make the binomial model exact for a finite sample without replacement.
Expected count is not a guaranteed count. A zero observed count does not prove zero population prevalence. The ordinary formula also does not automatically cover biased or unequal-probability sampling.

Business use

Use the distribution to assess finite-population sampling plans when the selection mechanism and population composition are specified. Report the sample size, population size, success definition, and replacement rule. If the population issue count is unknown, separate the forward probability calculation from the estimation or uncertainty analysis needed to learn that count.

People also ask

Can success mean an error?

Yes; it is just the category being counted.

Why is variance smaller than the matching binomial variance?

Sampling without replacement constrains the remaining composition.

Does the order of draws matter for the final count?

Not for this distribution under simple random sampling.

Check your understanding

What is the maximum issue count in the example?

Answer: Four, because only four records are sampled.

Why is the probability of at least one not four times one-quarter?

Answer: Events across draws overlap, and drawing without replacement changes subsequent probabilities.

Related terms

  • Simple Random Sampling
  • Binomial distribution
  • Fisher exact test
  • finite population correction
  • sampling without replacement
  • negative hypergeometric distribution

Learn next

Learn combinations and sampling designs. Then study finite-population inference and how hypergeometric probabilities underpin conditional tests for contingency tables.

More in Statistics and probability

  • Huber regression - Huber regression fits a regression model using a loss that is quadratic for small residuals and linear for sufficiently large residuals.
  • Hurdle model - A hurdle model describes an outcome using one component for whether it is zero or positive and another for its size once it is positive.
  • Hybrid Bayesian network - A hybrid Bayesian network is a Bayesian network containing both discrete and continuous random variables.
  • Hyperprior - A hyperprior is a prior distribution placed on a parameter that controls another prior distribution.
  • Hypertabastic survival models - Hypertabastic survival models are parametric time-to-event models built from the hypertabastic probability distribution introduced by Tabatabai and...
  • Hypothesis - A hypothesis is a candidate claim, explanation, or model considered in relation to evidence.

Sources

SciPy, scipy.stats.hypergeom: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.hypergeom.html R stats, The Hypergeometric Distribution: https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Hypergeometric.html

Previous: Hyperdimensional computing Next: Hyperjacking

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer