Dirichlet distribution

Dirichlet Distribution
Probability density function

Parameters K \geq 2 number of categories (integer)
\alpha_1, \cdots, \alpha_K concentration parameters, where \alpha_i > 0
Support x_1, \cdots, x_K where x_i \in (0,1) and \sum_{i=1}^K x_i = 1
PDF \frac{1}{\mathrm{B}(\boldsymbol\alpha)} \prod_{i=1}^K x_i^{\alpha_i - 1}
where \mathrm{B}(\boldsymbol\alpha) = \frac{\prod_{i=1}^K \Gamma(\alpha_i)}{\Gamma\bigl(\sum_{i=1}^K \alpha_i\bigr)}
where \boldsymbol\alpha=(\alpha_1,\ldots,\alpha_K)
Mean \operatorname{E}[X_i] = \frac{\alpha_i}{\sum_k \alpha_k}
 \operatorname{E}[\ln X_i] = \psi(\alpha_i)-\psi(\textstyle\sum_k \alpha_k)
(see digamma function)
Mode x_i = \frac{\alpha_i - 1}{\sum_{k=1}^K\alpha_k - K}, \quad \alpha_i > 1.
Variance \mathrm{Var}[X_i] = \frac{\alpha_i (\alpha_0-\alpha_i)}{\alpha_0^2 (\alpha_0+1)},
where \alpha_0 = \sum_{i=1}^K\alpha_i
\mathrm{Cov}[X_i,X_j] = \frac{- \alpha_i \alpha_j}{\alpha_0^2 (\alpha_0+1)}~~(i\neq j)
Entropy  H(X) = \log \mathrm{B}(\alpha) - (K-\alpha_0)\psi(\alpha_0) - \sum_{j=1}^K (\alpha_j-1)\psi(\alpha_j)

In probability and statistics, the Dirichlet distribution (after Peter Gustav Lejeune Dirichlet), often denoted \operatorname{Dir}(\boldsymbol\alpha), is a family of continuous multivariate probability distributions parameterized by a vector \boldsymbol\alpha of positive reals. It is the multivariate generalization of the beta distribution.[1] Dirichlet distributions are very often 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.

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 \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 \left(x_1,\cdots, x_{K}; \alpha_1,\cdots, \alpha_K \right) = \frac{1}{\mathrm{B}(\boldsymbol\alpha)} \prod_{i=1}^K x_i^{\alpha_i - 1},

on the open (K  1)-dimensional simplex defined by:

\begin{align} 
&x_1, \cdots, x_{K-1} > 0 \\
&x_1 + \cdots + x_{K-1} < 1 \\ 
&x_K = 1 - x_1 - \cdots - x_{K-1} 
\end{align}

and zero elsewhere.

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

\mathrm{B}(\boldsymbol\alpha) = \frac{\prod_{i=1}^K \Gamma(\alpha_i)}{\Gamma\left(\sum_{i=1}^K \alpha_i\right)},\qquad\boldsymbol{\alpha}=(\alpha_1,\cdots,\alpha_K).

Support

The support of the Dirichlet distribution is the set of K-dimensional vectors \boldsymbol x whose entries are real numbers in the interval (0,1); furthermore, \|\boldsymbol x\|_1=1, i.e. the sum of the coordinates is 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. Note that the technical term for the set of points in the support of a K-dimensional Dirichlet distribution is the open standard (K−1)-simplex,[2] 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 very common special case is the symmetric Dirichlet distribution, where all of the elements making up the parameter vector \boldsymbol\alpha have the same value. Symmetric Dirichlet distributions are often used when a Dirichlet prior is called for, since there typically is no prior knowledge favoring one component over another. Since all elements of the parameter vector have the same value, the distribution alternatively can be parametrized by a single scalar value α, called the concentration parameter. The density function then simplifies to

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

