## 18.1 Multinomial distribution

### 18.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!}.$

### 18.1.2 Sampling statement

y ~ multinomial(theta)

Increment target log probability density with multinomial_lupmf(y | theta).
Available since 2.0

### 18.1.3 Stan functions

real multinomial_lpmf(array[] 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)
Available since 2.12

real multinomial_lupmf(array[] 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) dropping constant additive terms
Available since 2.25

array[] 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 transformed data and generated quantities blocks
Available since 2.8