Thesupport of the Dirichlet distribution is the set ofK-dimensional vectorsx whose entries are real numbers in the interval [0,1] such that, i.e. the sum of the coordinates is equal to 1. These can be viewed as the probabilities of aK-waycategorical event. Another way to express this is that the domain of the Dirichlet distribution is itself a set ofprobability distributions, specifically the set ofK-dimensionaldiscrete distributions. The technical term for the set of points in the support of aK-dimensional Dirichlet distribution is theopenstandard(K − 1)-simplex,[3] which is a generalization of atriangle, embedded in the next-higher dimension. For example, withK = 3, the support is anequilateral 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.
A common special case is thesymmetric Dirichlet distribution, where all of the elements making up the parameter vectorα 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 theconcentration parameter. In terms ofα, the density function has the form
Whenα = 1,[1] the symmetric Dirichlet distribution is equivalent to a uniform distribution over the openstandard(K−1)-simplex, i.e. it is uniform over all points in itssupport. This particular distribution is known as theflat Dirichlet distribution. Values of the concentration parameter above 1 prefervariates 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.
Whenα = 1/2, the distribution is the same as would be obtained by choosing a point uniformly at random from the surface of a(K−1)-dimensionalunit hypersphere and squaring each coordinate. Theα = 1/2 distribution is theJeffreys prior for the Dirichlet distribution.
More generally, the parameter vector is sometimes written as the product of a (scalar)concentration parameterα and a (vector)base measure wheren lies within the(K − 1)-simplex (i.e.: its coordinates sum to one). The concentration parameter in this case is larger by a factor ofK than the concentration parameter for a symmetric Dirichlet distribution described above. This construction ties in with concept of a base measure when discussingDirichlet 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 parameterK, the dimension of the distribution, is the uniform distribution on the(K − 1)-simplex.
More generally, moments of Dirichlet-distributed random variables can be expressed in the following way. For, denote by itsi-thHadamard power. Then,[6]
The Dirichlet distribution is theconjugate prior distribution of thecategorical distribution (a genericdiscrete probability distribution with a given number of possible outcomes) andmultinomial 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 theprior distribution of the distribution's parameter (the vector of probabilities that generates the data point) is distributed as a Dirichlet, then theposterior 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
then the following holds:
This relationship is used inBayesian statistics to estimate the underlying parameterp of acategorical distribution given a collection ofN samples. Intuitively, we can view thehyperprior vectorα aspseudocounts, 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 vectorc) in order to derive the posterior distribution.
The following formula for can be used to derive the differentialentropy above. Since the functions are the sufficient statistics of the Dirichlet distribution, theexponential family differential identities can be used to get an analytic expression for the expectation of (see equation (2.62) in[12]) and its associated covariance matrix:
and the information entropy is the limit as goes to 1.
Another related interesting measure is the entropy of a discrete categorical (one-of-K binary) vectorZ with probability-mass distributionX, i.e.,. The conditionalinformation entropy ofZ, givenX is
This function ofX is a scalar random variable. IfX has a symmetric Dirichlet distribution with all, the expected value of the entropy (innat units) is[14]
If, then the vector X is said to beneutral[16] in the sense thatXK is independent of[3] where
and similarly for removing any of. Observe that any permutation ofX is also neutral (a property not possessed by samples drawn from ageneralized Dirichlet distribution).[17]
Combining this with the property of aggregation it follows thatXj + ... +XK is independent of. In fact it is true, further, for the Dirichlet distribution, that for, the pair, and the two vectors and, viewed as triple of normalised random vectors, aremutually independent. The analogous result is true for partition of the indices{1, 2, ...,K} into any other pair of non-singleton subsets.
The sum is over non-negative integers and. Phillips goes on to state that this form is "inconvenient for numerical calculation" and gives an alternative in terms of acomplex path integral:
whereL denotes any path in the complex plane originating at, encircling in the positive direction all the singularities of the integrand and returning to.
Probability density function plays a key role in a multifunctional inequality which implies various bounds for the Dirichlet distribution.[19]
Another inequality relates the moment-generating function of the Dirichlet distribution to the convex conjugate of the scaled reversed Kullback-Leibler divergence:[20]
where the supremum is taken overp spanning the(K − 1)-simplex.
Although theXis are not independent from one another, they can be seen to be generated from a set ofK independentgamma random variables.[21]: 594 Unfortunately, since the sumV is lost in formingX (in fact it can be shown thatV is stochastically independent ofX), 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.
Here is aK-dimensional real vector and is a scalar parameter. The domain of is restricted to the set of parameters for which the above unnormalized density function can be normalized. The (necessary and sufficient) condition is:[23]
The conjugation property can be expressed as
if [prior:] and [observation:] then [posterior:].
In the published literature there is no practical algorithm to efficiently generate samples from.
Generalization by scaling and translation of log-probabilities
As noted above, Dirichlet variates can be generated by normalizing independentgamma variates. If instead one normalizesgeneralized gamma variates, one obtains variates from the simplicial generalized beta distribution (SGB).[24] On the other hand, SGB variates can also be obtained by applying thesoftmax function to scaled and translated logarithms of Dirichlet variates. Specifically, let and let, where applying the logarithm elementwise:orwhere and, with all, then. The SGB density function can be derived by noting that the transformation, which is abijection from the simplex to itself, induces adifferential volume change factor[25] of:where it is understood that is recovered as a function of, as shown above. This facilitates writing the SGB density in terms of the Dirichlet density, as:This generalization of the Dirichlet density, via achange of variables, is closely related to anormalizing flow, while it must be noted that the differential volume change is not given by theJacobian determinant of which is zero, but by the Jacobian determinant of, as explained in more detail atNormalizing flow § Simplex flow.
When, then the transformation simplifies to, which is known astemperature scaling inmachine learning, where it is used as a calibration transform for multiclass probabilistic classifiers.[26] Traditionally the temperature parameter ( here) is learntdiscriminatively by minimizing multiclasscross-entropy over a supervised calibration data set with known class labels. But the above PDF transformation mechanism can be used to facilitate also the design ofgeneratively trained calibration models with a temperature scaling component.
Inference over hierarchical Bayesian models is often done usingGibbs sampling, and in such a case, instances of the Dirichlet distribution are typicallymarginalized out of the model by integrating out the Dirichletrandom variable. This causes the various categorical variables drawn from the same Dirichlet random variable to become correlated, and the joint distribution over them assumes aDirichlet-multinomial distribution, conditioned on the hyperparameters of the Dirichlet distribution (theconcentration parameters). One of the reasons for doing this is that Gibbs sampling of theDirichlet-multinomial distribution is extremely easy; see that article for more information.
Dirichlet distributions are very often used asprior distributions inBayesian 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 theconcentration parameter. If the sample space of the Dirichlet distribution is interpreted as adiscrete 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 theconcentration parameter for further discussion.
One example use of the Dirichlet distribution is if one wanted to cut strings (each of initial length 1.0) intoK 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 The values specify the mean lengths of the cut pieces of string resulting from the distribution. The variance around this mean varies inversely with.
Consider an urn containing balls ofK different colors. Initially, the urn containsα1 balls of color 1,α2 balls of color 2, and so on. Now performN 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 asN approaches infinity, the proportions of different colored balls in the urn will be distributed asDir(α1, ...,αK).[27]
For a formal proof, note that the proportions of the different colored balls form a bounded[0,1]K-valuedmartingale, hence by themartingale convergence theorem, these proportions convergealmost surely andin mean to a limiting random vector. To see that this limiting vector has the above Dirichlet distribution, check that all mixedmoments 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.
With a source of Gamma-distributed random variates, one can easily sample a random vector from theK-dimensional Dirichlet distribution with parameters . First, drawK independent random samples fromGamma distributions each with density
and then set
[Proof]
The joint distribution of the independently sampled gamma variates,, is given by the product:
Next, one uses a change of variables, parametrising in terms of and , and performs a change of variables from such that. Each of the variables and likewise. One must then use the change of variables formula, in which is the transformation Jacobian. Writing y explicitly as a function of x, one obtainsThe Jacobian now looks like
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
which can be expanded about the bottom row to obtain the determinant value. Substituting for x in the joint pdf and including the Jacobian determinant, one obtains:
where. The right-hand side can be recognized as the product of a Dirichlet pdf for the and a gamma pdf for. The product form shows the Dirichlet and gamma variables are independent, so the latter can be integrated out by simply omitting it, to obtain:
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.
Whenα1 = ... =αK = 1, a sample from the distribution can be found by randomly drawing a set ofK − 1 values independently and uniformly from the interval[0, 1], adding the values0 and1 to the set to make it haveK + 1 values, sorting the set, and computing the difference between each pair of order-adjacent values, to givex1, ...,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 drawingK values independently from the standard normal distribution, squaring these values, and normalizing them by dividing by their sum, to givex1, ...,xK.
A point(x1, ...,xK) can be drawn uniformly at random from the (K−1)-dimensional unit hypersphere (which is the surface of aK-dimensionalhyperball) via a similar procedure. Randomly drawK 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.
^S. Kotz; N. Balakrishnan; N. L. Johnson (2000).Continuous Multivariate Distributions. Volume 1: Models and Applications. New York: Wiley.ISBN978-0-471-18387-7. (Chapter 49: Dirichlet and Inverted Dirichlet Distributions)
^Song, Kai-Sheng (2001). "Rényi information, loglikelihood, and an intrinsic distribution measure".Journal of Statistical Planning and Inference.93 (325). Elsevier:51–69.doi:10.1016/S0378-3758(00)00169-5.
^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.64 (325). American Statistical Association:194–206.doi:10.2307/2283728.JSTOR2283728.
^See Kotz, Balakrishnan & Johnson (2000), Section 8.5, "Connor and Mosimann's Generalization", pp. 519–521.