Home › Statistics & 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
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
population_size | integer | yes | Total number of items. Range: ≥ 1, ≤ 10000000 | |
successes_in_population | integer | yes | Number of items in the population that count as successes (0 ≤ K ≤ N). Range: ≥ 0 | |
draws | integer | yes | Number of items drawn without replacement (1 ≤ n ≤ N). Range: ≥ 1, ≤ 100000 | |
successes_in_sample | integer | yes | Number of successes among the draws whose probability you want (0 ≤ k ≤ n). Range: ≥ 0 |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
probability_exact | number | Probability of exactly k successes. | |
probability_at_most | number | Probability of k or fewer successes. | |
probability_at_least | number | Probability of k or more successes. | |
probability_less_than | number | Probability of fewer than k successes. | |
probability_more_than | number | Probability of more than k successes. | |
mean | number | n·K/N. | |
variance | number | n·(K/N)·(1 − K/N)·(N − n)/(N − 1). | |
std_dev | number | √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
- API:
GET https://tttkmbb.com/api/v1/calculate/hypergeometric-distribution(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/hypergeometric-distribution · Markdown: https://tttkmbb.com/statistics/hypergeometric-distribution.md · JSON definition: https://tttkmbb.com/statistics/hypergeometric-distribution.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="hypergeometric-distribution" - OpenAPI operationId:
calculate_hypergeometric_probability - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Hypergeometric distribution (reference)
- Wolfram MathWorld – Hypergeometric Distribution (reference)
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
- Binomial Distribution Calculator — Sampling with replacement or from a very large population.
- Lottery Odds Calculator — Prize-tier odds of a lottery, a hypergeometric application.
- Combinations and Permutations Calculator — The binomial coefficients used here.