Categorical distribution
Cat(π) picks one of K classes, class k with probability πₖ. It is how a model samples the next token.
In ML papers
is a die with faces: it returns class with probability , where the are non-negative and sum to 1. A classifier's Softmax output is the parameter vector of a categorical distribution, and a language model samples each next token as .
, the multinomial, counts how often each class comes up in such draws. With it is the categorical written as a one-hot vector, which is why some papers say "multinomial" for a single draw.
How to type it
| LaTeX | Shows |
|---|---|
\operatorname{Cat}(\boldsymbol{\pi}) | |
\operatorname{Categorical}(\mathbf{p}) | |
\operatorname{Mult}(n, \mathbf{p}) multinomial |
A worked example
Sampling 1000 times gives roughly 700 ones, 200 twos and 100 threes.
Common confusions
- is a distribution over class indices; the Bernoulli distribution is the special case with two classes.