Model data as a weighted sum of K Gaussians. Soft clustering, density estimation, and the canonical EM example.
ConceptCore MLFoundations
Published ·9 min read·Role-specific·Intermediate
Visual quick review
Explain how one observation in an overlap region receives nonzero responsibility from multiple Gaussian components and therefore contributes fractionally to each component's M-step update.
Learning objective
Normalize component evidence per point, then refit with fractional observation mass
Read it this way:Choose a component by its mixture weight, then draw from that Gaussian. For observed data, combine each component's density and prior, then normalize across components. Each point still supplies one unit of mass. EM uses these fractional weights to refit component means, covariances, and mixture weights, then recomputes responsibilities. Soft assignment differs from nearest-center clustering. Covariance restrictions, held-out fit, initialization, and collapse prevention remain separate choices. Do three points become six observations during fitting?
Sources and provenance
Full explanation 9 min read
Summary
A Gaussian mixture model assumes data is generated by sampling a component k∈{1,…,K} from a categorical distribution with weights πk and then sampling x∼N(μk,Σk):
p(x)=k=1∑KπkN(x;μk,Σk).
GMMs are the canonical:
Soft clustering algorithm (each point has a posterior responsibility distribution over components, not a hard assignment).
Continuous density estimator with adjustable expressiveness via K.
Building block for HMMs (state emissions), VAEs (mixture priors), and many speech / vision systems.
EM teaching example. The simplest non-trivial latent-variable model with closed-form EM updates.
The latent variable view
Define a one-hot latent z∈{1,…,K} with p(z=k)=πk. Then p(x∣z=k)=N(μk,Σk). Marginalize: p(x)=∑kπkN(x;μk,Σk).
The latent z is what makes GMM a soft-clustering algorithm: posterior p(z=k∣x) tells you how much “responsibility” component k has for x.
Learning objective
An overlap point receives soft responsibility from two Gaussian components
Read it this way: the ellipses show where each component assigns density, not a hard boundary. At x, multiply each density by its prior weight π, then normalize those scores into r₁ and r₂. Because both responsibilities are between zero and one, the same point contributes fractionally to both components' effective counts, means, and covariances. The construction is original and checked against Dempster, Laird, and Rubin (1977), Bishop (2006), and the scikit-learn GaussianMixture documentation.
Check: Why can one observation contribute to both M-step updates without being counted twice at full weight?
Reference drawing
Learning objective
Normalize component evidence per point, then refit with fractional observation mass
Derivation
Read it this way: the ellipses show where each component assigns density, not a hard boundary. At x, multiply each density by its prior weight π, then normalize those scores into r₁ and r₂. Because both responsibilities are between zero and one, the same point contributes fractionally to both components' effective counts, means, and covariances. The construction is original and checked against Dempster, Laird, and Rubin (1977), Bishop (2006), and the scikit-learn GaussianMixture documentation.
Check: Why can one observation contribute to both M-step updates without being counted twice at full weight?
Read it this way:Choose a component by its mixture weight, then draw from that Gaussian. For observed data, combine each component's density and prior, then normalize across components. Each point still supplies one unit of mass. EM uses these fractional weights to refit component means, covariances, and mixture weights, then recomputes responsibilities. Soft assignment differs from nearest-center clustering. Covariance restrictions, held-out fit, initialization, and collapse prevention remain separate choices. Do three points become six observations during fitting?
Training: EM
Initialize πk,μk,Σk (k-means++ for means, identity for covariances). Iterate until log-likelihood stabilizes.
Trade expressiveness for parameter count by restricting Σk:
Form
Parameters per component
Use case
Full
d(d+1)/2
Default; expressive
Diagonal
d
High-d data, fewer parameters
Sphericalσk2I
1
Approximates k-means with soft assignments
Tied (shared across components)
d(d+1)/2 once
Used in linear discriminant analysis
Choosing K
Same problem as k-means. Standard approaches:
Information criteria: BIC (logn⋅params−2logL) or AIC (2⋅params−2logL). Pick K minimizing.
Cross-validation log-likelihood.
Dirichlet process mixture (infinite GMM): non-parametric Bayesian alternative that lets K grow with data.
GMM vs. k-means
Property
k-means
GMM
Cluster shape
Spherical, equal radius
Arbitrary ellipsoid (full Σ)
Assignment
Hard (0/1)
Soft (probability over components)
Parameters
K centroids
K centroids + K covariances + K weights
Compute per iter
O(nKd)
O(nKd2) for full Σ
Soft probabilities
No
Yes
Density estimation
No (Voronoi cells)
Yes
GMM is k-means generalized: k-means = GMM with shared identity covariance, equal weights, and hard assignments.
Use cases
Soft clustering with ellipsoidal clusters.
Density estimation for low-d continuous data.
Anomaly detection: low-likelihood points are anomalies.
Speaker diarization: GMMs over MFCC features (legacy speech).
Background subtraction in video: GMM per pixel.
Mixture of experts gating in neural networks (related but distinct).
For high-dimensional data: pure GMMs struggle (covariance estimation requires O(d2) parameters per component). Use diagonal covariance, dimensionality reduction, or normalizing-flow alternatives.
Common pitfalls
Covariance singularities. A component centered on a single point has Σk→0 and log-likelihood diverges. Add jitter Σk+εI.
Initialization. Random init often gives degenerate clusters; use k-means++ centroids as initial means.
Reading mixture weights as cluster sizes.πk is the prior; effective cluster size is Nk=∑irik.
Comparing GMM and k-means on cluster counts. GMM components and k-means clusters are not directly comparable; soft mass distributes differently.