Gaussian Mixture & EM
A Gaussian mixture model explains data as k overlapping Gaussian bells, each with its own weight, mean and covariance, and fits them with the EM algorithm. Pick a preset — well-separated, overlapping, or elongated diagonal clusters — or click to add points, choose k and a covariance type (full or spherical), and step through EM: the E-step blends every point’s colour by its responsibilities (soft membership probabilities), and the M-step slides the mean markers and reshapes the 1σ and 2σ ellipses to match the weighted data. A mini-chart tracks the log-likelihood rising monotonically until convergence. On the elongated preset, flip the k-means comparison toggle to see hard, round assignments slice the tilted clusters apart while full-covariance EM hugs them.
Runs 100% in your browser — models are trained and computed locally on your device.
Read the full guide to this tool
Notes
- E-step: responsibility rᵢₖ = πₖ N(xᵢ | μₖ, Σₖ) / Σⱼ πⱼ N(xᵢ | μⱼ, Σⱼ). M-step: each weight, mean and covariance is re-estimated from the data weighted by those responsibilities.
- Every EM iteration provably increases (or keeps) the log-likelihood, so the curve is monotone — but only to a local maximum, and the answer depends on the initialization, just like k-means.
- k-means is the limit of EM with spherical covariances shrunk to zero: responsibilities harden to nearest-mean assignment. Full covariances are what let GMM fit tilted, elongated clusters.
- A component can collapse onto a single point, sending the likelihood to infinity; this demo adds a small regularizer to each covariance diagonal to prevent that.
- Runs 100% in your browser — models are trained and computed locally on your device.