Dirichlet distribution

From HandWiki
Short description: Probability distribution
Dirichlet distribution
Probability density function
Dirichlet.pdf
Parameters [math]\displaystyle{ K \geq 2 }[/math] number of categories (integer)
[math]\displaystyle{ \boldsymbol\alpha=(\alpha_1,\ldots,\alpha_K) }[/math] concentration parameters, where [math]\displaystyle{ \alpha_i \gt 0 }[/math]
Support [math]\displaystyle{ x_1, \ldots, x_K }[/math] where [math]\displaystyle{ x_i \in [0,1] }[/math] and [math]\displaystyle{ \sum_{i=1}^K x_i = 1 }[/math]
PDF [math]\displaystyle{ \frac{1}{\mathrm{B}(\boldsymbol\alpha)} \prod_{i=1}^K x_i^{\alpha_i - 1} }[/math]
where [math]\displaystyle{ \mathrm{B}(\boldsymbol\alpha) = \frac{\prod_{i=1}^K \Gamma(\alpha_i)}{\Gamma\bigl(\alpha_0\bigr)} }[/math]
where [math]\displaystyle{ \alpha_0 = \sum_{i=1}^K\alpha_i }[/math]
Mean [math]\displaystyle{ \operatorname{E}[X_i] = \frac{\alpha_i}{\alpha_0} }[/math]
[math]\displaystyle{ \operatorname{E}[\ln X_i] = \psi(\alpha_i)-\psi(\alpha_0) }[/math]
(where [math]\displaystyle{ \psi }[/math] is the digamma function)
Mode [math]\displaystyle{ x_i = \frac{\alpha_i - 1}{\alpha_0 - K}, \quad \alpha_i \gt 1. }[/math]
Variance [math]\displaystyle{ \operatorname{Var}[X_i] = \frac{\tilde{\alpha}_i(1-\tilde{\alpha}_i)}{\alpha_0+1}, }[/math] [math]\displaystyle{ \operatorname{Cov}[X_i,X_j] = \frac{\delta_{ij}\,\tilde{\alpha}_i-\tilde{\alpha}_i \tilde{\alpha}_j}{\alpha_0+1} }[/math]
where [math]\displaystyle{ \tilde{\alpha}_i = \frac{\alpha_i}{\alpha_0} }[/math], and [math]\displaystyle{ \delta_{ij} }[/math] is the Kronecker delta
Entropy [math]\displaystyle{ H(X) = \log \mathrm{B}(\boldsymbol\alpha) }[/math][math]\displaystyle{ + (\alpha_0-K)\psi(\alpha_0) - }[/math][math]\displaystyle{ \sum_{j=1}^K (\alpha_j-1)\psi(\alpha_j) }[/math]
with [math]\displaystyle{ \alpha_0 }[/math] defined as for variance, above; and [math]\displaystyle{ \psi }[/math] is the digamma function

In probability and statistics, the Dirichlet distribution (after Peter Gustav Lejeune Dirichlet), often denoted [math]\displaystyle{ \operatorname{Dir}(\boldsymbol\alpha) }[/math], is a family of continuous multivariate probability distributions parameterized by a vector [math]\displaystyle{ \boldsymbol\alpha }[/math] of positive reals. It is a multivariate generalization of the beta distribution,[1] hence its alternative name of multivariate beta distribution (MBD).[2] Dirichlet distributions are commonly used as prior distributions in Bayesian statistics, and in fact, the Dirichlet distribution is the conjugate prior of the categorical distribution and multinomial distribution.

The infinite-dimensional generalization of the Dirichlet distribution is the Dirichlet process.

Definitions

Probability density function

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 [math]\displaystyle{ \alpha_i }[/math]'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

[math]\displaystyle{ f \left(x_1,\ldots, x_{K}; \alpha_1,\ldots, \alpha_K \right) = \frac{1}{\mathrm{B}(\boldsymbol\alpha)} \prod_{i=1}^K x_i^{\alpha_i - 1} }[/math]
where [math]\displaystyle{ \{x_k\}_{k=1}^{k=K} }[/math] belong to the standard [math]\displaystyle{ K-1 }[/math] simplex, or in other words: [math]\displaystyle{ \sum_{i=1}^{K} x_i = 1 \mbox{ and } x_i \in \left[0,1\right] \mbox{ for all } i \in \{1,\dots,K\} }[/math]

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

[math]\displaystyle{ \mathrm{B}(\boldsymbol\alpha) = \frac{\prod\limits_{i=1}^K \Gamma(\alpha_i)}{\Gamma\left(\sum\limits_{i=1}^K \alpha_i\right)},\qquad\boldsymbol{\alpha}=(\alpha_1,\ldots,\alpha_K). }[/math]

Support

