Foundations to Frontier
Tests
A. Mathematical Foundations › A4 Probability Theory › Distributions

Dirichlet and Wishart Distributions

Some uncertain quantities are not numbers but whole probability vectors or whole covariance matrices. The Dirichlet is a distribution over probability vectors on the simplex. Its components are betas and its conjugate update is 'add the counts', which is where add-one smoothing comes from. The Wishart is the distribution of Gaussian scatter matrices, and its inverse is the standard prior on covariances. It keeps few-sample covariance estimates sane in filters and Bayesian models.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Uncertain about the chances themselves

Is this die fair? You don’t know the six chances (one per face), so they’re uncertain too. A distribution over whole lists of chances that always add up to 1 is a Dirichlet distribution. Its parameters act like imaginary counts you’ve already seen. Every real roll adds one to the count for its face.

Engineers also need uncertainty about how noisy a sensor is, and about how its errors in different directions are related (a covariance matrix). The Wishart family describes random covariance matrices.

Distributions over probability vectors and over covariance matrices
observe a category: counts = (0, 0, 0)
p₁ = 1p₂ = 1p₃ = 1
posterior Dirichlet(α + n) = (2.0, 2.0, 2.0) · α₀ = 6.0
mean (orange) = (0.333, 0.333, 0.333)
Each dot is a whole probability vector (p₁, p₂, p₃) with Σ = 1. All α's below 1 pile mass in the corners (sparse vectors). Large α's concentrate near the mean. Observing counts just adds them to α: the conjugate update. Watch the cloud shrink.
Why engineers care

A classifier has never seen a rare fault type, so it would assign it probability 0, which is dangerous. Dirichlet “pseudo-counts” keep it possible. A new IMU’s noise covariance must be estimated from only a few calibration samples, and a Wishart-based prior stops the estimate from being nonsense.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A die's six face probabilities add up to…
  2. 2. Seen 7 red, 3 blue; add one imaginary count to each. P(red) = ?
  3. 3. A Wishart distribution describes random…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

The Dirichlet

p∼Dir⁡(α)\mathbf p\sim\operatorname{Dir}(\boldsymbol\alpha) has density Γ(α0)∏Γ(αi)∏ipiαi−1\frac{\Gamma(\alpha_0)}{\prod\Gamma(\alpha_i)}\prod_ip_i^{\alpha_i - 1} on the simplex {pi≥0,∑pi=1}\{p_i\ge0, \sum p_i = 1\}, where α0=∑αi\alpha_0 = \sum\alpha_i.

  • Mean Epi=αi/α0\mathbb E p_i = \alpha_i/\alpha_0 and variance mi(1−mi)α0+1\frac{m_i(1 - m_i)}{\alpha_0 + 1}. A larger α0\alpha_0 means more concentrated.
  • With K=2K = 2 it’s the Beta distribution.
  • Shape: all αi=1\alpha_i = 1 is uniform on the simplex. All αi<1\alpha_i < 1 gives sparse vectors (mass in the corners). Large αi\alpha_i concentrates near the mean.

The Wishart

