Hypergeometric Distribution Calculator

Compute exact probabilities for sampling without replacement from a finite population. Get PMF, CDF, survival function, expected value, variance, and standard deviation. Visualize the distribution with an interactive bar chart.

Presets:
♠ Poker
✓ Quality
? Ecology
? Lottery
? Capture
Presets:
? Defect Sampling
? Medical Test
?️ Election Poll
Standard mode: Enter N, K, n, k directly.
Privacy first: All computations run locally in your browser. No data is sent to any server. The chart is drawn using Canvas – your inputs never leave your device.

Understanding the Hypergeometric Distribution

The hypergeometric distribution models the number of successes in a sample drawn without replacement from a finite population. Unlike the binomial distribution (which assumes independent trials with constant probability), the hypergeometric distribution accounts for the changing composition of the population as sampling progresses. This makes it the correct model for applications ranging from quality control and ecological mark‑recapture to poker odds and lottery analysis.

If a population of size N contains K successes, and we draw a sample of size n without replacement, the probability of observing exactly k successes is:

P(X = k) = C(K, k) · C(N − K, n − k) / C(N, n)

where C(a, b) denotes the binomial coefficient “a choose b”.

When to Use the Hypergeometric Distribution

  • Sampling without replacement – Every draw changes the population composition, making trials dependent.
  • Finite population – The population size N is known and fixed, not infinite.
  • Binary outcomes – Each item in the population is classified as either a “success” or “failure”.
  • Fixed sample size – The number of draws n is predetermined.

Common applications include acceptance sampling (inspecting a batch of products), capture‑recapture (estimating wildlife populations), card games (probabilities of specific hands), and auditing (selecting invoices for review). The hypergeometric distribution is also foundational in Fisher's exact test, used to assess associations in 2×2 contingency tables.

Key Properties and Formulas

For a hypergeometric random variable X with parameters (N, K, n), the following properties hold:

  • Support: k ranges from max(0, n − (N − K)) to min(n, K).
  • Expected value: E[X] = n · K / N
  • Variance: Var(X) = n · (K/N) · (1 − K/N) · (N − n) / (N − 1)
  • Standard deviation: σ = √Var(X)
  • Finite population correction (FPC): (N − n) / (N − 1) – the factor that reduces variance compared to binomial sampling with replacement.

As N grows large relative to n, the hypergeometric distribution converges to the binomial distribution with p = K/N. The finite population correction factor approaches 1, and the dependence between draws becomes negligible. This is a key insight: the hypergeometric distribution is the “exact” finite‑population version of the binomial.

Step‑by‑Step Calculation

  1. Verify parameters: Ensure 0 ≤ K ≤ N, 0 ≤ n ≤ N, and 0 ≤ k ≤ min(K, n).
  2. Compute binomial coefficients: Calculate C(K, k), C(N−K, n−k), and C(N, n).
  3. Apply the PMF formula: P(X = k) = C(K,k)·C(N−K, n−k) / C(N, n).
  4. Calculate cumulative probabilities: P(X ≤ k) = Σi=0k P(X = i).
  5. Compute survival: P(X ≥ k) = 1 − P(X ≤ k−1).
  6. Derive moments: Use the formulas for mean, variance, and standard deviation.

Our calculator performs all these steps instantly. The interactive bar chart displays the full PMF, highlighting the selected k and showing the cumulative distribution as an optional overlay.

Comparison with the Binomial Distribution

Feature Hypergeometric Binomial
Sampling method Without replacement With replacement (or infinite population)
Trial independence Dependent Independent
Population size Finite (N) Infinite (or effectively infinite)
Probability changes Changes after each draw Constant (p)
Variance n·p·(1−p)·(N−n)/(N−1) n·p·(1−p)
Convergence → Binomial as N → ∞

The key practical takeaway: if your sample size is more than 5% of the population, the hypergeometric distribution gives noticeably different results than the binomial. Use this calculator to get the exact probabilities for your finite‑population sampling problems.

Case Study: Quality Control in Manufacturing

A factory produces batches of 200 circuit boards. Historically, 8% of boards are defective. Before shipping, a quality inspector randomly selects 15 boards for testing. What is the probability that the sample contains exactly 2 defective boards? Using the hypergeometric model with N = 200, K = 16 (8% of 200), n = 15, and k = 2, we compute:

  • P(X = 2) ≈ 0.287 (28.7%) – the most likely outcome.
  • P(X ≤ 2) ≈ 0.714 (71.4%) – the chance of finding 2 or fewer defectives.
  • P(X ≥ 2) ≈ 0.573 (57.3%) – the chance of finding 2 or more.

