bundles / scipy latest / scipy / stats / _multivariate / multivariate_hypergeom_gen
class
scipy.stats._multivariate:multivariate_hypergeom_gen
source: build-install/usr/lib/python3.14/site-packages/scipy/stats/_multivariate.py:5649
Signature
class multivariate_hypergeom_gen(seed = None)Members
Summary
A multivariate hypergeometric random variable.
Parameters
%(_doc_default_callparams)s%(_doc_random_state)s
Methods
pmf(x, m, n)Probability mass function.
logpmf(x, m, n)Log of the probability mass function.
rvs(m, n, size=1, random_state=None)Draw random samples from a multivariate hypergeometric distribution.
mean(m, n)Mean of the multivariate hypergeometric distribution.
var(m, n)Variance of the multivariate hypergeometric distribution.
cov(m, n)Compute the covariance matrix of the multivariate hypergeometric distribution.
Notes
%(_doc_callparams_note)s
The probability mass function for multivariate_hypergeom is
where are the number of objects of type , is the total number of objects in the population (sum of all the ), and is the size of the sample to be taken from the population.
Examples
To evaluate the probability mass function of the multivariate hypergeometric distribution, with a dichotomous population of size :math:`10` and :math:`20`, at a sample of size :math:`12` with :math:`8` objects of the first type and :math:`4` objects of the second type, use:from scipy.stats import multivariate_hypergeom
✓multivariate_hypergeom.pmf(x=[8, 4], m=[10, 20], n=12)
✗np.float64(0.0025207176631464523)The `multivariate_hypergeom` distribution is identical to the corresponding `hypergeom` distribution (tiny numerical differences notwithstanding) when only two types (good and bad) of objects are present in the population as in the example above. Consider another example for a comparison with the hypergeometric distribution:
from scipy.stats import hypergeom
✓multivariate_hypergeom.pmf(x=[3, 1], m=[10, 5], n=4) hypergeom.pmf(k=3, M=15, n=4, N=10)✗
np.float64(0.4395604395604396)The functions ``pmf``, ``logpmf``, ``mean``, ``var``, ``cov``, and ``rvs`` support broadcasting, under the convention that the vector parameters (``x``, ``m``, and ``n``) are interpreted as if each row along the last axis is a single object. For instance, we can combine the previous two calls to `multivariate_hypergeom` as
multivariate_hypergeom.pmf(x=[[8, 4], [3, 1]], m=[[10, 20], [10, 5]], n=[12, 4])✗
array([0.00252, 0.43956])This broadcasting also works for ``cov``, where the output objects are square matrices of size ``m.shape[-1]``. For example:
multivariate_hypergeom.cov(m=[[7, 9], [10, 15]], n=[8, 12])
✗array([[[ 1.05, -1.05],
[-1.05, 1.05]],
[[ 1.56, -1.56],
[-1.56, 1.56]]])
That is, ``result[0]`` is equal to
``multivariate_hypergeom.cov(m=[7, 9], n=8)`` and ``result[1]`` is equal
to ``multivariate_hypergeom.cov(m=[10, 15], n=12)``.
Alternatively, the object may be called (as a function) to fix the `m`
and `n` parameters, returning a "frozen" multivariate hypergeometric
random variable.
rv = multivariate_hypergeom(m=[10, 20], n=12)
✓rv.pmf(x=[8, 4])
✗np.float64(0.0025207176631464523)
See also
- scipy.stats.hypergeom
The hypergeometric distribution.
- scipy.stats.multinomial
The multinomial distribution.
Aliases
scipy.stats._multivariate.multivariate_hypergeom_gen