Dirichlet distribution
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
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 RK1 given by
for all x1, ..., xK1 > 0 satisfying x1 + ... + xK1 < 1, where xK is an abbreviation for 1  x1  ...  xK1. 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:

# Properties
Let X = (X_1, \ldots, X_K)\sim\operatorname{Dir}(\alpha), meaning that the first K  1 components have the above density and
Define \textstyle\alpha_0 = \sum_{i=1}^K\alpha_i. Then
in fact, the marginals are  Beta distributions:
Furthermore,
The mode of the distribution is the vector (x1, ..., xK) with
The Dirichlet distribution is conjugate to the multinomial distribution in the following sense: if
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
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 \scriptstyle i\in\{1,2,\ldots,K\},
- 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
and then set

# 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.