This is an old version, view current version.

14.1 Multinomial Distribution

14.1.1 Probability Mass Function

If \(K \in \mathbb{N}\), \(N \in \mathbb{N}\), and \(\theta \in \text{$K$-simplex}\), then for \(y \in \mathbb{N}^K\) such that \(\sum_{k=1}^K y_k = N\), \[ \text{Multinomial}(y|\theta) = \binom{N}{y_1,\ldots,y_K} \prod_{k=1}^K \theta_k^{y_k}, \] where the multinomial coefficient is defined by \[ \binom{N}{y_1,\ldots,y_k} = \frac{N!}{\prod_{k=1}^K y_k!}. \]

14.1.2 Sampling Statement

y ~ multinomial(theta)

Increment target log probability density with multinomial_lpmf( y | theta) dropping constant additive terms.

14.1.3 Stan Functions

real multinomial_lpmf(int[] y | vector theta)
The log multinomial probability mass function with outcome array y of size \(K\) given the \(K\)-simplex distribution parameter theta and (implicit) total count N = sum(y)

int[] multinomial_rng(vector theta, int N)
Generate a multinomial variate with simplex distribution parameter theta and total count N; may only be used in generated quantities block