When α=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 \alpha \boldsymbol n of a (scalar) concentration parameter α and a (vector) base measure \boldsymbol n=(n_1,\dots,n_K) where \boldsymbol n lies within the (K−1)-simplex (i.e.: its coordinates n_i 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 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-\sum_{i=1}^{K-1}X_i.

Let

\alpha_0 = \sum_{i=1}^K\alpha_i.

Then[3][4]

 \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)}.

Furthermore, if  i\neq j

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

Note that the matrix so defined is singular.

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

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}\left(\alpha_{i}+\beta_{i}\right)\right]}\times\prod_{i=1}^{K}\frac{\Gamma\left(\alpha_{i}+\beta_{i}\right)}{\Gamma\left(\alpha_{i}\right)}.

Mode

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

 x_i = \frac{\alpha_i - 1}{\alpha_0 - K}, \qquad \alpha_i > 1.

Marginal distributions

The marginal distributions are beta distributions:[7]

X_i \sim \operatorname{Beta}\left (\alpha_i, \left(\sum\nolimits_{j=1}^K{\alpha_j}\right) - \alpha_i \right).

Conjugate to categorical/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

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

then the following holds:

\begin{array}{rcccl}
\mathbf{c} &=& \left(c_1, \cdots, 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,\cdots,c_K+\alpha_K \right)
\end{array}

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 Dir(α) random variable, then the exponential family differential identities can be used to get an analytic expression for the expectation of \log(X_i) and its associated covariance matrix:

 \operatorname{E}[\log(X_i)] = \psi(\alpha_i)-\psi(\alpha_0)

and

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

where \psi is the digamma function, \psi' is the trigamma function, and \delta_{ij} is the Kronecker delta. The formula for  \operatorname{E}[\log(X_i)] yields the following formula for the information entropy of X:

 H(X) = \log \mathrm{B}(\boldsymbol\alpha) + (\alpha_0-K)\psi(\alpha_0) - \sum_{j=1}^K (\alpha_j-1)\psi(\alpha_j)

The spectrum of Rényi information for values other than  \lambda = 1 is given by [8]

F_R(\lambda) = (1-\lambda)^{-1} \left( - \log \mathrm{B}(\alpha) + \sum_{j=1}^K \log \Gamma(\lambda(\alpha_i - 1) + 1) - \log \Gamma(\lambda (\alpha_0 -d)+d ) \right)

and the information entropy is the limit as \lambda goes to 1.

Aggregation

If

X = (X_1, \cdots, X_K)\sim\operatorname{Dir}(\alpha_1,\cdots,\alpha_K)

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

X' = (X_1, \cdots, X_i + X_j, \cdots, X_K)\sim\operatorname{Dir} \left(\alpha_1,\cdots,\alpha_i+\alpha_j,\cdots,\alpha_K \right).

This aggregation property may be used to derive the marginal distribution of X_i mentioned above.

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[9] in the sense that XK is independent of X^{(-K)}[2] where

X^{(-K)}=\left(\frac{X_1}{1-X_K},\frac{X_2}{1-X_K},\cdots,\frac{X_{K-1}}{1-X_K}\right),

and similarly for removing any of 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.)[10]

Characteristic function

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


CF\left(s_1,\ldots,s_{k-1}\right) = \mathbb{E}\left(e^{i\left(s_1x_1+\cdots+s_{k-1}x_{k-1}\right)}\right)=
\Psi^{\left[k-1\right]}
\left(\alpha_1,\ldots,\alpha_k;\alpha;is_1,\ldots is_{k-1}\right)

where


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

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


\Psi^{\left[m\right]} = \frac{\Gamma(c)}{2\pi i}\int_Le^t\,t^{a_1+\cdots+a_m-c}\,\prod_{j=1}^m\left(t-z_j\right)^{-a_j}\,dt

where L denotes any path in the complex plane originating at -\infty, encircling in the positive direction all the singularities of the integrand and returning to -\infty.

Related distributions

For K independently distributed Gamma distributions:

 Y_1 \sim \operatorname{Gamma}(\alpha_1, \theta), \cdots, Y_K \sim \operatorname{Gamma}(\alpha_K, \theta)

we have:[12]:402

V=\sum_{i=1}^K Y_i\sim\operatorname{Gamma} \left(\sum_{i=1}^K\alpha_i, \theta \right ),
X = (X_1, \cdots, X_K) = \left(\frac{Y_1}{V}, \cdots, \frac{Y_K}{V} \right)\sim \operatorname{Dir}\left (\alpha_1, \cdots, \alpha_K \right).

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.[12]: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.

Applications

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. (Note that in many fields, such as in natural language processing, categorical variables are often imprecisely called "multinomial variables". Such a usage is liable to cause confusion, just as if Bernoulli distributions and binomial distributions were 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.

Random number generation

Gamma distribution

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

 \textrm{Gamma}(\alpha_i, 1) = \frac{y_i^{\alpha_i-1} \; e^{-y_i}}{\Gamma (\alpha_i)}, \!

and then set

x_i = \frac{y_i}{\sum_{j=1}^K y_j}.

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.

Marginal beta distributions

A less efficient algorithm[13] relies on the univariate marginal and conditional distributions being beta and proceeds as follows. Simulate x_1 from

\textrm{Beta}\left(\alpha_1, \sum_{i=2}^K \alpha_i \right)

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

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

and let

x_j= \left(1-\sum_{i=1}^{j-1} x_i \right )\phi_j.

Finally, set

x_K=1-\sum_{i=1}^{K-1} x_i.

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

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))

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 a sample from a Dirichlet distribution is likely to be. 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. 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. 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.

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).[14]

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.

Note that 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. This "diminishing returns" effect can also help explain how small α values yield Dirichlet distributions with most of the probability mass concentrated around a single point on the simplex.

See also

References

  1. S. Kotz, N. Balakrishnan, and N. L. Johnson (2000). Continuous Multivariate Distributions. Volume 1: Models and Applications. New York: Wiley. ISBN 0-471-18387-3. (Chapter 49: Dirichlet and Inverted Dirichlet Distributions)
  2. 1 2 Bela A. Frigyik, Amol Kapila, and Maya R. Gupta (2010). "Introduction to the Dirichlet Distribution and Related Processes" (Technical Report UWEETR-2010-006). University of Washington Department of Electrical Engineering. Retrieved May 2012.
  3. Eq. (49.9) on page 488 of Kotz, Balakrishnan & Johnson (2000). Continuous Multivariate Distributions. Volume 1: Models and Applications. New York: Wiley.
  4. 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.
  5. Hoffmann, Till. "Moments of the Dirichlet distribution". Retrieved 13 September 2014.
  6. Christopher M. Bishop (17 August 2006). Pattern Recognition and Machine Learning. Springer. ISBN 978-0-387-31073-2.
  7. Farrow, Malcolm. "MAS3301 Bayesian Statistics" (PDF). Newcastle University. Newcastle University. Retrieved 10 April 2013.
  8. 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.
  9. 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. JSTOR 2283728.
  10. See Kotz, Balakrishnan & Johnson (2000), Section 8.5, "Connor and Mosimann's Generalization", pp. 519–521.
  11. P. C. B. Phillips 1988. "The characteristic function of the Dirichlet and multivariate F distribution", Cowles Foundation discussion paper 985
  12. 1 2 Devroye, Luc (1986). Non-Uniform Random Variate Generation. Springer-Verlag. ISBN 0-387-96305-7.
  13. A. Gelman and J. B. Carlin and H. S. Stern and D. B. Rubin (2003). Bayesian Data Analysis (2nd ed.). p. 582. ISBN 1-58488-388-X.
  14. Blackwell, David; MacQueen, James B. (1973). "Ferguson distributions via Polya urn schemes". Ann. Stat. 1 (2): 353–355. doi:10.1214/aos/1176342372.

External links

This article is issued from Wikipedia - version of the Monday, April 25, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.