# 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.

- Calculator id: `hypergeometric-distribution` · Category: Statistics & Probability (`statistics`) · Tool name: `calculate_hypergeometric_probability`
- Canonical page: https://tttkmbb.com/statistics/hypergeometric-distribution · This document: https://tttkmbb.com/statistics/hypergeometric-distribution.md · JSON definition: https://tttkmbb.com/statistics/hypergeometric-distribution.json

## Purpose

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.

**Use when:** 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).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `population_size` | integer |  | required | Total number of items. (min 1, max 10000000) |
| `successes_in_population` | integer |  | required | Number of items in the population that count as successes (0 ≤ K ≤ N). (min 0) |
| `draws` | integer |  | required | Number of items drawn without replacement (1 ≤ n ≤ N). (min 1, max 100000) |
| `successes_in_sample` | integer |  | required | Number of successes among the draws whose probability you want (0 ≤ k ≤ n). (min 0) |

## Output

| Field | 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. |

## 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.

## Data Sources

- Wikipedia – Hypergeometric distribution — https://en.wikipedia.org/wiki/Hypergeometric_distribution (reference, retrieved 2026-09-24)
- Wolfram MathWorld – Hypergeometric Distribution — https://mathworld.wolfram.com/HypergeometricDistribution.html (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/hypergeometric-distribution?population_size=…&successes_in_population=…&draws=…&successes_in_sample=…`
- `POST https://tttkmbb.com/api/v1/calculate/hypergeometric-distribution` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/hypergeometric-distribution · OpenAPI operationId `calculate_hypergeometric_probability` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "hypergeometric-distribution", "inputs": {…}}`

## Example

- Exactly 2 aces in a 5-card poker hand: inputs `{"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): inputs `{"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
```

## Limitations

Draws are with replacement or the population is effectively infinite (use binomial-distribution), or you want lottery prize-tier odds directly (use lottery-odds). 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. All values are computed from the formula above; no measurement or live data is involved.

## 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

- [Binomial Distribution Calculator](https://tttkmbb.com/statistics/binomial-distribution.md) — Sampling with replacement or from a very large population.
- [Lottery Odds Calculator](https://tttkmbb.com/statistics/lottery-odds.md) — Prize-tier odds of a lottery, a hypergeometric application.
- [Combinations and Permutations Calculator](https://tttkmbb.com/math/combinations-permutations.md) — The binomial coefficients used here.