The support of the Dirichlet distribution is the set of K-dimensional vectors [math]\displaystyle{ \boldsymbol x }[/math] whose entries are real numbers in the interval [0,1] such that [math]\displaystyle{ \|\boldsymbol x\|_1 = 1 }[/math], i.e. the sum of the coordinates is equal to 1. These can be viewed as the probabilities of a K-way categorical event. Another way to express this is that the domain of the Dirichlet distribution is itself a set of probability distributions, specifically the set of K-dimensional discrete distributions. The technical term for the set of points in the support of a K-dimensional Dirichlet distribution is the open standard (K − 1)-simplex,[3] which is a generalization of a triangle, embedded in the next-higher dimension. For example, with K = 3, the support is an equilateral triangle embedded in a downward-angle fashion in three-dimensional space, with vertices at (1,0,0), (0,1,0) and (0,0,1), i.e. touching each of the coordinate axes at a point 1 unit away from the origin.

Special cases

A common special case is the symmetric Dirichlet distribution, where all of the elements making up the parameter vector [math]\displaystyle{ \boldsymbol\alpha }[/math] have the same value. The symmetric case might be useful, for example, when a Dirichlet prior over components is called for, but there is no prior knowledge favoring one component over another. Since all elements of the parameter vector have the same value, the symmetric Dirichlet distribution can be parametrized by a single scalar value α, called the concentration parameter. In terms of α, the density function has the form

[math]\displaystyle{ f(x_1,\dots, x_{K}; \alpha) = \frac{\Gamma(\alpha K)}{\Gamma(\alpha)^K} \prod_{i=1}^K x_i^{\alpha - 1}. }[/math]

When α=1[1], the symmetric Dirichlet distribution is equivalent to a uniform distribution over the open standard (K − 1)-simplex, i.e. it is uniform over all points in its support. This particular distribution is known as the flat Dirichlet distribution. Values of the concentration parameter above 1 prefer variates that are dense, evenly distributed distributions, i.e. all the values within a single sample are similar to each other. Values of the concentration parameter below 1 prefer sparse distributions, i.e. most of the values within a single sample will be close to 0, and the vast majority of the mass will be concentrated in a few of the values.

More generally, the parameter vector is sometimes written as the product [math]\displaystyle{ \alpha \boldsymbol n }[/math] of a (scalar) concentration parameter α and a (vector) base measure [math]\displaystyle{ \boldsymbol n=(n_1,\dots,n_K) }[/math] where [math]\displaystyle{ \boldsymbol n }[/math] lies within the (K − 1)-simplex (i.e.: its coordinates [math]\displaystyle{ n_i }[/math] sum to one). The concentration parameter in this case is larger by a factor of K than the concentration parameter for a symmetric Dirichlet distribution described above. This construction ties in with concept of a base measure when discussing Dirichlet processes and is often used in the topic modelling literature.

^ If we define the concentration parameter as the sum of the Dirichlet parameters for each dimension, the Dirichlet distribution with concentration parameter K, the dimension of the distribution, is the uniform distribution on the (K − 1)-simplex.

Properties

Moments

Let [math]\displaystyle{ X = (X_1, \ldots, X_K)\sim\operatorname{Dir}(\boldsymbol\alpha) }[/math].

Let

[math]\displaystyle{ \alpha_0 = \sum_{i=1}^K \alpha_i. }[/math]

Then[4][5]

[math]\displaystyle{ \operatorname{E}[X_i] = \frac{\alpha_i}{\alpha_0}, }[/math]
[math]\displaystyle{ \operatorname{Var}[X_i] = \frac{\alpha_i (\alpha_0-\alpha_i)}{\alpha_0^2 (\alpha_0+1)}. }[/math]

Furthermore, if [math]\displaystyle{ i\neq j }[/math]

[math]\displaystyle{ \operatorname{Cov}[X_i,X_j] = \frac{- \alpha_i \alpha_j}{\alpha_0^2 (\alpha_0+1)}. }[/math]

The matrix is thus singular.

More generally, moments of Dirichlet-distributed random variables can be expressed as[6]

[math]\displaystyle{ \operatorname{E}\left[\prod_{i=1}^K X_i^{\beta_i}\right] = \frac{B\left(\boldsymbol{\alpha} + \boldsymbol{\beta}\right)}{B\left(\boldsymbol{\alpha}\right)} = \frac{\Gamma\left(\sum\limits_{i=1}^K \alpha_{i}\right)}{\Gamma\left[\sum\limits_{i=1}^K (\alpha_i+\beta_i)\right]}\times\prod_{i=1}^K \frac{\Gamma(\alpha_i+\beta_i)}{\Gamma(\alpha_i)}. }[/math]

Mode

The mode of the distribution is[7] the vector (x1, ..., xK) with

[math]\displaystyle{ x_i = \frac{\alpha_i - 1}{\alpha_0 - K}, \qquad \alpha_i \gt 1. }[/math]

Marginal distributions

The marginal distributions are beta distributions:[8]

[math]\displaystyle{ X_i \sim \operatorname{Beta} (\alpha_i, \alpha_0 - \alpha_i). }[/math]

Conjugate to categorical or multinomial

