HomeStatistics & Probability › Hypergeometric Distribution Calculator

Hypergeometric Distribution Calculator

Computes the probability of exactly, at most, at least, fewer than or more than k successes in n draws without replacement from a population of N items containing K successes, plus the mean, variance and standard deviation.

When to use

Items are drawn without replacement from a finite population (cards from a deck, defective units in a sampled lot, lottery numbers, capture–recapture) and you need the probability of a given number of successes.

Do not use when: Draws are with replacement or the population is effectively infinite (use binomial-distribution), or you want lottery prize-tier odds directly (use lottery-odds).

Formula

P(X = k) = C(K, k) · C(N − K, n − k) / C(N, n) for max(0, n − N + K) ≤ k ≤ min(n, K); mean = n·K/N; variance = n·(K/N)·(1 − K/N)·(N − n)/(N − 1)

Binomial coefficients are evaluated in log space with the log-gamma function, so large populations do not overflow; results are exact to the displayed precision.

Inputs

ParameterTypeUnitRequiredDescription
population_sizeintegeryesTotal number of items. Range: ≥ 1, ≤ 10000000
successes_in_populationintegeryesNumber of items in the population that count as successes (0 ≤ K ≤ N). Range: ≥ 0
drawsintegeryesNumber of items drawn without replacement (1 ≤ n ≤ N). Range: ≥ 1, ≤ 100000
successes_in_sampleintegeryesNumber of successes among the draws whose probability you want (0 ≤ k ≤ n). Range: ≥ 0

Outputs

OutputTypeUnitDescription
probability_exactnumberProbability of exactly k successes.
probability_at_mostnumberProbability of k or fewer successes.
probability_at_leastnumberProbability of k or more successes.
probability_less_thannumberProbability of fewer than k successes.
probability_more_thannumberProbability of more than k successes.
meannumbern·K/N.
variancenumbern·(K/N)·(1 − K/N)·(N − n)/(N − 1).
std_devnumber√variance.

Example

Exactly 2 aces in a 5-card poker hand: {"population_size":52,"successes_in_population":4,"draws":5,"successes_in_sample":2}{"probability_exact":0.03993,"probability_at_most":0.998246,"probability_at_least":0.041684,"probability_less_than":0.958316,"probability_more_than":0.001754,"mean":0.3846,"variance":0.3272,"std_dev":0.572}

4 green marbles in 10 draws from 50 marbles with 5 green (Wikipedia example): {"population_size":50,"successes_in_population":5,"draws":10,"successes_in_sample":4}{"probability_exact":0.003965,"probability_at_least":0.004083,"mean":1,"variance":0.7347}

GET https://tttkmbb.com/api/v1/calculate/hypergeometric-distribution?population_size=52&successes_in_population=4&draws=5&successes_in_sample=2

Machine access

Sources

FAQ

How does this differ from the binomial distribution?

The binomial assumes a constant success probability (sampling with replacement); the hypergeometric accounts for each draw changing the remaining population. They converge when n is small relative to N (below about 5 %).

What if k is impossible?

Values of k outside max(0, n − (N − K)) … min(n, K) have probability 0; the cumulative probabilities are still returned.

Related calculators