Hypergeometric distribution
Story
Consider an urn with \(a\) white balls and \(b\) black balls. Draw \(N\) balls from this urn without replacement. The number white balls drawn, \(n\), is Hypergeometrically distributed.
Example
There are \(a+b\) finches on an island, and \(a\) of them are tagged (and therefore \(b\) of them are untagged). You capture \(N\) finches. The number of tagged finches \(n\) is Hypergeometrically distributed.
Parameters
There are three parameters: the number of draws \(N\), the number of white balls \(a\), and the number of black balls \(b\).
Support
The Hypergeometric distribution is supported on the set of integers between \(\mathrm{max}(0, Nb)\) and \(\mathrm{min}(N, a)\), inclusive.
Probability mass function
Moments
Mean: \(\displaystyle{N\,\frac{a}{a+b}}\)
Variance: \(\displaystyle{N\,\frac{ab}{(a + b)^2}\,\frac{a+bN}{a+b1}}\)
Usage
Package 
Syntax 

NumPy 

SciPy 

Stan 

Notes
This distribution is analogous to the Binomial distribution, except that the Binomial distribution describes draws from an urn with replacement. In the analogy, the Binomial parameter \(\theta\) is \(\theta = a/(a+b)\).
SciPy uses a different parametrization than NumPy and Stan. Let \(M = a+b\) be the total number of balls in the urn. Then, noting the order of the parameters, since this is what
scipy.stats.hypergeom
expects, the PMF may be written as
Although NumPy and Stan use the same parametrization, note the difference in the ordering of the arguments.