How Hypergeometric Distribution Calculator Works?
The Hypergeometric Distribution Calculator reads 4 numbers (N, K, n and k), builds the full probability distribution of X, and returns exact probabilities, cumulative tails, summary statistics, charts and a simulation. Every result updates as you type, and the URL stays clean.
- Enter 4 inputsPopulation size N, successes in the population K, sample size n and observed successes k.
- Check the rangeX runs from max(0, n + K − N) to min(n, K). Inputs outside the range show a warning.
- Compute the PMFP(X = x) for every x, using log-gamma binomial coefficients and exact ratios.
- Add up the tailsP(X < k), P(X ≤ k), P(X > k) and P(X ≥ k) from the PMF values.
- Show the resultsResult card, statistics, PMF and CDF charts, urn simulation, worked formula and table.
Inputs
- Population size (N): the total number of items, for example 52 cards, 60 Magic: The Gathering cards or 20,000 genes.
- Successes in population (K): the items that count as a success, for example 13 hearts, 24 lands or 200 pathway genes.
- Sample size (n): the number of items drawn without replacement, for example a 5-card hand.
- Successes in sample (k): the count you want the probability for, for example 2 hearts.
Outputs
- Exact probability P(X = k), shown as a decimal, a percentage and odds ("1 in 3.6").
- Cumulative probabilities P(X < k), P(X ≤ k), P(X > k) and P(X ≥ k), from the cumulative distribution function (CDF).
- Summary statistics: mean, variance, standard deviation, mode, skewness and the support of X.
- Charts: a probability mass function (PMF) bar chart and a CDF step chart, with the selected tail shaded.
- Simulation: 2,000 random draws from the urn, compared with the exact PMF.
- Table: every value of x with P(X = x), P(X ≤ x) and P(X ≥ x), downloadable as CSV.
Exactness
The calculator computes probabilities with natural-log binomial coefficients and multiplies neighbouring terms by exact ratios, so C(1,000,000, 500) never overflows and a tail probability of 10−40 keeps its significant digits. Results match R dhyper(), SciPy hypergeom.pmf() and Excel HYPGEOM.DIST() for populations up to 1,000,000 items.
What is hypergeometric distribution?
The hypergeometric distribution is a discrete probability distribution that gives the probability of exactly k successes in n draws, without replacement, from a finite population of N items that holds K successes.
Each draw changes the population. The first card is a heart with probability 13/52 = 0.25. After one heart leaves the deck, the next card is a heart with probability 12/51 = 0.2353. Draws are dependent, and the hypergeometric distribution models this dependence exactly.
| Symbol | Meaning | Card example |
|---|---|---|
| N | Population size | 52 cards |
| K | Successes in the population | 13 hearts |
| n | Sample size (draws) | 5 cards |
| k | Successes in the sample | 2 hearts |
The random variable X ~ Hypergeometric(N, K, n) counts successes in the sample. Its probability mass function (PMF) is a ratio of binomial coefficients, its mean is n · K / N and its variance carries a finite population correction (FPC) of (N − n)/(N − 1). The name comes from the probability generating function, which is a Gaussian hypergeometric series.
Real uses include:
- Card games: poker hands, Magic: The Gathering opening hands and Yu-Gi-Oh! starter odds.
- Quality control: acceptance sampling of a lot, as in the National Institute of Standards and Technology (NIST) Engineering Statistics Handbook.
- Bioinformatics: gene set enrichment and Gene Ontology (GO) term over-representation tests.
- Lotteries: matching 3 of 6 numbers in a 6/49 lottery, with probability 0.017650.
- Ecology: capture–recapture estimates of animal populations.
When to use hypergeometric distribution?
Use the hypergeometric distribution when you draw a fixed number of items without replacement from a finite population and count items of one type. All 4 conditions below must hold.
- Is the population finite, with a known size N?Yes ↓No → Binomial or Poisson distribution
- Does each item fall into exactly 2 groups (success or failure)?Yes ↓No → Multivariate hypergeometric
- Is the number of draws n fixed in advance?Yes ↓No → Negative hypergeometric
- Are draws made without replacement?Yes ↓No → Binomial distribution
Hypergeometric vs binomial distribution
| Feature | Hypergeometric | Binomial |
|---|---|---|
| Sampling | Without replacement | With replacement, or infinite population |
| Draws | Dependent | Independent Bernoulli trials (Jacob Bernoulli) |
| Success probability | Changes after each draw | Constant p |
| Parameters | N, K, n | n, p |
| Variance | n·p·(1 − p)·(N − n)/(N − 1) | n·p·(1 − p) |
| P(2 hearts in 5 cards) | 0.274280 | 0.263672 (p = 0.25) |
The binomial distribution is a close approximation when the sample is at most 5% of the population (n ≤ 0.05 N). A 5-card hand is 9.6% of a 52-card deck, so the binomial answer misses by 0.0106. Sampling 100 genes from 20,000 is 0.5% of the population, and P(X ≥ 5) differs by 0.0001 (0.00332 vs 0.00343).
Pick a specialised calculator when the question changes shape:
- Count draws until the first success: negative hypergeometric distribution calculator (without replacement) or geometric distribution calculator (with replacement).
- Track 3 or more categories: multivariate hypergeometric distribution calculator.
- Plan an inspection sample: hypergeometric distribution sample size calculator.
- Build a deck: hypergeometric distribution calculator MTG or hypergeometric distribution calculator Yugioh.
Hypergeometric distribution formula
The hypergeometric distribution formula is P(X = k) = C(K, k) · C(N − K, n − k) / C(N, n): the number of favourable samples divided by the number of possible samples.
- C(K, k)Ways to choose k successes from the K successes in the population
- C(N − K, n − k)Ways to choose the remaining n − k items from the N − K failures
- C(N, n)Ways to choose any n items from all N items
C(a, b) is the binomial coefficient "a choose b", written nCr on calculators. For the card example, C(13, 2) = 78, C(39, 3) = 9,139 and C(52, 5) = 2,598,960.
Related formulas
| Quantity | Formula | N = 52, K = 13, n = 5 |
|---|---|---|
| Cumulative distribution function (CDF) | P(X ≤ k) = Σi ≤ k P(X = i) | P(X ≤ 2) = 0.907233 |
| Upper tail | P(X ≥ k) = 1 − P(X ≤ k − 1) | P(X ≥ 2) = 0.367047 |
| Mean (μ) | n · K / N | 1.25 |
| Variance (σ²) | n · (K/N) · (1 − K/N) · (N − n)/(N − 1) | 0.8640 |
| Standard deviation (σ) | √σ² | 0.9295 |
| Finite population correction (FPC) | (N − n)/(N − 1) | 0.9216 |
| Support | max(0, n + K − N) ≤ k ≤ min(n, K) | 0 to 5 |
The FPC shrinks the binomial variance. The binomial standard deviation for 5 cards is 0.9682; the hypergeometric value is 0.9295, 4% lower. Use the standard deviation of hypergeometric distribution calculator to see the FPC for any sample.
How to calculate hypergeometric distribution?
To calculate a hypergeometric probability, find N, K, n and k, compute the 3 binomial coefficients, multiply the 2 numerator terms and divide by C(N, n). For a cumulative probability, repeat the calculation for every k in the tail and add the results.
Worked example: 2 hearts in a 5-card hand
- Identify the parameters: N = 52 cards, K = 13 hearts, n = 5 cards, k = 2 hearts.
- Count success combinations: C(13, 2) = 13 · 12 / 2 = 78.
- Count failure combinations: C(39, 3) = 39 · 38 · 37 / 6 = 9,139.
- Multiply the counts: 78 × 9,139 = 712,842 favourable hands.
- Divide by all hands: 712,842 / 2,598,960 = 0.274280, or 27.43%, about 1 in 3.6 hands.
Cumulative example: at least 2 hearts
P(X ≥ 2) adds the bars for x = 2, 3, 4 and 5: 0.2743 + 0.0815 + 0.0107 + 0.0005 = 0.367047. The shorter route is 1 − P(X ≤ 1) = 1 − (0.2215 + 0.4114).
Common mistakes
- Swapping K and n: K counts successes in the population; n counts draws.
- Using the binomial formula: 0.263672 instead of 0.274280 for the card example.
- Mixing up "at least" and "more than": P(X ≥ 2) includes 2; P(X > 2) starts at 3.
- Ignoring the support: k above min(n, K) has probability 0.
The hypergeometric distribution calculator with steps prints every line of this working for your own numbers.
How to do hypergeometric distribution on calculator?
To do a hypergeometric distribution on a scientific or graphing calculator, type the formula with the nCr (combinations) key: K nCr k × (N − K) nCr (n − k) ÷ N nCr n.
| Calculator | nCr location | Built-in hypergeometric? |
|---|---|---|
| TI-84 Plus, TI-83 Plus | MATH → PRB → 3:nCr | No |
| TI-Nspire CX | menu → Probability → Combinations | No |
| Casio fx-991EX, fx-570 | SHIFT + ÷ (nCr) | No |
| Casio fx-CG50 | OPTN → PROB → nCr | No |
| HP Prime | Toolbox → Math → Probability → COMB | No |
| This online calculator | Not needed | Yes, all tails |
Handheld calculators overflow above C(N, n) ≈ 10100, for example C(1000, 100). Divide the terms in pairs, or use this online calculator, which works in logarithms. Round only the final answer.
Hypergeometric distribution calculator TI 84
No, the TI-84 Plus has no built-in hypergeometric function. Compute P(X = k) with nCr, and compute cumulative probabilities with sum(seq(.
Exact probability P(X = k)
- Press (, type 13, then open the nCr menu.
- Type 2, close the bracket, and repeat for 39 nCr 3.
- Press ÷, type 52 nCr 5, and press ENTER.
Cumulative probability P(X ≤ k)
The seq( command builds the list of PMF values for X = 0 to 2, and sum( adds the list. Find sum( under 2nd STAT → MATH → 5, and seq( under 2nd STAT → OPS → 5.
Full table with Y=
- Press Y= and enter
Y1=(13 nCr X)(39 nCr (5−X))/(52 nCr 5). - Press 2nd WINDOW (TBLSET) and set TblStart = 0 and ΔTbl = 1.
- Press 2nd GRAPH (TABLE) to read P(X = 0) to P(X = 5).
The TI-84 Plus CE shows 10 digits and returns ERR:OVERFLOW above 10100. For a 60-card deck or a 20,000-gene list, use the online calculator above.
Hypergeometric distribution calculator Excel
Microsoft Excel calculates the hypergeometric distribution with =HYPGEOM.DIST(sample_s, number_sample, population_s, number_pop, cumulative). Set cumulative to FALSE for P(X = k) and TRUE for P(X ≤ k).
| A | B | |
|---|---|---|
| 1 | Population size (N) | 52 |
| 2 | Successes in population (K) | 13 |
| 3 | Sample size (n) | 5 |
| 4 | Successes in sample (k) | 2 |
| 5 | P(X = k) | 0.274279712 |
| 6 | P(X ≤ k) =HYPGEOM.DIST(B4,B3,B2,B1,TRUE) | 0.907232893 |
| 7 | P(X ≥ k) =1-HYPGEOM.DIST(B4-1,B3,B2,B1,TRUE) | 0.367046819 |
| Argument | Symbol | Example |
|---|---|---|
| sample_s | k | 2 |
| number_sample | n | 5 |
| population_s | K | 13 |
| number_pop | N | 52 |
| cumulative | — | FALSE (PMF) or TRUE (CDF) |
- At least k:
=1-HYPGEOM.DIST(k-1, n, K, N, TRUE). - More than k:
=1-HYPGEOM.DIST(k, n, K, N, TRUE). - Between a and b:
=HYPGEOM.DIST(b, n, K, N, TRUE)-HYPGEOM.DIST(a-1, n, K, N, TRUE). - Excel 2007 and Google Sheets:
=HYPGEOMDIST(2, 5, 13, 52)returns P(X = k) only, with 4 arguments.
Excel returns #NUM! when k exceeds n or K, or when n exceeds N. The argument order runs from sample to population, the reverse of the N, K, n order on this page.
R, Python and MATLAB
# R
dhyper(2, 13, 39, 5) # 0.2742797 (x, K, N - K, n)
phyper(2, 13, 39, 5) # 0.9072329
# Python (SciPy)
from scipy.stats import hypergeom
hypergeom.pmf(2, 52, 13, 5) # 0.2742797 (k, N, K, n)
hypergeom.sf(1, 52, 13, 5) # 0.3670468 P(X >= 2)
% MATLAB (Statistics and Machine Learning Toolbox)
hygepdf(2, 52, 13, 5) % 0.2742797 (x, N, K, n)
hygecdf(2, 52, 13, 5) % 0.9072329Hypergeometric distribution calculator FAQ
How to do hypergeometric distribution on calculator?
To do a hypergeometric distribution on a calculator, type C(K, k) × C(N − K, n − k) ÷ C(N, n) using the nCr key. For 2 hearts in a 5-card hand, enter 13 nCr 2 × 39 nCr 3 ÷ 52 nCr 5 and the display shows 0.2742797119.
On a TI-84 Plus the nCr key sits under MATH → PRB → 3:nCr. Cumulative probabilities need one term per value of k, added together, or the sum(seq( command on the TI-84.
How do you calculate the hypergeometric distribution?
You calculate the hypergeometric distribution in 5 steps: identify N, K, n and k, compute C(K, k), compute C(N − K, n − k), multiply the two results, and divide by C(N, n).
Drawing 2 hearts in 5 cards from a 52-card deck gives 78 × 9,139 = 712,842 favourable hands out of 2,598,960 possible hands, so P(X = 2) = 0.274280.
What is a hypergeometric calculator?
A hypergeometric calculator is a statistical calculator that computes exact probabilities for sampling without replacement from a finite population. It takes 4 inputs (population size N, successes in the population K, sample size n and successes in the sample k) and returns P(X = k), the cumulative probabilities P(X ≤ k) and P(X ≥ k), and the mean, variance and standard deviation.
This hypergeometric distribution calculator adds a probability mass function (PMF) chart, a cumulative distribution function (CDF) chart, a 2,000-draw simulation, the worked formula and a downloadable probability table.
How is the p-value calculated in a hypergeometric test?
The p-value of a one-sided hypergeometric test is the upper-tail probability P(X ≥ k): the sum of P(X = i) for every i from the observed k up to min(n, K).
In a gene set enrichment analysis with 20,000 genes, 200 pathway genes and 100 selected genes, an observed overlap of 5 genes (1 expected) gives p = P(X ≥ 5) = 0.00332. The one-sided Fisher's exact test, described by Ronald A. Fisher, returns the same value for the matching 2 × 2 table. The American Statistical Association (ASA) 2016 statement on p-values notes that a p-value does not measure the probability that a hypothesis is true.
What is the difference between hypergeometric and binomial distribution?
The hypergeometric distribution draws without replacement from a finite population, and the binomial distribution draws with replacement (or from an infinite population) with a constant success probability p. Hypergeometric draws are dependent; binomial trials, named after Jacob Bernoulli's independent Bernoulli trials, are independent.
The binomial distribution approximates the hypergeometric distribution well when the sample is at most 5% of the population (n ≤ 0.05 N).
What are the mean and variance of the hypergeometric distribution?
The mean of the hypergeometric distribution is μ = n · K / N, and the variance is σ² = n · (K/N) · (1 − K/N) · (N − n)/(N − 1). The factor (N − n)/(N − 1) is the finite population correction (FPC).
For 5 cards from a 52-card deck counting hearts, μ = 1.25, σ² = 0.8640 and the standard deviation σ = 0.9295.
Is the hypergeometric distribution discrete or continuous?
The hypergeometric distribution is discrete. The random variable X counts successes, so X takes only whole-number values from max(0, n + K − N) to min(n, K).
Can this hypergeometric distribution calculator handle large populations?
Yes, the calculator handles populations of up to 1,000,000 items. It computes probabilities with log-gamma functions and exact probability ratios, so huge binomial coefficients never overflow and tiny tail probabilities keep their precision.