Speaker diarization (who-spoke-when)
Each speaker's voice fingerprint is one component of a GMM over MFCC features. EM separates the speakers without labels.
Name things for the reader, not the writer.
Name things for the reader, not the writer.
Gaussian Mixture Models
A Gaussian Mixture Model (GMM) assumes the data is generated by K underlying clusters, each Gaussian with its own mean and covariance: p(mathbf{x}) = sum_{k=1}^{K} pi_k\, mathcal{N}(mathbf{x}; boldsymbolmu_k, Sigma_k), where pi_k geq 0 and sum_k pi_k = 1 are mixture weights. GMMs are *soft-clusterin
GMM: โ a soft-clustering density model.
A Gaussian Mixture Model (GMM) assumes the data is generated by underlying clusters, each Gaussian with its own mean and covariance: where and are mixture weights. GMMs are *soft-clustering* โ each point has a probability of belonging to each cluster, not a hard label. They generalize -means (which is roughly a GMM with shared spherical covariances) and are the go-to tool for density estimation and model-based clustering.
Fitting a GMM by maximum likelihood is hard: the log-likelihood has no closed-form maximum because of the . Enter the Expectation-Maximization (EM) algorithm โ an iterative procedure that monotonically increases the likelihood by alternating two steps. EM is the workhorse for any model with latent variables.
The E-step computes, for each point and cluster , the responsibility (posterior probability of cluster given the point under current parameters): Responsibilities are soft cluster assignments โ if a point clearly belongs to cluster 3, ; if it lies between clusters 1 and 2, it splits mass between them.
The M-step updates the parameters to maximize the expected complete-data log-likelihood, using the responsibilities as weights: These are exactly the weighted sample mean, weighted sample covariance, and weighted sample proportion. The closed-form update is the payoff for introducing latent variables.
EM is guaranteed to monotonically increase the likelihood and converges to a local maximum. Initialization matters: random starts can land in poor local optima, so -means++ seeding is common. Singularities also lurk โ if a Gaussian collapses to a single point, its variance and likelihood . Regularize by adding to each covariance or by Bayesian priors. Beyond GMMs, EM trains HMMs, latent Dirichlet allocation, factor analysis, and countless other latent-variable models.
Worked example โ one EM iteration on 1D data: Data , initialize with . E-step: for , , , so . By symmetry . M-step (cluster 1): , . The mean snapped to the left cluster's empirical average.
Python (in browser)
Expected: Means cluster near [0,0], [5,1], [2,5]
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
Each speaker's voice fingerprint is one component of a GMM over MFCC features. EM separates the speakers without labels.
Fit a GMM to normal traffic. New points with very low density under the mixture are flagged. Used in fraud detection, intrusion detection.
Each pixel's intensity over time is modeled as a GMM; new frames whose pixels fall in low-probability components become foreground.
VAEs train an encoder + decoder by maximizing the ELBO, the same lower bound EM uses โ just with continuous latents and amortized inference.
Put your understanding to the test. Score + streak + speed all count.
3 quick questions. Get 2 right to mark this lesson complete.