The Dirichlet distribution is the conjugate prior distribution of the categorical distribution (a generic discrete probability distribution with a given number of possible outcomes) and multinomial distribution (the distribution over observed counts of each possible category in a set of categorically distributed observations). This means that if a data point has either a categorical or multinomial distribution, and the prior distribution of the distribution's parameter (the vector of probabilities that generates the data point) is distributed as a Dirichlet, then the posterior distribution of the parameter is also a Dirichlet. Intuitively, in such a case, starting from what we know about the parameter prior to observing the data point, we then can update our knowledge based on the data point and end up with a new distribution of the same form as the old one. This means that we can successively update our knowledge of a parameter by incorporating new observations one at a time, without running into mathematical difficulties.

Formally, this can be expressed as follows. Given a model

[math]\displaystyle{ \begin{array}{rcccl} \boldsymbol\alpha &=& \left(\alpha_1, \ldots, \alpha_K \right) &=& \text{concentration hyperparameter} \\ \mathbf{p}\mid\boldsymbol\alpha &=& \left(p_1, \ldots, p_K \right ) &\sim& \operatorname{Dir}(K, \boldsymbol\alpha) \\ \mathbb{X}\mid\mathbf{p} &=& \left(\mathbf{x}_1, \ldots, \mathbf{x}_K \right ) &\sim& \operatorname{Cat}(K,\mathbf{p}) \end{array} }[/math]

then the following holds:

[math]\displaystyle{ \begin{array}{rcccl} \mathbf{c} &=& \left(c_1, \ldots, c_K \right ) &=& \text{number of occurrences of category }i \\ \mathbf{p} \mid \mathbb{X},\boldsymbol\alpha &\sim& \operatorname{Dir}(K,\mathbf{c}+\boldsymbol\alpha) &=& \operatorname{Dir} \left (K,c_1+\alpha_1,\ldots,c_K+\alpha_K \right) \end{array} }[/math]

This relationship is used in Bayesian statistics to estimate the underlying parameter p of a categorical distribution given a collection of N samples. Intuitively, we can view the hyperprior vector α as pseudocounts, i.e. as representing the number of observations in each category that we have already seen. Then we simply add in the counts for all the new observations (the vector c) in order to derive the posterior distribution.

In Bayesian mixture models and other hierarchical Bayesian models with mixture components, Dirichlet distributions are commonly used as the prior distributions for the categorical variables appearing in the models. See the section on applications below for more information.

Relation to Dirichlet-multinomial distribution

In a model where a Dirichlet prior distribution is placed over a set of categorical-valued observations, the marginal joint distribution of the observations (i.e. the joint distribution of the observations, with the prior parameter marginalized out) is a Dirichlet-multinomial distribution. This distribution plays an important role in hierarchical Bayesian models, because when doing inference over such models using methods such as Gibbs sampling or variational Bayes, Dirichlet prior distributions are often marginalized out. See the article on this distribution for more details.

Entropy

If X is a [math]\displaystyle{ \operatorname{Dir}(\boldsymbol\alpha) }[/math] random variable, the differential entropy of X (in nat units) is[9]

[math]\displaystyle{ h(\boldsymbol X) = \operatorname{E}[- \ln f(\boldsymbol X)] = \ln \operatorname{B}(\boldsymbol\alpha) + (\alpha_0-K)\psi(\alpha_0) - \sum_{j=1}^K (\alpha_j-1)\psi(\alpha_j) }[/math]

where [math]\displaystyle{ \psi }[/math] is the digamma function.

The following formula for [math]\displaystyle{ \operatorname{E}[\ln(X_i)] }[/math] can be used to derive the differential entropy above. Since the functions [math]\displaystyle{ \ln(X_i) }[/math] are the sufficient statistics of the Dirichlet distribution, the exponential family differential identities can be used to get an analytic expression for the expectation of [math]\displaystyle{ \ln(X_i) }[/math] (see equation (2.62) in [10]) and its associated covariance matrix:

[math]\displaystyle{ \operatorname{E}[\ln(X_i)] = \psi(\alpha_i)-\psi(\alpha_0) }[/math]

and

[math]\displaystyle{ \operatorname{Cov}[\ln(X_i),\ln(X_j)] = \psi'(\alpha_i) \delta_{ij} - \psi'(\alpha_0) }[/math]

