# Dirichlet distribution

File:Dirichlet distributions.png
Several images of the probability density of the Dirichlet distribution when K=3 for various parameter vectors α. Clockwise from top left: α=(6, 2, 2), (3, 7, 5), (6, 2, 6), (2, 3, 4).

In probability and statistics, the Dirichlet distribution (after Johann Peter Gustav Lejeune Dirichlet), often denoted Dir(α), is a family of continuous multivariate probability distributions parametrized by the vector α of positive reals. It is the multivariate generalization of the beta distribution, and conjugate prior of the multinomial distribution in Bayesian statistics. That is, its probability density function returns the belief that the probabilities of K rival events are $x_{i}$ given that each event has been observed $\alpha _{i}-1$ times.

## Probability density function

File:LogDirichletDensity-alpha 0.3 to alpha 2.0.gif
Illustrating how the log of the density function changes when K=3 as we change the vector α from α=(0.3, 0.3, 0.3) to (2.0, 2.0, 2.0), keeping all the individual $\alpha _{i}$ 's equal to each other.

The Dirichlet distribution of order K ≥ 2 with parameters α1, ..., αK > 0 has a probability density function with respect to Lebesgue measure on the Euclidean space RK–1 given by

$f(x_{1},\dots ,x_{K-1};\alpha _{1},\dots ,\alpha _{K})={\frac {1}{\mathrm {B} (\alpha )}}\prod _{i=1}^{K}x_{i}^{\alpha _{i}-1}$ for all x1, ..., xK–1 > 0 satisfying x1 + ... + xK–1 < 1, where xK is an abbreviation for 1 – x1 – ... – xK–1. The density is zero outside this open (K − 1)-dimensional simplex.

The normalizing constant is the multinomial beta function, which can be expressed in terms of the gamma function:

$\mathrm {B} (\alpha )={\frac {\prod _{i=1}^{K}\Gamma (\alpha _{i})}{\Gamma {\bigl (}\sum _{i=1}^{K}\alpha _{i}{\bigr )}}},\qquad \alpha =(\alpha _{1},\dots ,\alpha _{K}).$ ## Properties

Let $X=(X_{1},\ldots ,X_{K})\sim \operatorname {Dir} (\alpha )$ , meaning that the first K – 1 components have the above density and

$X_{K}=1-X_{1}-\cdots -X_{K-1}.$ Define $\textstyle \alpha _{0}=\sum _{i=1}^{K}\alpha _{i}$ . Then

$\mathrm {E} [X_{i}]={\frac {\alpha _{i}}{\alpha _{0}}},$ $\mathrm {Var} [X_{i}]={\frac {\alpha _{i}(\alpha _{0}-\alpha _{i})}{\alpha _{0}^{2}(\alpha _{0}+1)}},$ in fact, the marginals are Beta distributions:

$X_{i}\sim \operatorname {Beta} (\alpha _{i},\alpha _{0}-\alpha _{i}).$ Furthermore,

$\mathrm {Cov} [X_{i}X_{j}]={\frac {-\alpha _{i}\alpha _{j}}{\alpha _{0}^{2}(\alpha _{0}+1)}}.$ The mode of the distribution is the vector (x1, ..., xK) with

$x_{i}={\frac {\alpha _{i}-1}{\alpha _{0}-K}},\quad \alpha _{i}>1.$ The Dirichlet distribution is conjugate to the multinomial distribution in the following sense: if

$\beta \mid X=(\beta _{1},\ldots ,\beta _{K})\mid X\sim \operatorname {Mult} (X),$ where βi is the number of occurrences of i in a sample of n points from the discrete distribution on {1, ..., K} defined by X, then

$X\mid \beta \sim \operatorname {Dir} (\alpha +\beta ).$ This relationship is used in Bayesian statistics to estimate the hidden parameters, X, of a discrete probability distribution given a collection of n samples. Intuitively, if the prior is represented as Dir(α), then Dir(α + β) is the posterior following a sequence of observations with histogram β.

### Neutrality

(main article: neutral vector).

If $X=(X_{1},\ldots ,X_{K})\sim \operatorname {Dir} (\alpha )$ , then the vector~$X$ is said to be neutral in the sense that $X_{1}$ is independent of $X_{2}/(1-X_{1}),X_{3}/(1-X_{1}),\ldots ,X_{K}/(1-X_{1})$ and similarly for $X_{2},\ldots ,X_{K-1}$ .

Observe that any permutation of $X$ is also neutral (a property not possessed by samples drawn from a generalized Dirichlet distribution).

## Related distributions

• If, for $i\in \{1,2,\ldots ,K\},$ $Y_{i}\sim \operatorname {Gamma} ({\textrm {shape}}=\alpha _{i},{\textrm {scale}}=1){\text{ independently}},$ then
$V=\sum _{i=1}^{K}Y_{i}\sim \operatorname {Gamma} ({\textrm {shape}}=\sum _{i=1}^{K}\alpha _{i},{\textrm {scale}}=1),$ and
$(X_{1},\ldots ,X_{K})=(Y_{1}/V,\ldots ,Y_{K}/V)\sim \operatorname {Dir} (\alpha _{1},\ldots ,\alpha _{K}).$ Though the Xis are not independent from one another, they can be seen to be generated from a set of $K$ independent gamma random variables. Unfortunately, since the sum $V$ is lost in the process of forming X = (X1, ..., XK), it is not possible to recover the original gamma random variables from these values alone. Nevertheless, because independent random variables are simpler to work with, this reparametrization can still be useful for proofs about properties of the Dirichlet distribution.
• Multinomial opinions in subjective logic are equivalent to Dirichlet distributions.

## Random number generation

A method to sample a random vector $x=(x_{1},\ldots ,x_{K})$ from the K-dimensional Dirichlet distribution with parameters $(\alpha _{1},\ldots ,\alpha _{K})$ follows immediately from this connection. First, draw K independent random samples $y_{1},\ldots ,y_{K}$ from gamma distributions each with density

${\frac {y_{i}^{\alpha _{i}-1}\;e^{-y_{i}}}{\Gamma (\alpha _{i})}},\!$ and then set

$x_{i}=y_{i}/\sum _{j=1}^{K}y_{j}.\!$ ## Intuitive interpretation of the parameters

One example use of the Dirichlet distribution is if one wanted to cut strings (each of initial length 1.0) into K pieces with different lengths, where each piece had, on average, a designated average length, but allowing some variation in the relative sizes of the pieces. The α/α0 values specify the mean lengths of the cut pieces of string resulting from the distribution. The variance around this mean varies inversely with α0. 