• Descriptive
    • Moments
    • Concentration
    • Central Tendency
    • Variability
    • Stem-and-Leaf Plot
    • Histogram & Frequency Table
    • Data Quality Forensics
    • Conditional EDA
    • Quantiles
    • Kernel Density Estimation
    • Normal QQ Plot
    • Bootstrap Plot

    • Multivariate Descriptive Statistics
  • Distributions
    • Binomial Probabilities
    • Geometric Probabilities
    • Negative Binomial Probabilities
    • Hypergeometric Probabilities
    • Multinomial Probabilities
    • Dirichlet
    • Poisson Probabilities

    • Exponential
    • Gamma
    • Erlang
    • Weibull
    • Rayleigh
    • Maxwell-Boltzmann
    • Lognormal
    • Pareto
    • Inverse Gamma
    • Inverse Chi-Square

    • Beta
    • Power
    • Beta Prime (Inv. Beta)
    • Triangular

    • Normal (area)
    • Logistic
    • Laplace
    • Cauchy (standard)
    • Cauchy (location-scale)
    • Gumbel
    • Fréchet
    • Generalized Extreme Value

    • Normal RNG
    • ML Fitting
    • Tukey Lambda PPCC
    • Box-Cox Normality Plot
    • Noncentral t
    • Noncentral F
    • Sample Correlation r

    • Empirical Tests
  • Hypotheses
    • Theoretical Aspects of Hypothesis Testing
    • Bayesian Inference
    • Minimum Sample Size

    • Empirical Tests
    • Multivariate (pair-wise) Testing
  • Models
    • Manual Model Building
    • Guided Model Building
  • Time Series
    • Time Series Plot
    • Decomposition
    • Exponential Smoothing

    • Blocked Bootstrap Plot
    • Mean Plot
    • (P)ACF
    • VRM
    • Standard Deviation-Mean Plot
    • Spectral Analysis
    • ARIMA

    • Cross Correlation Function
    • Granger Causality
  1. Probability Distributions
  2. 44  Dirichlet Distribution
  • Preface
  • Getting Started
    • 1  Introduction
    • 2  Why Do We Need Innovative Technology?
    • 3  Basic Definitions
    • 4  The Big Picture: Why We Analyze Data
  • Introduction to Probability
    • 5  Definitions of Probability
    • 6  Jeffreys’ axiom system
    • 7  Bayes’ Theorem
    • 8  Sensitivity and Specificity
    • 9  Naive Bayes Classifier
    • 10  Law of Large Numbers

    • 11  Problems
  • Probability Distributions
    • 12  Bernoulli Distribution
    • 13  Binomial Distribution
    • 14  Geometric Distribution
    • 15  Negative Binomial Distribution
    • 16  Hypergeometric Distribution
    • 17  Multinomial Distribution
    • 18  Poisson Distribution

    • 19  Uniform Distribution (Rectangular Distribution)
    • 20  Normal Distribution (Gaussian Distribution)
    • 21  Gaussian Naive Bayes Classifier
    • 22  Chi Distribution
    • 23  Chi-squared Distribution (1 parameter)
    • 24  Chi-squared Distribution (2 parameters)
    • 25  Student t-Distribution
    • 26  Fisher F-Distribution
    • 27  Exponential Distribution
    • 28  Lognormal Distribution
    • 29  Gamma Distribution
    • 30  Beta Distribution
    • 31  Weibull Distribution
    • 32  Pareto Distribution
    • 33  Inverse Gamma Distribution
    • 34  Rayleigh Distribution
    • 35  Erlang Distribution
    • 36  Logistic Distribution
    • 37  Laplace Distribution
    • 38  Gumbel Distribution
    • 39  Cauchy Distribution
    • 40  Triangular Distribution
    • 41  Power Distribution
    • 42  Beta Prime Distribution
    • 43  Sample Correlation Distribution
    • 44  Dirichlet Distribution
    • 45  Generalized Extreme Value (GEV) Distribution
    • 46  Frechet Distribution
    • 47  Noncentral t Distribution
    • 48  Noncentral F Distribution
    • 49  Inverse Chi-Squared Distribution
    • 50  Maxwell-Boltzmann Distribution
    • 51  Distribution Relationship Map

    • 52  Problems
  • Descriptive Statistics & Exploratory Data Analysis
    • 53  Types of Data
    • 54  Datasheets

    • 55  Frequency Plot (Bar Plot)
    • 56  Frequency Table
    • 57  Contingency Table
    • 58  Binomial Classification Metrics
    • 59  Confusion Matrix
    • 60  ROC Analysis

    • 61  Stem-and-Leaf Plot
    • 62  Histogram
    • 63  Data Quality Forensics
    • 64  Quantiles
    • 65  Central Tendency
    • 66  Variability
    • 67  Skewness & Kurtosis
    • 68  Concentration
    • 69  Notched Boxplot
    • 70  Scatterplot
    • 71  Pearson Correlation
    • 72  Rank Correlation
    • 73  Partial Pearson Correlation
    • 74  Simple Linear Regression
    • 75  Moments
    • 76  Quantile-Quantile Plot (QQ Plot)
    • 77  Normal Probability Plot
    • 78  Probability Plot Correlation Coefficient Plot (PPCC Plot)
    • 79  Box-Cox Normality Plot
    • 80  Kernel Density Estimation
    • 81  Bivariate Kernel Density Plot
    • 82  Conditional EDA: Panel Diagnostics
    • 83  Bootstrap Plot (Central Tendency)
    • 84  Survey Scores Rank Order Comparison
    • 85  Cronbach Alpha

    • 86  Equi-distant Time Series
    • 87  Time Series Plot (Run Sequence Plot)
    • 88  Mean Plot
    • 89  Blocked Bootstrap Plot (Central Tendency)
    • 90  Standard Deviation-Mean Plot
    • 91  Variance Reduction Matrix
    • 92  (Partial) Autocorrelation Function
    • 93  Periodogram & Cumulative Periodogram

    • 94  Problems
  • Hypothesis Testing
    • 95  Normal Distributions revisited
    • 96  The Population
    • 97  The Sample
    • 98  The One-Sided Hypothesis Test
    • 99  The Two-Sided Hypothesis Test
    • 100  When to use a one-sided or two-sided test?
    • 101  What if \(\sigma\) is unknown?
    • 102  The Central Limit Theorem (revisited)
    • 103  Statistical Test of the Population Mean with known Variance
    • 104  Statistical Test of the Population Mean with unknown Variance
    • 105  Statistical Test of the Variance
    • 106  Statistical Test of the Population Proportion
    • 107  Statistical Test of the Standard Deviation \(\sigma\)
    • 108  Statistical Test of the difference between Means -- Independent/Unpaired Samples
    • 109  Statistical Test of the difference between Means -- Dependent/Paired Samples
    • 110  Statistical Test of the difference between Variances -- Independent/Unpaired Samples

    • 111  Hypothesis Testing for Research Purposes
    • 112  Decision Thresholds, Alpha, and Confidence Levels
    • 113  Bayesian Inference for Decision-Making
    • 114  One Sample t-Test
    • 115  Skewness & Kurtosis Tests
    • 116  Paired Two Sample t-Test
    • 117  Wilcoxon Signed-Rank Test
    • 118  Unpaired Two Sample t-Test
    • 119  Unpaired Two Sample Welch Test
    • 120  Two One-Sided Tests (TOST) for Equivalence
    • 121  Mann-Whitney U test (Wilcoxon Rank-Sum Test)
    • 122  Bayesian Two Sample Test
    • 123  Median Test based on Notched Boxplots
    • 124  Chi-Squared Tests for Count Data
    • 125  Kolmogorov-Smirnov Test
    • 126  One Way Analysis of Variance (1-way ANOVA)
    • 127  Kruskal-Wallis Test
    • 128  Two Way Analysis of Variance (2-way ANOVA)
    • 129  Repeated Measures ANOVA
    • 130  Friedman Test
    • 131  Testing Correlations
    • 132  A Note on Causality

    • 133  Problems
  • Regression Models
    • 134  Simple Linear Regression Model (SLRM)
    • 135  Multiple Linear Regression Model (MLRM)
    • 136  Logistic Regression
    • 137  Generalized Linear Models
    • 138  Multinomial and Ordinal Logistic Regression
    • 139  Cox Proportional Hazards Regression
    • 140  Conditional Inference Trees
    • 141  Leaf Diagnostics for Conditional Inference Trees
    • 142  Conditional Random Forests
    • 143  Hypothesis Testing with Linear Regression Models (from a Practical Point of View)

    • 144  Problems
  • Introduction to Time Series Analysis
    • 145  Case: the Market of Health and Personal Care Products
    • 146  Decomposition of Time Series
    • 147  Ad hoc Forecasting of Time Series
  • Box-Jenkins Analysis
    • 148  Introduction to Box-Jenkins Analysis
    • 149  Theoretical Concepts
    • 150  Stationarity
    • 151  Identifying ARMA parameters
    • 152  Estimating ARMA Parameters and Residual Diagnostics
    • 153  Forecasting with ARIMA models
    • 154  Intervention Analysis
    • 155  Cross-Correlation Function
    • 156  Transfer Function Noise Models
    • 157  General-to-Specific Modeling
  • Model Building Strategies
    • 158  Introduction to Model Building Strategies
    • 159  Manual Model Building
    • 160  Model Validation
    • 161  Regularization Methods
    • 162  Hyperparameter Optimization Strategies
    • 163  Guided Model Building in Practice
    • 164  Diagnostics, Revision, and Guided Forecasting
    • 165  Leakage, Target Encoding, and Robust Regression
  • References
  • Appendices
    • Appendices
    • A  Method Selection Guide
    • B  Presentations and Teaching Materials
    • C  R Language Concepts for Statistical Computing
    • D  Matrix Algebra
    • E  Standard Normal Table (Gaussian Table)
    • F  Critical values of Student’s \(t\) distribution with \(\nu\) degrees of freedom
    • G  Upper-tail critical values of the \(\chi^2\)-distribution with \(\nu\) degrees of freedom
    • H  Lower-tail critical values of the \(\chi^2\)-distribution with \(\nu\) degrees of freedom

