{ } Raw JSON

bundles / scipy 1.17.1 / scipy / stats / _multivariate / multivariate_hypergeom_gen

class

scipy.stats._multivariate:multivariate_hypergeom_gen

source: /scipy/stats/_multivariate.py :5647

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)
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)
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])
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])
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])

See also

scipy.stats.hypergeom

The hypergeometric distribution.

scipy.stats.multinomial

The multinomial distribution.

Aliases

  • scipy.stats._multivariate.multivariate_hypergeom_gen