This is a concise introduction to the Dirichlet distribution and its connection to Multinomial-distributions counts, based on work and discussions with Daniel Mortlock (Imperial College), Hiranya Peiris (UCL), Josh Speagle (Harvard), and Jo Bovy (Toronto). Everything below is very simple but for some reason misunderstood and massively under-exploited outside of the statistics literature.

The Dirichlet distribution is a very useful tool in probability and statistics. It is a natural choice for constructing a prior on a set of positive unit-normalized weights, denoted by with and .

To use a Dirichlet prior for those weights, one needs a set of (positive, real) hyperparameters with . Neglecting the normalization (i.e. the terms which do not depend on , which you can find here), the prior reads

.

Note that this is a prior on the simplex, and that it is easy to draw values (weights ) from this distribution, like you would do from uniform or Gaussian distributions. By changing the hyperparameters, one can affect the statistical properties of the weights. For example, if we write , their mean, variance and covariance read

,

where you will forgive me for slightly abusing the notation for expectation values. You will note that the coefficients are anti-correlated. Can you find why this is intuitively correct? An important case is , where the mean becomes . This is the most general, uninformative prior you can place on a set of unit-normalized positive weights, and it has important consequences.

One of those has to do with what these sorts of weights are used for: drawing objects from categories. Indeed, can be interpreted as a set of probabilities over classes. Drawing objects from those classes (one by one) is known as a categorical draw. The generalization of these draws is the well-known Multinomial distribution, which corresponds to drawing objects from categories/classes with probabilities . We are interested in the probability of drawing some the numbers of objects the classes, , with . The Multinomial distribution is

.

where I have, again, neglected the normalization constants that do not depend on . Note that we have conditioned on here (things get much more complicated if the number of objects varies!).

Did you notice how similar this expression is to the Dirichlet distribution? This is because the Dirichlet and Multinomial distributions are conjugate priors. If you swap the parameters and in the probability , you change one distribution into the other. This is extremely useful, because this sort of swap happens when applying Bayes theorem:

.

Let us take a concrete, classic example: I observe a set of categorical counts , and I want to estimate the weights , subject to a Dirichlet prior controlled by fixed hyperparameters . Applying Bayes theorem gives

,

which is a Dirichlet distribution! So we can write .

With the uninformative prior , we have which is a common example. This is the posterior distribution for the probabilities of the categories given the observed counts . The weights could be the normalized amplitudes of a histogram, for example. The reason this is a powerful result is because we know how to sample directly from a Dirichlet distribution, and we can easily compute all its moments; there is no need to resort to MCMC or other sampling techniques to explore or approximate this posterior distribution. Note that this is not quite true if the number counts themselves are unobserved (latent) variables in a larger hierarchical probabilistic model, but one can still exploit the Dirichlet-Multinomial conjugacy property via Gibbs MCMC sampling, like we did in this paper for galaxy redshift estimation.

One final remark: an other very common structure is the so-called Dirichlet-Multinomial distribution or compound. This arises when one wants to skip the weights and directly connect the number counts to the hyperparameters . This requires marginalizing out the weights , i.e.,

This admits a closed form which you can find here. It is a useful when one wants is not interested in the weights , or if one wants to infer a point estimate of (optimal in some sense, such as a maximum likelihood solution) given a set of number counts while marginalizing over the weights.

which involves the Dirichlet-Multinomial compound and a prior over .