If x1,…,xn∼N(0,Σ)\mathbf x_1,\dots,\mathbf x_n\sim\mathcal N(\mathbf 0, \Sigma) in dd dimensions, the scatter matrix S=∑xixi⊤S = \sum\mathbf x_i\mathbf x_i^\top is Wishart⁡(Σ,n)\operatorname{Wishart}(\Sigma, n).

  • Its mean is nΣn\Sigma, so S/nS/n is unbiased.
  • With d=1d = 1 it’s σ2χn2\sigma^2\chi^2_n.
  • The inverse-Wishart IW⁡(Ψ,ν)\operatorname{IW}(\Psi, \nu) (the law of S−1S^{-1}, suitably parametrized) is the conjugate prior for a Gaussian covariance.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Dirichlet(2, 6, 2) mean of p₂?
  2. 2. Dirichlet with K = 2 is the…
  3. 3. E[S] for Wishart(Σ, n)?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Constructions and properties

  • Gamma construction: take independent Gi∼G_i\simGamma(αi,1\alpha_i, 1). Then p=G/∑Gi∼Dir⁡(α)\mathbf p = \mathbf G/\sum G_i\sim\operatorname{Dir}(\boldsymbol\alpha). It’s also independent of the total ∑Gi\sum G_i.
  • Marginals: pi∼Beta(αi,α0−αi)p_i\sim\text{Beta}(\alpha_i, \alpha_0 - \alpha_i).
  • Aggregation: merging components adds their α\alpha’s. For example, (p1,p2+p3)∼Dir⁡(α1,α2+α3)(p_1, p_2 + p_3)\sim\operatorname{Dir}(\alpha_1, \alpha_2 + \alpha_3).
  • Conjugacy with the multinomial: prior Dir⁡(α)\operatorname{Dir}(\boldsymbol\alpha) and counts n\mathbf n give posterior Dir⁡(α+n)\operatorname{Dir}(\boldsymbol\alpha + \mathbf n), with posterior mean αi+niα0+N\frac{\alpha_i + n_i}{\alpha_0 + N}. With αi=1\alpha_i = 1, that’s Laplace (add-one) smoothing, so unseen categories keep non-zero probability.

Covariance estimation with few samples

The sample covariance Σ^=S/n\hat\Sigma = S/n is unbiased, but noisy when nn is small. If n<dn < d, it’s singular, so you can’t invert it, as filters and Mahalanobis gates need to. An inverse-Wishart prior IW⁡(Ψ,ν)\operatorname{IW}(\Psi,\nu) gives posterior IW⁡(Ψ+S,ν+n)\operatorname{IW}(\Psi + S, \nu + n) (zero-mean data), with mean

Ψ+Sν+n−d−1\frac{\Psi + S}{\nu + n - d - 1}

That’s a blend of a prior guess and the data, and it’s always positive definite. The same idea in non-Bayesian form is shrinkage (Ledoit and Wolf, 2004).

🐍 Exercise 1: the Dirichlet on the simplex
Sample Dirichlet vectors by normalizing gammas. Check the moments, Beta marginals and aggregation, then apply the conjugate update to see add-one smoothing keep an unseen category possible.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Dir(1,1,1) prior plus counts (7, 0, 3) gives the posterior…
  2. 2. Marginal of p₁ under Dir(2, 5, 3)?
  3. 3. The sample covariance with n < d samples is…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Conjugacy, proved

Prior ∝∏piαi−1\propto\prod p_i^{\alpha_i-1} times multinomial likelihood ∝∏pini\propto\prod p_i^{n_i} gives ∝∏piαi+ni−1\propto\prod p_i^{\alpha_i + n_i - 1}, which is again a Dirichlet kernel. ∎

The Dirichlet mean from the gamma construction

Write Gi=piTG_i = p_iT with T=∑Gj∼T = \sum G_j\simGamma(α0\alpha_0), independent of p\mathbf p (Lukacs’ theorem). Then αi=EGi=Epi ET=Epi α0\alpha_i = \mathbb E G_i = \mathbb E p_i\,\mathbb E T = \mathbb E p_i\,\alpha_0. ∎

Why n<dn < d means singular

S=X⊤XS = X^\top X with X∈Rn×dX\in\mathbb R^{n\times d} has rank ≤n\le n. With fewer samples than dimensions, some directions have zero estimated variance. A filter using Σ^−1\hat\Sigma^{-1} would treat them as perfectly known, which is catastrophic overconfidence.

The Dirichlet process (preview)

Let K→∞K\to\infty with a total concentration α0\alpha_0. You get the Dirichlet process, a prior over distributions with infinitely many possible categories. It’s used in non-parametric mixture models that decide how many clusters the data needs (Ferguson, 1973; A4.2-6).

Exercise 3.1: Show the posterior mean under a symmetric Dir(1) prior is (nᵢ + 1)/(N + K)

The posterior is Dir⁡(1+ni)\operatorname{Dir}(1 + n_i), so its mean is 1+ni∑j(1+nj)=ni+1N+K\frac{1 + n_i}{\sum_j(1 + n_j)} = \frac{n_i + 1}{N + K}.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Dirichlet × multinomial likelihood gives a…
  2. 2. rank(XᵀX) for X ∈ ℝ^(n×d) is at most…
  3. 3. The K → ∞ limit of the Dirichlet is the…

Level 4: Expert

★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.

Bayesian covariance estimation for sensors

A new IMU’s 6-D noise covariance must be estimated from a handful of static calibration windows. The MLE S/nS/n is singular for n<6n < 6 and badly conditioned for small nn. An inverse-Wishart prior centred on a datasheet guess gives a posterior mean that’s always positive definite and much more accurate when samples are scarce. The data take over as nn grows. This is the same idea behind adaptive and variational Kalman filters that learn unknown noise covariances online (Särkkä and Nummenmaa, 2009) and behind Bayesian multivariate regression.

🐍 Exercise 2 (research): Wishart scatter and inverse-Wishart regularization
Check E[S] = nΣ and Var(S₀₁) for Wishart scatter matrices. Then compare the MLE S/n with the inverse-Wishart posterior mean for a 6-D sensor-noise covariance at n = 4, 8 and 30 samples, including the singular n < d case.

Where they appear

  • Topic models and mixtures. In LDA, each document’s topic proportions are Dirichlet, and small α\alpha makes documents focus on few topics (Blei, Ng and Jordan, 2003). Mixture-model weights get Dirichlet priors (A4.2-6).
  • Uncertainty-aware classification. Evidential deep learning outputs Dirichlet parameters, so a network can say “I don’t know” (low α0\alpha_0) rather than only “class 3 with 60%” (Sensoy, Kaplan and Kandemir, 2018).
  • Exploration in RL. Bayesian (Thompson-sampling) agents keep Dirichlet posteriors over transition probabilities of unknown MDPs (Osband, Russo and Van Roy, 2013).
  • Robotics. Inverse-Wishart priors appear in adaptive noise estimation for Kalman filters, in Gaussian-process hyperpriors, and in multi-target tracking’s covariance models.
  • Random-matrix effects. For large dd with d/nd/n not small, the eigenvalues of S/nS/n spread far from Σ’s (Marchenko–Pastur). That’s why shrinkage is essential in high-dimensional covariance estimation.

References

  1. N. Johnson, S. Kotz, N. Balakrishnan (1997). Discrete Multivariate Distributions. Wiley.
  2. J. Wishart (1928). “The generalised product moment distribution in samples from a normal multivariate population.” Biometrika, 20A.
  3. O. Ledoit, M. Wolf (2004). “A well-conditioned estimator for large-dimensional covariance matrices.” Journal of Multivariate Analysis, 88(2).
  4. T. Ferguson (1973). “A Bayesian analysis of some nonparametric problems.” Annals of Statistics, 1(2).
  5. D. Blei, A. Ng, M. Jordan (2003). “Latent Dirichlet allocation.” JMLR, 3.
  6. M. Sensoy, L. Kaplan, M. Kandemir (2018). “Evidential deep learning to quantify classification uncertainty.” NeurIPS.
  7. S. Särkkä, A. Nummenmaa (2009). “Recursive noise adaptive Kalman filtering by variational Bayesian approximations.” IEEE Transactions on Automatic Control, 54(3).
  8. I. Osband, D. Russo, B. Van Roy (2013). “(More) efficient reinforcement learning via posterior sampling.” NeurIPS.
  9. A. Gelman et al. (2013). Bayesian Data Analysis, 3rd ed. CRC Press.