Table of contents

  • 44.1 Probability Density Function
  • 44.2 Purpose
  • 44.3 Moment Generating Function
  • 44.4 Expected Value
  • 44.5 Variance
  • 44.6 Covariance
  • 44.7 Mode
  • 44.8 Parameter Estimation
  • 44.9 R Module
    • 44.9.1 RFC
    • 44.9.2 Direct app link
    • 44.9.3 R Code
  • 44.10 Example
  • 44.11 Property 1: Marginals are Beta
  • 44.12 Property 2: Aggregation Property
  • 44.13 Property 3: Conjugate Prior for Multinomial
  • 44.14 Related Distributions 1: Beta Distribution
  • 44.15 Related Distributions 2: Multinomial Distribution
  • 44.16 Related Distributions 3: Uniform on the Simplex
  1. Probability Distributions
  2. 44  Dirichlet Distribution

44  Dirichlet Distribution

The Dirichlet distribution is the multivariate generalization of the Beta distribution. It is a probability distribution over the \((K-1)\)-simplex — the set of \(K\)-dimensional vectors whose components are non-negative and sum to one. The Dirichlet distribution arises naturally as the conjugate prior for the Multinomial distribution in Bayesian inference.

Formally, a random vector \(\mathbf{X} = (X_1, \ldots, X_K)\) is said to follow a Dirichlet distribution (i.e. \(\mathbf{X} \sim \text{Dir}(\boldsymbol{\alpha})\)) with concentration parameters \(\alpha_1, \ldots, \alpha_K > 0\) if the components satisfy \(X_i \geq 0\) and \(\sum_{i=1}^K X_i = 1\).

