The hypergeometric distribution models drawing objects from a bin.
M is the total number of objects, n is total number of Type I objects.
The random variate represents the number of Type I objects in N drawn
without replacement from the total population.

As an instance of the rv_discrete class, hypergeom object inherits from it
a collection of generic methods (see below for the full list),
and completes them with details specific for this particular distribution.

The probability mass function above is defined in the “standardized” form.
To shift distribution use the loc parameter.
Specifically, hypergeom.pmf(k,M,n,N,loc) is identically
equivalent to hypergeom.pmf(k-loc,M,n,N).

Examples

>>> fromscipy.statsimporthypergeom>>> importmatplotlib.pyplotasplt

Suppose we have a collection of 20 animals, of which 7 are dogs. Then if
we want to know the probability of finding a given number of dogs if we
choose at random 12 of the 20 animals, we can initialize a frozen
distribution and plot the probability mass function: