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

Mixture Distributions

Real data often come from several sources mixed together: ground and obstacle returns in lidar, normal and faulty sensor readings, multiple modes of a robot's possible poses. A mixture distribution is 'pick a component, then sample it'. Its moments follow total expectation and variance, Bayes' theorem says which component produced each point, EM fits it by alternating those two steps, and BIC chooses how many components to use. Heavy-tailed distributions are themselves continuous mixtures of Gaussians.

Level 0: Foundation

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

Several sources mixed together

A bin holds bolts from two factories. Factory A’s average 10 g and factory B’s average 14 g. Weigh many bolts and the histogram has two bumps. The weights follow a mixture distribution: first “which factory?”, then “how heavy?”.

Given one bolt weighing 13.8 g, which factory probably made it? That’s Bayes’ theorem again. Turning it around, if you only see the bolts, you can still work out the two factories’ shares and averages. That’s the job of the EM algorithm.

Mixtures: pick a component, then sample it, and fit them with EM
component 1
component 2
component 3
responsibilities at x = 2.60: P(comp 1 | x) = 0.000 P(comp 2 | x) = 0.376 P(comp 3 | x) = 0.624
mean 0.100 · variance = within 0.660 + between 5.490 = 6.150
Thick: the mixture density. Thin: weighted components. Ticks: 200 of the 400 samples used for EM. Orange dashed: the EM fit, which starts from a rough guess. EM alternates "which component made each point?" (Bayes, the responsibilities) with "refit each component to its share of the points" (weighted MLE).
Why engineers care

A lidar beam returns from the ground, from an obstacle, or from dust. A sensor is usually healthy but sometimes faulty. A lost robot might be in one of three similar corridors. Each is a mixture, and separating the components is how you detect obstacles, flag faults and localize.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Half the bolts average 10 g and half 14 g. The overall average?
  2. 2. Two well-separated bumps in a histogram suggest…
  3. 3. A 13.8 g bolt most likely came from…

Level 1: Beginner

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

Definition

A finite mixture with weights wk≥0w_k\ge0, ∑wk=1\sum w_k = 1, and component densities fkf_k has density

f(x)=∑k=1Kwkfk(x)f(x) = \sum_{k=1}^Kw_kf_k(x)

Generative story: draw a latent label z∼Categorical(w)z\sim\text{Categorical}(\mathbf w), then x∣z=k∼fkx\mid z = k\sim f_k. This is ancestral sampling. A Gaussian mixture model (GMM) uses fk=N(μk,σk2)f_k = \mathcal N(\mu_k, \sigma_k^2).

Moments (A4.1-8):

  • EX=∑wkμk\mathbb E X = \sum w_k\mu_k;
  • Var⁡X=∑wkσk2⏟within+∑wk(μk−μˉ)2⏟between\operatorname{Var}X = \underbrace{\sum w_k\sigma_k^2}_{\text{within}} + \underbrace{\sum w_k(\mu_k - \bar\mu)^2}_{\text{between}}.

Responsibilities (A4.1-3): rk(x)=P(z=k∣x)=wkfk(x)∑jwjfj(x)r_k(x) = P(z = k\mid x) = \frac{w_kf_k(x)}{\sum_jw_jf_j(x)}.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Mixture 0.3·N(−1, 0.5²) + 0.7·N(2, 1²): mean?
  2. 2. Responsibilities are computed with…
  3. 3. A mixture's variance includes a between term that is…

Level 2: Intermediate

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

Fitting mixtures: the EM algorithm

If you knew each point’s label, fitting would be easy: just compute per-component means and variances. You don’t, so alternate (Dempster, Laird and Rubin, 1977):

  1. E-step. Compute responsibilities rik=P(zi=k∣xi)r_{ik} = P(z_i = k\mid x_i) under the current parameters.
  2. M-step. Re-estimate each component as a weighted MLE: wk=1n∑irikw_k = \frac1n\sum_ir_{ik}, μk=∑rikxi∑rik\mu_k = \frac{\sum r_{ik}x_i}{\sum r_{ik}}, σk2=∑rik(xi−μk)2∑rik\sigma_k^2 = \frac{\sum r_{ik}(x_i - \mu_k)^2}{\sum r_{ik}}.

The log-likelihood never decreases. EM converges to a local maximum, so use several random starts. Watch out for degenerate solutions where a component collapses onto one point (σ→0\sigma\to0, likelihood →∞\to\infty). A variance floor or a prior prevents this.

How many components?

More components always fit the training data better. BIC =−2log⁡L^+plog⁡n= -2\log\hat L + p\log n penalizes the p=3K−1p = 3K - 1 parameters (1-D GMM) and usually picks a sensible KK. Alternatives are held-out likelihood and Dirichlet-process mixtures (A4.2-3).

Mixtures are everywhere

  • Multimodality: a robot that can’t tell which of three identical corridors it’s in has a three-bump belief. A single Gaussian can’t represent it, but a mixture (or a particle filter) can.
  • Outlier models: (1−ϵ)N(0,σ2)+ϵ⋅broad(1 - \epsilon)\mathcal N(0, \sigma^2) + \epsilon\cdot\text{broad} is the standard “inlier + outlier” sensor model.
  • Continuous mixtures: a normal whose variance is drawn from an inverse-gamma is a Student-t (Practice Code 5). A Poisson whose rate is gamma-distributed is a negative binomial (A4.2-5).
🐍 Exercise 1: mixture density, sampling, moments and responsibilities
Implement a 3-component Gaussian mixture: its density, ancestral sampling, mean and variance by total variance, and responsibilities by Bayes. Check it integrates to 1, has three modes, and that the moments match simulation.
📝 Quick check (Level 2)
0/3 answered
  1. 1. EM's E-step computes…
  2. 2. Can EM's log-likelihood decrease between iterations?
  3. 3. A 1-D GMM with K = 3 has how many free parameters?

Level 3: Advanced

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

Why EM never goes down

For any distribution q(z)q(z) over the latent labels, Jensen’s inequality gives a lower bound:

log⁡p(x∣θ)=log⁡∑zq(z)p(x,z∣θ)q(z) ≥ ∑zq(z)log⁡p(x,z∣θ)q(z)=:L(q,θ)\log p(x\mid\theta) = \log\sum_zq(z)\frac{p(x,z\mid\theta)}{q(z)}\ \ge\ \sum_zq(z)\log\frac{p(x,z\mid\theta)}{q(z)} =: \mathcal L(q,\theta)

The gap is KL⁡(q ∥ p(z∣x,θ))\operatorname{KL}(q\,\|\,p(z\mid x,\theta)).

  1. E-step. Setting q=p(z∣x,θt)q = p(z\mid x,\theta_t) makes the bound tight.
  2. M-step. Maximizing L\mathcal L over θ\theta can only raise it.
  3. Result. log⁡p(x∣θt+1)≥L(q,θt+1)≥L(q,θt)=log⁡p(x∣θt)\log p(x\mid\theta_{t+1})\ge\mathcal L(q,\theta_{t+1})\ge\mathcal L(q,\theta_t) = \log p(x\mid\theta_t). ∎

The same evidence lower bound (ELBO) is what variational autoencoders maximize (Kingma and Welling, 2014).

Identifiability and label switching

Permuting the component labels gives the same mixture, so there are K!K! equivalent parameter settings. Compare fitted components only after sorting them, for example by mean. Bayesian MCMC for mixtures must handle this explicitly.

Student-t as a Gaussian scale mixture

If τ∼Gamma(ν/2,rate ν/2)\tau\sim\text{Gamma}(\nu/2, \text{rate }\nu/2) and x∣τ∼N(0,1/τ)x\mid\tau\sim\mathcal N(0, 1/\tau), then x∼tνx\sim t_\nu. Integrating out τ\tau gives ∝(1+x2/ν)−(ν+1)/2\propto(1 + x^2/\nu)^{-(\nu+1)/2}. This is why t-based robust estimators can be fitted with EM. The E-step’s expected precision E[τ∣x]=ν+1ν+x2\mathbb E[\tau\mid x] = \frac{\nu+1}{\nu + x^2} is exactly the IRLS weight from A4.2-2.