44.1 Probability Density Function

\[ f(\mathbf{x}; \boldsymbol{\alpha}) = \frac{\Gamma\!\left(\sum_{i=1}^K \alpha_i\right)}{\prod_{i=1}^K \Gamma(\alpha_i)} \prod_{i=1}^K x_i^{\alpha_i - 1}, \quad \mathbf{x} \in S_K \]

where \(S_K = \{\mathbf{x} \in \mathbb{R}^K : x_i \geq 0,\, \sum x_i = 1\}\) is the \(K\)-simplex.

The figure below shows the Dirichlet density on the 3-simplex (ternary plot) for different concentration parameter configurations.

Code
dirichlet_density <- function(x, alpha) {
  x <- as.matrix(x)
  log_const <- lgamma(sum(alpha)) - sum(lgamma(alpha))
  exp(log_const + rowSums(sweep(log(x), 2, alpha - 1, `*`)))
}

draw_simplex <- function(alpha, title_text) {
  vals <- seq(0.02, 0.96, length.out = 50)
  pts <- do.call(rbind, lapply(vals, function(x1) {
    x2 <- vals[vals < 0.98 - x1]
    if (!length(x2)) return(NULL)
    x3 <- 1 - x1 - x2
    keep <- x3 > 0.02
    if (!any(keep)) return(NULL)
    cbind(x1 = x1, x2 = x2[keep], x3 = x3[keep])
  }))
  if (is.null(pts)) return()
  dens <- dirichlet_density(pts, alpha)
  tri_x <- c(0, 1, 0.5, 0)
  tri_y <- c(0, 0, sqrt(3)/2, 0)
  plot(tri_x, tri_y, type = "n", asp = 1, axes = FALSE, ann = FALSE,
       xlim = c(-0.05, 1.05), ylim = c(-0.05, 0.92), main = title_text)
  polygon(tri_x, tri_y, border = "#2c3e50", lwd = 2, col = "grey98")
  px <- pts[, 2] + 0.5 * pts[, 3]
  py <- (sqrt(3)/2) * pts[, 3]
  pal <- colorRampPalette(c("#f7fbff", "#74a9cf", "#0570b0", "#08306b"))(100)
  z <- log(pmax(dens, 1e-300))
  idx <- cut(z, breaks = 100, include.lowest = TRUE, labels = FALSE)
  points(px, py, pch = 15, cex = 0.7, col = pal[idx])
}

