bundles / scipy 1.17.1 / scipy / stats / _discrete_distns / hypergeom_gen
class
scipy.stats._discrete_distns:hypergeom_gen
Signature
class hypergeom_gen ( a = 0 , b = inf , name = None , badvalue = None , moment_tol = 1e-08 , values = None , inc = 1 , longname = None , shapes = None , seed = None ) Members
Summary
A hypergeometric discrete random variable.
Extended Summary
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.
%(before_notes)s
Notes
The symbols used to denote the shape parameters (M, n, and N) are not universally accepted. See the Examples for a clarification of the definitions used here.
The probability mass function is defined as,
for , where the binomial coefficients are defined as,
This distribution uses routines from the Boost Math C++ library for the computation of the pmf, cdf, sf and stats methods. [1]
%(after_notes)s
Examples
import numpy as np from scipy.stats import hypergeom import matplotlib.pyplot as plt✓
[M, n, N] = [20, 7, 12] rv = hypergeom(M, n, N) x = np.arange(0, n+1) pmf_dogs = rv.pmf(x)✓
fig = plt.figure() ax = fig.add_subplot(111)✓
ax.plot(x, pmf_dogs, 'bo') ax.vlines(x, 0, pmf_dogs, lw=2) ax.set_xlabel('# of dogs in our group of chosen animals') ax.set_ylabel('hypergeom PMF')✗
plt.show()
✓
prb = hypergeom.cdf(x, M, n, N)
✓R = hypergeom.rvs(M, n, N, size=10)
✓See also
- binom
- nbinom
- nhypergeom
Aliases
-
scipy.stats._discrete_distns.hypergeom_gen