Exercise 3.1: Prove the mixture-variance formula

Apply the law of total variance with Y=zY = z: E[Var⁡(X∣z)]=∑wkσk2\mathbb E[\operatorname{Var}(X\mid z)] = \sum w_k\sigma_k^2 and Var⁡(E[X∣z])=∑wk(μk−μˉ)2\operatorname{Var}(\mathbb E[X\mid z]) = \sum w_k(\mu_k - \bar\mu)^2.

📝 Quick check (Level 3)
0/3 answered
  1. 1. EM's monotonicity comes from…
  2. 2. How many label permutations does a K = 3 mixture have?
  3. 3. The t-distribution's E-step weight is…

Level 4: Expert

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

Fitting a lidar range mixture with EM

Ranges measured along one lidar beam over time mix returns from the ground, from a nearby pole, and spurious near-field returns (dust, rain). That’s a 3-component mixture. EM recovers each component’s weight, location and spread from unlabelled ranges, and BIC confirms three components. Thrun, Burgard and Fox (2005) build the standard beam sensor model from mixtures like this: hit, short return, max range and random. Background subtraction in vision fits a per-pixel GMM (Stauffer and Grimson, 1999), and anomaly detection flags points with low mixture likelihood.

🐍 Exercise 2 (research): EM and BIC on lidar ranges
Implement EM for a 1-D Gaussian mixture from scratch. Fit 3000 simulated lidar ranges (ground, pole, spurious returns), verify that the log-likelihood never decreases, recover the components, and use BIC (best of several starts) to choose K.

Mixtures in AI, robotics and aerospace

  • Multi-hypothesis estimation. Gaussian-sum filters and multiple-model trackers (IMM; Blom and Bar-Shalom, 1988) represent beliefs as Gaussian mixtures. They’re used for manoeuvring targets and for spacecraft whose thruster mode is unknown.
  • Mixture density networks output mixture parameters, so a network can predict several plausible outcomes. Examples are where a pedestrian might go, or which grasp might work (Bishop, 1994; Ha and Schmidhuber, 2018).
  • Mixture-of-experts layers route each input to a few specialist subnetworks with learned gating weights, which scales large models efficiently (Jacobs et al., 1991; Shazeer et al., 2017).
  • Behaviour cloning with multimodal actions. Averaging two valid demonstrations, like going left or right around an obstacle, gives a collision. Mixture or diffusion policies keep the modes separate (Chi et al., 2023).

References

  1. A. Dempster, N. Laird, D. Rubin (1977). “Maximum likelihood from incomplete data via the EM algorithm.” JRSS B, 39(1).
  2. G. McLachlan, D. Peel (2000). Finite Mixture Models. Wiley.
  3. G. Schwarz (1978). “Estimating the dimension of a model.” Annals of Statistics, 6(2). (BIC.)
  4. S. Thrun, W. Burgard, D. Fox (2005). Probabilistic Robotics, Ch. 6. MIT Press.
  5. C. Stauffer, W. E. L. Grimson (1999). “Adaptive background mixture models for real-time tracking.” CVPR.
  6. H. Blom, Y. Bar-Shalom (1988). “The interacting multiple model algorithm for systems with Markovian switching coefficients.” IEEE Transactions on Automatic Control, 33(8).
  7. C. Bishop (1994). Mixture Density Networks. Aston University Technical Report NCRG/94/004.
  8. R. Jacobs, M. Jordan, S. Nowlan, G. Hinton (1991). “Adaptive mixtures of local experts.” Neural Computation, 3(1).
  9. N. Shazeer et al. (2017). “Outrageously large neural networks: the sparsely-gated mixture-of-experts layer.” ICLR.
  10. C. Chi et al. (2023). “Diffusion policy: visuomotor policy learning via action diffusion.” RSS.