Dirichlet distribution (source code)

= Dirichlet distribution
{c}
{title2=$\operatorname{Dir}(\alpha_1,\ldots,\alpha_K)$}
{wiki}

For $K\geq2$ and parameters $\alpha_i>0$, the <Dirichlet distribution> is a <probability distribution> on the <probability simplex> $p_i\geq0$, $\sum_{i=1}^Kp_i=1$. With $\alpha_0=\sum_i\alpha_i$, its <probability density function> in coordinates $p_1,\ldots,p_{K-1}$, with $p_K=1-\sum_{i<K}p_i$, is
$$
f(p)=\frac{\Gamma(\alpha_0)}{\prod_i\Gamma(\alpha_i)}\prod_i p_i^{\alpha_i-1}
$$
on the simplex interior. This is a <probability density function>[density] relative to $dp_1\cdots dp_{K-1}$, not to $K$-dimensional <Lebesgue measure>, for which the simplex has zero <volume>.<SciPy Reference: scipy.stats.dirichlet>[Notes: positive parameters, simplex support and multivariate beta normalizer]{ref}

For $K=2$, the first coordinate has the <beta distribution> with parameters $\alpha_1,\alpha_2$. For $K=3$ and all parameters one, the coordinate triangle has area $1/2$ and <probability density function>[density] $2$, giving the uniform law in those coordinates. More generally, <independent> <gamma distributions> with shapes $\alpha_i$ and a common rate can be normalized by their sum to generate a Dirichlet <vector>. The <expected value> of $p_i$ is $\alpha_i/\alpha_0$; the parameters describe both average proportions and their concentration, rather than allowing the coordinates to vary independently.