par(mfrow = c(2, 2), mar = c(1, 1, 3, 1))
draw_simplex(c(2, 2, 2), expression(alpha == "(2, 2, 2)"))
draw_simplex(c(5, 5, 5), expression(alpha == "(5, 5, 5)"))
draw_simplex(c(0.5, 0.5, 0.5), expression(alpha == "(0.5, 0.5, 0.5)"))
draw_simplex(c(10, 2, 1), expression(alpha == "(10, 2, 1)"))
par(mfrow = c(1, 1))
Figure 44.1: Dirichlet density heatmaps on the 3-simplex for different concentration parameters

44.2 Purpose

The Dirichlet distribution models uncertainty over compositions — vectors of proportions that must sum to one. Common applications include:

  • Bayesian analysis with categorical or multinomial data (as the conjugate prior)
  • Topic modeling (Latent Dirichlet Allocation), where topic proportions follow a Dirichlet
  • Compositional data analysis: market shares, diet proportions, soil composition, alloy mixtures
  • Election forecasting: modeling vote share distributions across parties
  • Bayesian A/B/C testing: posterior probabilities over conversion rates for multiple variants

44.3 Moment Generating Function

The Dirichlet distribution does not have a standard moment generating function, but its moments are well known and given below.

44.4 Expected Value

\[ \text{E}(X_i) = \frac{\alpha_i}{\alpha_0}, \quad \alpha_0 = \sum_{j=1}^K \alpha_j \]

44.5 Variance

\[ \text{V}(X_i) = \frac{\alpha_i(\alpha_0 - \alpha_i)}{\alpha_0^2(\alpha_0 + 1)} \]

44.6 Covariance

\[ \text{Cov}(X_i, X_j) = -\frac{\alpha_i \alpha_j}{\alpha_0^2(\alpha_0 + 1)}, \quad i \neq j \]

44.7 Mode

When all \(\alpha_i > 1\):

\[ \text{Mo}(X_i) = \frac{\alpha_i - 1}{\alpha_0 - K} \]

When any \(\alpha_i \leq 1\), the density concentrates at simplex boundaries (corners or edges) and the mode lies on the boundary of the simplex.

44.8 Parameter Estimation

The maximum likelihood estimators for \(\boldsymbol{\alpha}\) have no closed form and require iterative methods (e.g., Newton-Raphson on the log-likelihood). A method-of-moments estimator uses:

\[ \tilde{\alpha}_0 = \frac{\bar{x}_1(1 - \bar{x}_1)}{s_1^2} - 1, \qquad \tilde{\alpha}_i = \tilde{\alpha}_0 \bar{x}_i \]

set.seed(42)
alpha_true <- c(3, 5, 2)
n <- 200
x <- t(replicate(n, {
  g <- rgamma(3, shape = alpha_true)
  g / sum(g)
}))
xbar <- colMeans(x)
s2 <- apply(x, 2, var)
alpha0_hat <- xbar[1] * (1 - xbar[1]) / s2[1] - 1
alpha_hat <- alpha0_hat * xbar
cat("MoM alpha:", round(alpha_hat, 3), "\n")
cat("True alpha:", alpha_true, "\n")
MoM alpha: 2.947 4.682 2.001 
True alpha: 3 5 2 

