Sampling without replacement from a finite population.
The Hypergeometric distribution models the number of successes ($k$) in a sample of size $n$ drawn without replacement from a population of size $N$ containing $K$ successes. Unlike the Binomial distribution, the probability of success changes with each draw.
Where $\binom{n}{k}$ is the binomial coefficient.
Support: $\max(0, n+K-N) \le k \le \min(n, K)$
Finite Population Correction: The key difference in variance is the term $\frac{N-n}{N-1}$.
1. If $N$ is very large compared to $n$ (sample is < 5% of population), this term $\approx 1$.
2. In this case, the Hypergeometric distribution converges to the Binomial Distribution $B(n, p=K/N)$.
import scipy.stats as stats
N = 50 # Population Size
K = 10 # Total Successes in Pop
n = 5 # Sample Size
x = 2 # Observed Successes
# 1. Exact Probability P(X=x) (PMF)
prob = stats.hypergeom.pmf(x, N, K, n)
print(f"P(X={x}) = {prob:.4f}")
# 2. Cumulative Probability P(X<=x) (CDF)
cum_prob = stats.hypergeom.cdf(x, N, K, n)
print(f"P(X<={x}) = {cum_prob:.4f}")