pymc.Multinomial#

class pymc.Multinomial(name, *args, **kwargs)[source]#

Multinomial log-likelihood.

Generalizes binomial distribution, but instead of each trial resulting in “success” or “failure”, each one results in exactly one of some fixed finite number k of possible outcomes over n independent trials. ‘x[i]’ indicates the number of times outcome number i was observed over the n trials.

\[f(x \mid n, p) = \frac{n!}{\prod_{i=1}^k x_i!} \prod_{i=1}^k p_i^{x_i}\]

Support

\(x \in \{0, 1, \ldots, n\}\) such that \(\sum x_i = n\)

Mean

\(n p_i\)

Variance

\(n p_i (1 - p_i)\)

Covariance

\(-n p_i p_j\) for \(i \ne j\)

Parameters
ntensor_like of int

Total counts in each replicate (n > 0).

ptensor_like of float

Probability of each one of the different outcomes (0 <= p <= 1). The number of categories is given by the length of the last axis. Elements are expected to sum to 1 along the last axis, and they will be automatically rescaled otherwise.

Methods

Multinomial.__init__(*args, **kwargs)

Multinomial.dist(n, p, *args, **kwargs)

Creates a tensor variable corresponding to the cls distribution.

Multinomial.logp(n, p)

Calculate log-probability of Multinomial distribution at specified value.

Multinomial.moment(size, n, p)

Attributes

rv_class

rv_op