44.9 R Module

44.9.1 RFC

The Dirichlet Distribution module is available in RFC under the menu Distributions / Dirichlet Distribution.

44.9.2 Direct app link

  • https://shiny.wessa.net/dirichlet/

44.9.3 R Code

alpha <- c(3, 5, 2)
alpha0 <- sum(alpha)

# Expected values
cat("E(X):", alpha / alpha0, "\n")

# Variances
cat("Var(X):", alpha * (alpha0 - alpha) / (alpha0^2 * (alpha0 + 1)), "\n")

# Mode (all alpha > 1)
cat("Mode:", (alpha - 1) / (alpha0 - length(alpha)), "\n")

# Generate random Dirichlet samples via Gamma
set.seed(42)
g <- matrix(rgamma(10 * length(alpha), shape = rep(alpha, each = 10)), ncol = length(alpha))
x <- g / rowSums(g)
round(head(x), 4)
E(X): 0.3 0.5 0.2 
Var(X): 0.01909091 0.02272727 0.01454545 
Mode: 0.2857143 0.5714286 0.1428571 
       [,1]   [,2]   [,3]
[1,] 0.3482 0.5234 0.1283
[2,] 0.1765 0.7130 0.1105
[3,] 0.2782 0.7090 0.0127
[4,] 0.1470 0.7749 0.0781
[5,] 0.2080 0.6041 0.1879
[6,] 0.2243 0.4201 0.3557

44.10 Example

A market analyst models the share of three brands using a Dirichlet prior with \(\boldsymbol{\alpha} = (3, 5, 2)\). After observing 30 purchases with counts \((12, 14, 4)\), the posterior is \(\text{Dir}(15, 19, 6)\).

prior <- c(3, 5, 2)
counts <- c(12, 14, 4)
posterior <- prior + counts

cat("Prior mean:", round(prior / sum(prior), 4), "\n")
cat("Posterior mean:", round(posterior / sum(posterior), 4), "\n")
cat("Observed proportions:", round(counts / sum(counts), 4), "\n")
Prior mean: 0.3 0.5 0.2 
Posterior mean: 0.375 0.475 0.15 
Observed proportions: 0.4 0.4667 0.1333 
Interactive Shiny app (click to load).
Open in new tab

44.11 Property 1: Marginals are Beta

Each marginal \(X_i\) follows a Beta distribution:

\[ X_i \sim \text{Beta}(\alpha_i,\; \alpha_0 - \alpha_i) \]

See Chapter 30.

44.12 Property 2: Aggregation Property

Merging categories preserves the Dirichlet: if \(\mathbf{X} \sim \text{Dir}(\alpha_1, \ldots, \alpha_K)\) and we define \(Y = X_1 + X_2\), then \((Y, X_3, \ldots, X_K) \sim \text{Dir}(\alpha_1 + \alpha_2, \alpha_3, \ldots, \alpha_K)\).

44.13 Property 3: Conjugate Prior for Multinomial

If \(\boldsymbol{\theta} \sim \text{Dir}(\boldsymbol{\alpha})\) is the prior on category probabilities and \(\mathbf{n} = (n_1, \ldots, n_K)\) are observed multinomial counts, then the posterior is:

\[ \boldsymbol{\theta} \mid \mathbf{n} \sim \text{Dir}(\alpha_1 + n_1, \ldots, \alpha_K + n_K) \]

See Chapter 17 and Chapter 113.

44.14 Related Distributions 1: Beta Distribution

The Dirichlet with \(K = 2\) reduces to the Beta distribution: \(\text{Dir}(\alpha_1, \alpha_2) = \text{Beta}(\alpha_1, \alpha_2)\). See Chapter 30.

44.15 Related Distributions 2: Multinomial Distribution

The Dirichlet is the conjugate prior for the Multinomial distribution. See Chapter 17.

44.16 Related Distributions 3: Uniform on the Simplex

When all \(\alpha_i = 1\), the Dirichlet reduces to the Uniform distribution on the simplex.

43  Sample Correlation Distribution
45  Generalized Extreme Value (GEV) Distribution

© 2026 Patrick Wessa. Provided as-is, without warranty.

Feedback: e-mail | Anonymous contributions: click to copy (Sats) | click to copy (XMR)

Cookie Preferences