where [math]\displaystyle{ \psi }[/math] is the digamma function, [math]\displaystyle{ \psi' }[/math] is the trigamma function, and [math]\displaystyle{ \delta_{ij} }[/math] is the Kronecker delta.

The spectrum of Rényi information for values other than [math]\displaystyle{ \lambda = 1 }[/math] is given by[11]

[math]\displaystyle{ F_R(\lambda) = (1-\lambda)^{-1} \left( - \lambda \log \mathrm{B}(\boldsymbol\alpha) + \sum_{i=1}^K \log \Gamma(\lambda(\alpha_i - 1) + 1) - \log \Gamma(\lambda (\alpha_0 - K) + K ) \right) }[/math]

and the information entropy is the limit as [math]\displaystyle{ \lambda }[/math] goes to 1.

Another related interesting measure is the entropy of a discrete categorical (one-of-K binary) vector [math]\displaystyle{ \boldsymbol Z }[/math] with probability-mass distribution [math]\displaystyle{ \boldsymbol X }[/math], i.e., [math]\displaystyle{ P(Z_i=1, Z_{j\ne i} = 0 | \boldsymbol X) = X_i }[/math]. The conditional information entropy of [math]\displaystyle{ \boldsymbol Z }[/math], given [math]\displaystyle{ \boldsymbol X }[/math] is

[math]\displaystyle{ S(\boldsymbol X) = H(\boldsymbol Z | \boldsymbol X) = \operatorname{E}_{\boldsymbol Z}[- \log P(\boldsymbol Z | \boldsymbol X ) ] = \sum_{i=1}^K - X_i \log X_i }[/math]

This function of [math]\displaystyle{ \boldsymbol X }[/math] is a scalar random variable. If [math]\displaystyle{ \boldsymbol X }[/math] has a symmetric Dirichlet distribution with all [math]\displaystyle{ \alpha_i = \alpha }[/math], the expected value of the entropy (in nat units) is[12]

[math]\displaystyle{ \operatorname{E}[S(\boldsymbol X)] = \sum_{i=1}^K \operatorname{E}[- X_i \ln X_i] = \psi(K\alpha + 1) - \psi(\alpha + 1) }[/math]

Aggregation

If

[math]\displaystyle{ X = (X_1, \ldots, X_K)\sim\operatorname{Dir}(\alpha_1,\ldots,\alpha_K) }[/math]

then, if the random variables with subscripts i and j are dropped from the vector and replaced by their sum,

[math]\displaystyle{ X' = (X_1, \ldots, X_i + X_j, \ldots, X_K)\sim\operatorname{Dir} (\alpha_1, \ldots, \alpha_i + \alpha_j, \ldots, \alpha_K). }[/math]

This aggregation property may be used to derive the marginal distribution of [math]\displaystyle{ X_i }[/math] mentioned above.

Neutrality

Main page: Neutral vector

If [math]\displaystyle{ X = (X_1, \ldots, X_K)\sim\operatorname{Dir}(\boldsymbol\alpha) }[/math], then the vector X is said to be neutral[13] in the sense that XK is independent of [math]\displaystyle{ X^{(-K)} }[/math][3] where

[math]\displaystyle{ X^{(-K)}=\left(\frac{X_1}{1-X_K},\frac{X_2}{1-X_K},\ldots,\frac{X_{K-1}}{1-X_K} \right), }[/math]

and similarly for removing any of [math]\displaystyle{ X_2,\ldots,X_{K-1} }[/math]. Observe that any permutation of X is also neutral (a property not possessed by samples drawn from a generalized Dirichlet distribution).[14]

Combining this with the property of aggregation it follows that Xj + ... + XK is independent of [math]\displaystyle{ \left(\frac{X_1}{X_1+\cdots +X_{j-1}},\frac{X_2}{X_1+\cdots +X_{j-1}},\ldots,\frac{X_{j-1}}{X_1+\cdots +X_{j-1}} \right) }[/math]. In fact it is true, further, for the Dirichlet distribution, that for [math]\displaystyle{ 3\le j\le K-1 }[/math], the pair [math]\displaystyle{ \left(X_1+\cdots +X_{j-1}, X_j+\cdots +X_K\right) }[/math], and the two vectors [math]\displaystyle{ \left(\frac{X_1}{X_1+\cdots +X_{j-1}},\frac{X_2}{X_1+\cdots +X_{j-1}},\ldots,\frac{X_{j-1}}{X_1+\cdots +X_{j-1}} \right) }[/math] and [math]\displaystyle{ \left(\frac{X_j}{X_j+\cdots +X_K},\frac{X_{j+1}}{X_j+\cdots +X_K},\ldots,\frac{X_K}{X_j+\cdots +X_K} \right) }[/math], viewed as triple of normalised random vectors, are mutually independent. The analogous result is true for partition of the indices {1,2,...,K} into any other pair of non-singleton subsets.

Characteristic function

The characteristic function of the Dirichlet distribution is a confluent form of the Lauricella hypergeometric series. It is given by Phillips as[15]

[math]\displaystyle{ CF\left(s_1,\ldots,s_{K-1}\right) = \operatorname{E}\left(e^{i\left(s_1X_1+\cdots+s_{K-1}X_{K-1} \right)} \right)= \Psi^{\left[K-1\right]} (\alpha_1,\ldots,\alpha_{K-1};\alpha_0;is_1,\ldots, is_{K-1}) }[/math]

where

[math]\displaystyle{ \Psi^{[m]} (a_1,\ldots,a_m;c;z_1,\ldots z_m) = \sum\frac{(a_1)_{k_1} \cdots (a_m)_{k_m} \, z_1^{k_1} \cdots z_m^{k_m}}{(c)_k\,k_1!\cdots k_m!}. }[/math]

The sum is over non-negative integers [math]\displaystyle{ k_1,\ldots,k_m }[/math] and [math]\displaystyle{ k=k_1+\cdots+k_m }[/math]. Phillips goes on to state that this form is "inconvenient for numerical calculation" and gives an alternative in terms of a complex path integral:

[math]\displaystyle{ \Psi^{[m]} = \frac{\Gamma(c)}{2\pi i}\int_L e^t\,t^{a_1+\cdots+a_m-c}\,\prod_{j=1}^m (t-z_j)^{-a_j} \, dt }[/math]

where L denotes any path in the complex plane originating at [math]\displaystyle{ -\infty }[/math], encircling in the positive direction all the singularities of the integrand and returning to [math]\displaystyle{ -\infty }[/math].

Inequality

Probability density function [math]\displaystyle{ f \left(x_1,\ldots, x_{K-1}; \alpha_1,\ldots, \alpha_K \right) }[/math] plays a key role in a multifunctional inequality which implies various bounds for the Dirichlet distribution.[16]

Related distributions

For K independently distributed Gamma distributions:

[math]\displaystyle{ Y_1 \sim \operatorname{Gamma}(\alpha_1, \theta), \ldots, Y_K \sim \operatorname{Gamma}(\alpha_K, \theta) }[/math]

we have:[17]:402

[math]\displaystyle{ V=\sum_{i=1}^K Y_i\sim\operatorname{Gamma} \left(\alpha_0, \theta \right ), }[/math]
[math]\displaystyle{ X = (X_1, \ldots, X_K) = \left(\frac{Y_1}{V}, \ldots, \frac{Y_K}{V} \right)\sim \operatorname{Dir}\left (\alpha_1, \ldots, \alpha_K \right). }[/math]

Although the Xis are not independent from one another, they can be seen to be generated from a set of K independent gamma random variable.[17]:594 Unfortunately, since the sum V is lost in forming X (in fact it can be shown that V is stochastically independent of X), 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.

Conjugate prior of the Dirichlet distribution

Because the Dirichlet distribution is an exponential family distribution it has a conjugate prior. The conjugate prior is of the form:[18]

[math]\displaystyle{ \operatorname{CD}(\boldsymbol\alpha \mid \boldsymbol{v},\eta) \propto \left(\frac{1}{\operatorname{B}(\boldsymbol\alpha)}\right)^\eta \exp\left(-\sum_k v_k \alpha_k\right). }[/math]

Here [math]\displaystyle{ \boldsymbol{v} }[/math] is a K-dimensional real vector and [math]\displaystyle{ \eta }[/math] is a scalar parameter. The domain of [math]\displaystyle{ (\boldsymbol{v},\eta) }[/math] is restricted to the set of parameters for which the above unnormalized density function can be normalized. The (necessary and sufficient) condition is:[19]

[math]\displaystyle{ \forall k\;\;v_k\gt 0\;\;\;\;\text{ and } \;\;\;\;\eta\gt -1 \;\;\;\;\text{ and } \;\;\;\;(\eta\leq0\;\;\;\;\text{ or }\;\;\;\;\sum_k \exp-\frac{v_k} \eta \lt 1) }[/math]

The conjugation property can be expressed as

if [prior: [math]\displaystyle{ \boldsymbol{\alpha}\sim\operatorname{CD}(\cdot \mid \boldsymbol{v},\eta) }[/math]] and [observation: [math]\displaystyle{ \boldsymbol{x}\mid\boldsymbol{\alpha}\sim\operatorname{Dirichlet}(\cdot \mid \boldsymbol{\alpha}) }[/math]] then [posterior: [math]\displaystyle{ \boldsymbol{\alpha}\mid\boldsymbol{x}\sim\operatorname{CD}(\cdot \mid \boldsymbol{v}-\log \boldsymbol{x}, \eta+1) }[/math]].

In the published literature there is no practical algorithm to efficiently generate samples from [math]\displaystyle{ \operatorname{CD}(\boldsymbol{\alpha} \mid \boldsymbol{v},\eta) }[/math].

Occurrence and applications

Bayesian models

Dirichlet distributions are most commonly used as the prior distribution of categorical variables or multinomial variables in Bayesian mixture models and other hierarchical Bayesian models. (In many fields, such as in natural language processing, categorical variables are often imprecisely called "multinomial variables". Such a usage is unlikely to cause confusion, just as when Bernoulli distributions and binomial distributions are commonly conflated.)

Inference over hierarchical Bayesian models is often done using Gibbs sampling, and in such a case, instances of the Dirichlet distribution are typically marginalized out of the model by integrating out the Dirichlet random variable. This causes the various categorical variables drawn from the same Dirichlet random variable to become correlated, and the joint distribution over them assumes a Dirichlet-multinomial distribution, conditioned on the hyperparameters of the Dirichlet distribution (the concentration parameters). One of the reasons for doing this is that Gibbs sampling of the Dirichlet-multinomial distribution is extremely easy; see that article for more information.


Intuitive interpretations of the parameters

The concentration parameter

Dirichlet distributions are very often used as prior distributions in Bayesian inference. The simplest and perhaps most common type of Dirichlet prior is the symmetric Dirichlet distribution, where all parameters are equal. This corresponds to the case where you have no prior information to favor one component over any other. As described above, the single value α to which all parameters are set is called the concentration parameter. If the sample space of the Dirichlet distribution is interpreted as a discrete probability distribution, then intuitively the concentration parameter can be thought of as determining how "concentrated" the probability mass of the Dirichlet distribution to its center, leading to samples with mass dispersed almost equally among all components, i.e., with a value much less than 1, the mass will be highly concentrated in a few components, and all the rest will have almost no mass, and with a value much greater than 1, the mass will be dispersed almost equally among all the components. See the article on the concentration parameter for further discussion.

String cutting

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 a designated average length, but allowing some variation in the relative sizes of the pieces. Recall that [math]\displaystyle{ \alpha_0 = \sum_{i=1}^K \alpha_i. }[/math] The [math]\displaystyle{ \alpha_i/\alpha_0 }[/math] values specify the mean lengths of the cut pieces of string resulting from the distribution. The variance around this mean varies inversely with [math]\displaystyle{ \alpha_0 }[/math].

Example of Dirichlet(1/2,1/3,1/6) distribution

Pólya's urn

Consider an urn containing balls of K different colors. Initially, the urn contains α1 balls of color 1, α2 balls of color 2, and so on. Now perform N draws from the urn, where after each draw, the ball is placed back into the urn with an additional ball of the same color. In the limit as N approaches infinity, the proportions of different colored balls in the urn will be distributed as Dir(α1,...,αK).[20]

For a formal proof, note that the proportions of the different colored balls form a bounded [0,1]K-valued martingale, hence by the martingale convergence theorem, these proportions converge almost surely and in mean to a limiting random vector. To see that this limiting vector has the above Dirichlet distribution, check that all mixed moments agree.

Each draw from the urn modifies the probability of drawing a ball of any one color from the urn in the future. This modification diminishes with the number of draws, since the relative effect of adding a new ball to the urn diminishes as the urn accumulates increasing numbers of balls.


Random variate generation

From gamma distribution

With a source of Gamma-distributed random variates, one can easily sample a random vector [math]\displaystyle{ x=(x_1, \ldots, x_K) }[/math] from the K-dimensional Dirichlet distribution with parameters [math]\displaystyle{ (\alpha_1, \ldots, \alpha_K) }[/math] . First, draw K independent random samples [math]\displaystyle{ y_1, \ldots, y_K }[/math] from Gamma distributions each with density

[math]\displaystyle{ \operatorname{Gamma}(\alpha_i, 1) = \frac{y_i^{\alpha_i-1} \; e^{-y_i}}{\Gamma (\alpha_i)}, \! }[/math]

and then set

[math]\displaystyle{ x_i = \frac{y_i}{\sum_{j=1}^K y_j}. }[/math]
[Proof]

The joint distribution of the independently sampled gamma variates, [math]\displaystyle{ \{y_{i}\} }[/math], is given by the product:

[math]\displaystyle{ e^{-\sum_{i}y_{i}} \prod _{i=1}^{K} \frac{y_{i}^{\alpha _{i}-1}}{\Gamma (\alpha _{i})} }[/math]

Next, one uses a change of variables, parametrising [math]\displaystyle{ \{y_{i}\} }[/math] in terms of [math]\displaystyle{ y_{1}, y_{2}, \ldots , y_{K-1} }[/math] and [math]\displaystyle{ \sum _{i=1}^{K}y_{i} }[/math] , and performs a change of variables from [math]\displaystyle{ y \to x }[/math] such that [math]\displaystyle{ \bar x = \textstyle\sum_{i=1}^{K}y_{i}, x_{1} = \frac{y_{1}}{\bar x}, x_{2} = \frac{y_{2}}{\bar x}, \ldots , x_{K-1} = \frac{y_{K-1}}{\bar x} }[/math]. Each of the variables [math]\displaystyle{ 0 \leq x_{1}, x_{2}, \ldots , x_{k-1} \leq 1 }[/math] and likewise [math]\displaystyle{ 0 \leq \textstyle\sum _{i=1}^{K-1}x_{i} \leq 1 }[/math]. One must then use the change of variables formula, [math]\displaystyle{ P(x) = P(y(x))\bigg|\frac{\partial y}{\partial x}\bigg| }[/math] in which [math]\displaystyle{ \bigg|\frac{\partial y}{\partial x}\bigg| }[/math] is the transformation Jacobian. Writing y explicitly as a function of x, one obtains [math]\displaystyle{ y_{1} = \bar xx_{1}, y_{2} = \bar xx_{2} \ldots y_{K-1} = \bar xx_{K-1}, y_{K} = \bar x(1-\textstyle\sum_{i=1}^{K-1}x_{i}) }[/math] The Jacobian now looks like

[math]\displaystyle{ \begin{vmatrix}\bar x & 0 & \ldots & x_{1} \\ 0 & \bar x & \ldots & x_{2} \\ \vdots & \vdots & \ddots & \vdots \\ -\bar x & -\bar x & \ldots & 1-\sum_{i=1}^{K-1}x_{i} \end{vmatrix} }[/math]

The determinant can be evaluated by noting that it remains unchanged if multiples of a row are added to another row, and adding each of the first K-1 rows to the bottom row to obtain

[math]\displaystyle{ \begin{vmatrix}\bar x & 0 & \ldots & x_{1} \\ 0 & \bar x & \ldots & x_{2} \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \ldots & 1 \end{vmatrix} }[/math]

which can be expanded about the bottom row to obtain the determinant value [math]\displaystyle{ \bar x^{K-1} }[/math]. Substituting for x in the joint pdf and including the Jacobian determinant, one obtains:

[math]\displaystyle{ \begin{align} &\frac{\left[\prod _{i=1}^{K-1}(\bar xx_{i})^{\alpha _{i}-1} \right] \left[\bar x(1-\sum_{i=1}^{K-1}x_{i})\right]^{\alpha_{K}-1}}{\prod _{i=1}^{K}\Gamma (\alpha _{i})}\bar x^{K-1}e^{-\bar x} \\ =&\frac{\Gamma(\bar\alpha)\left[\prod _{i=1}^{K-1}(x_{i})^{\alpha _{i}-1} \right] \left[1-\sum_{i=1}^{K-1}x_{i}\right]^{\alpha_{K}-1}}{\prod _{i=1}^{K}\Gamma (\alpha _{i})}\times\frac{\bar x^{\bar\alpha_i-1}e^{-\bar x}}{\Gamma(\bar\alpha)} \end{align} }[/math]

where [math]\displaystyle{ \bar\alpha=\textstyle\sum_{i=1}^K\alpha_i }[/math]. The right-hand side can be recognized as the product of a Dirichlet pdf for the [math]\displaystyle{ x_i }[/math] and a gamma pdf for [math]\displaystyle{ \bar x }[/math]. The product form shows the Dirichlet and gamma variables are independent, so the latter can be integrated out by simply omitting it, to obtain:

[math]\displaystyle{ x_{1}, x_{2}, \ldots, x_{K-1} \sim \frac{(1-\sum_{i=1}^{K-1}x_{i})^{\alpha _{K}-1}\prod _{i=1}^{K-1}x_{i}^{\alpha _{i} -1}}{B(\boldsymbol{\alpha})} }[/math]

Which is equivalent to

[math]\displaystyle{ \frac{\prod _{i=1}^{K} x_{i}^{\alpha_{i}-1}}{B(\boldsymbol{\alpha})} }[/math] with support [math]\displaystyle{ \sum_{i=1}^{K}x_{i}=1 }[/math]

Below is example Python code to draw the sample:

params = [a1, a2, ..., ak]
sample = [random.gammavariate(a, 1) for a in params]
sample = [v / sum(sample) for v in sample]

This formulation is correct regardless of how the Gamma distributions are parameterized (shape/scale vs. shape/rate) because they are equivalent when scale and rate equal 1.0.

From marginal beta distributions

A less efficient algorithm[21] relies on the univariate marginal and conditional distributions being beta and proceeds as follows. Simulate [math]\displaystyle{ x_1 }[/math] from

[math]\displaystyle{ \textrm{Beta}\left(\alpha_1, \sum_{i=2}^K \alpha_i \right) }[/math]

Then simulate [math]\displaystyle{ x_2, \ldots, x_{K-1} }[/math] in order, as follows. For [math]\displaystyle{ j=2, \ldots, K-1 }[/math], simulate [math]\displaystyle{ \phi_j }[/math] from

[math]\displaystyle{ \textrm{Beta} \left(\alpha_j, \sum_{i=j+1}^K \alpha_i \right ), }[/math]

and let

[math]\displaystyle{ x_j= \left(1-\sum_{i=1}^{j-1} x_i \right )\phi_j. }[/math]

Finally, set

[math]\displaystyle{ x_K=1-\sum_{i=1}^{K-1} x_i. }[/math]

This iterative procedure corresponds closely to the "string cutting" intuition described above.

Below is example Python code to draw the sample:

params = [a1, a2, ..., ak]
xs = [random.betavariate(params[0], sum(params[1:]))]
for j in range(1, len(params) - 1):
    phi = random.betavariate(params[j], sum(params[j + 1 :]))
    xs.append((1 - sum(xs)) * phi)
xs.append(1 - sum(xs))

When each alpha is 1

When α1 = ... = αK = 1, a sample from the distribution can be found by randomly drawing a set of K − 1 values independently and uniformly from the interval [0, 1], adding the values 0 and 1 to the set to make it have K + 1 values, sorting the set, and computing the difference between each pair of order-adjacent values, to give x1, ..., xK.

When each alpha is 1/2 and relationship to the hypersphere

When α1 = ... = αK = 1/2, a sample from the distribution can be found by randomly drawing K values independently from the standard normal distribution, squaring these values, and normalizing them by dividing by their sum, to give x1, ..., xK.

A point (x1, ..., xK) can be drawn uniformly at random from the (K−1)-dimensional hypersphere (which is the surface of a K-dimensional hyperball) via a similar procedure. Randomly draw K values independently from the standard normal distribution and normalize these coordinate values by dividing each by the constant that is the square root of the sum of their squares.

See also

References

  1. S. Kotz; N. Balakrishnan; N. L. Johnson (2000). Continuous Multivariate Distributions. Volume 1: Models and Applications. New York: Wiley. ISBN 978-0-471-18387-7.  (Chapter 49: Dirichlet and Inverted Dirichlet Distributions)
  2. Olkin, Ingram; Rubin, Herman (1964). "Multivariate Beta Distributions and Independence Properties of the Wishart Distribution". The Annals of Mathematical Statistics 35 (1): 261–269. doi:10.1214/aoms/1177703748. 
  3. 3.0 3.1 "Introduction to the Dirichlet Distribution and Related Processes" (Technical Report UWEETR-2010-006). University of Washington Department of Electrical Engineering. 2010. https://www.ee.washington.edu/techsite/papers/documents/UWEETR-2010-0006.pdf. 
  4. Eq. (49.9) on page 488 of Kotz, Balakrishnan & Johnson (2000). Continuous Multivariate Distributions. Volume 1: Models and Applications. New York: Wiley.
  5. BalakrishV. B. (2005). ""Chapter 27. Dirichlet Distribution"". A Primer on Statistical Distributions. Hoboken, NJ: John Wiley & Sons, Inc.. p. 274. ISBN 978-0-471-42798-8. https://archive.org/details/primeronstatisti0000bala/page/274. 
  6. Hoffmann, Till. "Moments of the Dirichlet distribution". https://tillahoffmann.github.io/Moments-of-the-Dirichlet-distribution/. 
  7. Christopher M. Bishop (17 August 2006). Pattern Recognition and Machine Learning. Springer. ISBN 978-0-387-31073-2. https://books.google.com/books?id=kTNoQgAACAAJ. 
  8. Farrow, Malcolm. "MAS3301 Bayesian Statistics". Newcastle University. http://www.mas.ncl.ac.uk/~nmf16/teaching/mas3301/week6.pdf. 
  9. Lin, Jiayu (2016). On The Dirichlet Distribution. Kingston, Canada: Queen's University. pp. § 2.4.9. https://mast.queensu.ca/~communications/Papers/msc-jiayu-lin.pdf. 
  10. Nguyen, Duy. "AN IN DEPTH INTRODUCTION TO VARIATIONAL BAYES NOTE". https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4541076. 
  11. Song, Kai-Sheng (2001). "Rényi information, loglikelihood, and an intrinsic distribution measure". Journal of Statistical Planning and Inference (Elsevier) 93 (325): 51–69. doi:10.1016/S0378-3758(00)00169-5. 
  12. Nemenman, Ilya; Shafee, Fariel; Bialek, William (2002). "Entropy and Inference, revisited". NIPS 14. http://papers.nips.cc/paper/1965-entropy-and-inference-revisited.pdf. , eq. 8
  13. Connor, Robert J.; Mosimann, James E (1969). "Concepts of Independence for Proportions with a Generalization of the Dirichlet Distribution". Journal of the American Statistical Association (American Statistical Association) 64 (325): 194–206. doi:10.2307/2283728. 
  14. See Kotz, Balakrishnan & Johnson (2000), Section 8.5, "Connor and Mosimann's Generalization", pp. 519–521.
  15. Phillips, P. C. B. (1988). "The characteristic function of the Dirichlet and multivariate F distribution". Cowles Foundation Discussion Paper 865. https://cowles.yale.edu/sites/default/files/files/pub/d08/d0865.pdf. 
  16. Grinshpan, A. Z. (2017). "An inequality for multiple convolutions with respect to Dirichlet probability measure". Advances in Applied Mathematics 82 (1): 102–119. doi:10.1016/j.aam.2016.08.001. 
  17. 17.0 17.1 Devroye, Luc (1986). Non-Uniform Random Variate Generation. Springer-Verlag. ISBN 0-387-96305-7. http://luc.devroye.org/rnbookindex.html. 
  18. Lefkimmiatis, Stamatios; Maragos, Petros; Papandreou, George (2009). "Bayesian Inference on Multiscale Models for Poisson Intensity Estimation: Applications to Photon-Limited Image Denoising". IEEE Transactions on Image Processing 18 (8): 1724–1741. doi:10.1109/TIP.2009.2022008. PMID 19414285. Bibcode2009ITIP...18.1724L. 
  19. Andreoli, Jean-Marc (2018). "A conjugate prior for the Dirichlet distribution". arXiv:1811.05266 [cs.LG].
  20. Blackwell, David; MacQueen, James B. (1973). "Ferguson distributions via Polya urn schemes". Ann. Stat. 1 (2): 353–355. doi:10.1214/aos/1176342372. 
  21. A. Gelman; J. B. Carlin; H. S. Stern; D. B. Rubin (2003). Bayesian Data Analysis (2nd ed.). Chapman & Hall/CRC. pp. 582. ISBN 1-58488-388-X. https://archive.org/details/bayesiandataanal00gelm. 

External links