18.2 Multinomial distribution, logit parameterization

Stan also provides a version of the multinomial probability mass function distribution with the \(\text{$K$-simplex}\) for the event count probabilities per category given on the unconstrained logistic scale.

18.2.1 Probability mass function

If \(K \in \mathbb{N}\), \(N \in \mathbb{N}\), and \(\text{softmax}(\theta) \in \text{$K$-simplex}\), then for \(y \in \mathbb{N}^K\) such that \(\sum_{k=1}^K y_k = N\), \[\begin{equation*} \begin{split} \text{MultinomialLogit}(y \mid \gamma) & = \text{Multinomial}(y \mid \text{softmax}(\gamma)) \\ & = \binom{N}{y_1,\ldots,y_K} \prod_{k=1}^K [\text{softmax}(\gamma_k)]^{y_k}, \end{split} \end{equation*}\] where the multinomial coefficient is defined by \[\begin{equation*} \binom{N}{y_1,\ldots,y_k} = \frac{N!}{\prod_{k=1}^K y_k!}. \end{equation*}\]

18.2.2 Sampling statement

y ~ multinomial_logit(gamma)

Increment target log probability density with multinomial_logit_lupmf(y | gamma).
Available since 2.24

18.2.3 Stan functions

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

real multinomial_logit_lupmf(array[] int y | vector gamma)
The log multinomial probability mass function with outcome array y of size \(K\) given the log \(K\)-simplex distribution parameter \(\gamma\) and (implicit) total count N = sum(y) dropping constant additive terms
Available since 2.25

array[] int multinomial_logit_rng(vector gamma, int N)
Generate a variate from a multinomial distribution with probabilities softmax(gamma) and total count N; may only be used in transformed data and generated quantities blocks.
Available since 2.24