The expected number of defectives in the sample is 15·16/200 = 1.2, with a standard deviation of about 1.02. If the inspector finds 5 or more defectives (P(X ≥ 5) ≈ 0.012), that would be a statistically unusual event (p < 0.05), potentially triggering a full batch inspection. This kind of analysis is standard in statistical process control and acceptance sampling (e.g., ANSI/ASQ Z1.4 standards).

Real‑World Applications Across Disciplines

  • Ecology & Conservation: Mark‑recapture methods (Lincoln‑Petersen index) use the hypergeometric distribution to estimate population sizes from capture data.
  • Card Games & Gambling: Calculate the odds of drawing specific poker hands, bridge hands, or lottery combinations.
  • Public Health: Estimate the probability of observing a certain number of cases in a sample from a finite population during disease outbreaks.
  • Auditing & Finance: Select a random sample of transactions for fraud detection; the hypergeometric model helps determine the risk of missing fraudulent items.
  • Machine Learning: In evaluation metrics like precision and recall for imbalanced datasets, the hypergeometric distribution can model the probability of a certain number of true positives in a random sample.

Common Misconceptions and Pitfalls

  • “The binomial is always a good approximation.” – Not when the sample size exceeds 5–10% of the population. The hypergeometric distribution corrects for the finite population effect.
  • “The order of draws matters.” – The hypergeometric distribution counts combinations, not permutations. The probability depends only on the total number of successes in the sample, not the sequence.
  • “K and N must be integers.” – Yes, they represent counts of discrete items. For proportions, multiply by N to get integer counts.
  • “The distribution is symmetric.” – Only when K = N/2 and n = N/2. In general, the hypergeometric distribution is skewed.

Theoretical Foundations and History

The hypergeometric distribution has roots in the work of Abraham de Moivre (18th century) and Karl Pearson (early 20th century), who developed it in the context of contingency tables and goodness‑of‑fit tests. It is a cornerstone of Fisher's exact test, which R.A. Fisher introduced in 1922 as a non‑parametric method for analyzing 2×2 tables. The distribution also appears in Wallenius' non‑central hypergeometric distribution (extensions for biased sampling) and in the study of capture‑recapture models. Today, it remains essential in biostatistics, ecology, and industrial quality control.

The relationship between the hypergeometric and binomial distributions is a classic example of the Poisson approximation (when N is large, n is small, and K/N is small). However, our calculator always computes the exact finite‑population probabilities, eliminating the need for approximations.

Frequently Asked Questions

The binomial distribution assumes independent trials with a constant success probability (sampling with replacement or from an infinite population). The hypergeometric distribution assumes dependent trials (sampling without replacement from a finite population), so the success probability changes after each draw. The hypergeometric is the correct model when the population is finite and sample size is not negligible relative to the population.

You need: (1) a finite population of size N, (2) exactly K successes and N−K failures, (3) a sample of size n drawn without replacement, and (4) the random variable X counts the number of successes in the sample. All parameters must be non‑negative integers with K ≤ N, n ≤ N, and k ≤ min(K, n).

Use the binomial approximation when the population is very large relative to the sample (n/N ≤ 0.05) or when sampling is done with replacement. For n/N > 0.05, the finite population correction matters, and the hypergeometric distribution gives noticeably different (and more accurate) probabilities.

The calculator uses double‑precision floating‑point arithmetic for binomial coefficients, with robust handling of large numbers. Results are accurate to at least 10–12 decimal places for moderate N (up to ~1000). For very large N (millions), the calculator uses logarithmic gamma functions internally to maintain numerical stability.

Yes! In mark‑recapture studies, the hypergeometric distribution models the number of marked individuals recaptured. Given N (population estimate), K (number marked), n (sample size), and k (recaptured), you can compute probabilities and estimate N using methods like the Lincoln‑Petersen estimator. This calculator provides the probability side of the analysis.

The FPC is (N − n) / (N − 1), a factor that multiplies the binomial variance to obtain the hypergeometric variance. It accounts for the reduction in variability when sampling without replacement from a finite population. When n = 1, the FPC is 1; when n = N (sampling the entire population), the FPC is 0 (zero variance).
References: MathWorld: Hypergeometric Distribution; Wikipedia: Hypergeometric Distribution; Johnson, N.L., Kemp, A.W., & Kotz, S. (2005). Univariate Discrete Distributions, Wiley.