The EM Algorithm

Suppose you measure the heights of 10,000 people but forget to record their sex. The histogram is visibly bimodal, yet you cannot simply fit one Gaussian. The data are a mixture of two populations. The label telling you which population each point came from is missing. This is the generic problem of learning with latent variables: a model that would be easy to fit if we could see the hidden labels, but hard to fit because we cannot. The Expectation-Maximization (EM) algorithm is the classical answer. It underlies an enormous share of unsupervised learning, from Gaussian Mixture Models to hidden Markov models to missing-data imputation. EM matters because "hard" maximum-likelihood problems with latent structure are everywhere in real systems. Examples include clustering customers into hidden segments, decoding noisy communication channels, filling in missing sensor readings, and training topic models over text corpora. In each case, the log-likelihood of the observed data alone is a messy, non-convex function of the parameters. It often involves a log of a sum. EM turns this into an easy iterative recipe. It alternates between guessing the hidden labels (softly, as probabilities) and then re-fitting the model as if those guesses were true counts. The deep reason EM works — and the reason it deserves a full article rather than a one-line trick — is that it is not really an ad hoc heuristic. It is coordinate ascent on a rigorous lower bound to the log-likelihood, the Evidence Lower Bound (ELBO). Every EM iteration provably never decreases the observed-data log-likelihood. This gives the algorithm a clean convergence guarantee, even though the overall optimization problem is non-convex. This article builds EM from first principles. It covers what latent variables and the ELBO are, and the precise E-step and M-step. It explains why the likelihood increases monotonically, and gives the exact time/space complexity for a Gaussian mixture. It also includes a full numerical trace, and the classic failure modes (singular covariances, bad local optima, label switching). It assumes familiarity with Gaussian Mixture Models and Density Estimation Fundamentals. It also sets up the ideas needed for Anomaly Detection Fundamentals, where mixture densities are used to flag low-probability points.

Key takeaways
  • EM fits models with latent variables by maximizing the observed-data likelihood indirectly, via a lower bound.
  • The E-step computes the posterior distribution over hidden variables given current parameters (soft assignments).
  • The M-step re-estimates parameters by maximizing the expected complete-data log-likelihood under that posterior.
  • Each EM iteration is guaranteed to never decrease the observed log-likelihood — a provable monotonicity property.
  • The bound being optimized is the ELBO; EM is coordinate ascent that alternates tightening the bound (E) and maximizing it (M).
  • EM converges to a stationary point, not necessarily the global optimum — initialization and degeneracies matter a lot in practice.
The core insight

EM replaces a hard maximum-likelihood problem with hidden variables by iteratively maximizing a tight lower bound on the log-likelihood, guaranteeing monotone improvement at every step.

The idea

A latent variable model assumes each observed data point xx is generated together with an unobserved variable zz (a cluster label, a hidden state, a missing feature). The joint density is p(x,z∣θ)p(x, z \mid \theta), and the observed-data likelihood is obtained by marginalizing out zz:

p(x∣θ)=∑zp(x,z∣θ).p(x \mid \theta) = \sum_z p(x, z \mid \theta).

For a KK-component Gaussian mixture, z∈{1,…,K}z \in \{1,\dots,K\} indicates which component generated xx, and p(x∣θ)=∑k=1Kπk N(x∣μk,Σk)p(x \mid \theta) = \sum_{k=1}^K \pi_k \, \mathcal N(x \mid \mu_k, \Sigma_k). If we knew zz for every point, maximum likelihood estimation would be trivial: compute per-cluster means, covariances, and mixing weights in closed form. The difficulty is entirely due to the sum inside the logarithm of the log-likelihood,

ℓ(θ)=∑i=1Nlog⁡∑zip(xi,zi∣θ),\ell(\theta) = \sum_{i=1}^N \log \sum_{z_i} p(x_i, z_i \mid \theta),

which couples all components together and has no closed-form maximizer. EM sidesteps this by introducing, for each data point, a distribution q(zi)q(z_i) over the hidden variable and using Jensen's inequality to build a lower bound on ℓ(θ)\ell(\theta) called the Evidence Lower Bound (ELBO):

ℓ(θ)=∑ilog⁡∑ziq(zi)p(xi,zi∣θ)q(zi)  ≥  ∑i∑ziq(zi)log⁡p(xi,zi∣θ)q(zi)  =  ELBO(q,θ).\ell(\theta) = \sum_i \log \sum_{z_i} q(z_i) \frac{p(x_i, z_i \mid \theta)}{q(z_i)} \;\ge\; \sum_i \sum_{z_i} q(z_i) \log \frac{p(x_i, z_i \mid \theta)}{q(z_i)} \;=\; \mathrm{ELBO}(q, \theta).

The gap between the true log-likelihood and the ELBO is exactly the Kullback–Leibler divergence between q(zi)q(z_i) and the true posterior p(zi∣xi,θ)p(z_i \mid x_i, \theta):

ℓ(θ)−ELBO(q,θ)=∑iKL(q(zi) ∥ p(zi∣xi,θ))≥0.\ell(\theta) - \mathrm{ELBO}(q,\theta) = \sum_i \mathrm{KL}\big(q(z_i)\,\|\,p(z_i\mid x_i,\theta)\big) \ge 0.

This identity is the crux of the whole method. It says the bound is tight exactly when q(zi)=p(zi∣xi,θ)q(z_i) = p(z_i \mid x_i, \theta), and it is this fact that EM exploits by alternating two moves: set qq to the exact posterior (closing the gap — the E-step), then maximize the ELBO over θ\theta with qq fixed (climbing the bound — the M-step). Because the ELBO touches ℓ(θ)\ell(\theta) at the current parameters after the E-step, any improvement of the ELBO in the M-step is an improvement (or at worst no change) of the true log-likelihood too.

How it works

E-step (Expectation). Fix the current parameters θ(t)\theta^{(t)}. For every data point ii, compute the posterior responsibility of each latent value zz:

q(t)(zi):=p(zi∣xi,θ(t))=p(xi,zi∣θ(t))∑zi′p(xi,zi′∣θ(t)).q^{(t)}(z_i) := p(z_i \mid x_i, \theta^{(t)}) = \frac{p(x_i, z_i \mid \theta^{(t)})}{\sum_{z_i'} p(x_i, z_i' \mid \theta^{(t)})}.

For a Gaussian mixture, this is the familiar responsibility

γik=πk(t) N(xi∣μk(t),Σk(t))∑j=1Kπj(t) N(xi∣μj(t),Σj(t)).\gamma_{ik} = \frac{\pi_k^{(t)}\, \mathcal N(x_i \mid \mu_k^{(t)}, \Sigma_k^{(t)})} {\sum_{j=1}^K \pi_j^{(t)}\, \mathcal N(x_i \mid \mu_j^{(t)}, \Sigma_j^{(t)})}.

No parameters are changed in this step; only beliefs about the hidden labels are updated. This closes the KL gap exactly (setting it to zero), so the ELBO now equals the true log-likelihood at θ(t)\theta^{(t)}.

M-step (Maximization). With q(t)q^{(t)} fixed, maximize the ELBO over θ\theta. Since qq does not depend on θ\theta in this step, this reduces to maximizing the expected complete-data log-likelihood:

θ(t+1)=arg⁡max⁡θ  Eq(t)[log⁡p(X,Z∣θ)]=arg⁡max⁡θ∑i∑ziγik log⁡p(xi,zi∣θ).\theta^{(t+1)} = \arg\max_\theta \; \mathbb E_{q^{(t)}}\big[\log p(X, Z \mid \theta)\big] = \arg\max_\theta \sum_i \sum_{z_i} \gamma_{ik}\, \log p(x_i, z_i \mid \theta).

For a Gaussian mixture this maximization is closed-form: it is weighted maximum likelihood, where each point xix_i contributes to cluster kk with weight γik\gamma_{ik}:

Nk=∑iγik,πk=NkN,μk=1Nk∑iγikxi,Σk=1Nk∑iγik(xi−μk)(xi−μk)⊤.N_k = \sum_i \gamma_{ik}, \qquad \pi_k = \frac{N_k}{N}, \qquad \mu_k = \frac{1}{N_k}\sum_i \gamma_{ik} x_i, \qquad \Sigma_k = \frac{1}{N_k}\sum_i \gamma_{ik} (x_i-\mu_k)(x_i-\mu_k)^\top.

These two steps are repeated until the log-likelihood stops improving (by more than a tolerance) or a maximum number of iterations is reached. ``` ALGORITHM EM-for-GMM(X, K, tol, max_iter) Input: data X = {x_1, ..., x_N}, number of components K Output: parameters theta = {pi_k, mu_k, Sigma_k}_{k=1..K} Initialize pi_k, mu_k, Sigma_k for k = 1..K // e.g. via k-means++ seeding prev_ll <- -infinity repeat // ---- E-step: compute responsibilities ---- for i = 1..N: for k = 1..K: num[i][k] <- pi_k Gaussian(x_i | mu_k, Sigma_k) denom <- sum_k num[i][k] for k = 1..K: gamma[i][k] <- num[i][k] / denom // posterior p(z_i=k | x_i, theta) // ---- M-step: re-estimate parameters ---- for k = 1..K: N_k <- sum_i gamma[i][k] pi_k <- N_k / N mu_k <- (1 / N_k) sum_i gamma[i][k] x_i Sigma_k <- (1 / N_k) sum_i gamma[i][k] (x_i - mu_k)(x_i - mu_k)^T // ---- check convergence via observed log-likelihood ---- ll <- sum_i log( sum_k pi_k Gaussian(x_i | mu_k, Sigma_k) ) if |ll - prev_ll| < tol: break prev_ll <- ll until max_iter reached return theta ``` Two edge cases the pseudocode must handle in practice: (1) if Nk→0N_k \to 0 for some component (an empty cluster), Σk\Sigma_k is undefined — guard by re-seeding that component or adding a small floor to NkN_k; (2) if a component collapses onto a single point, Σk→0\Sigma_k \to 0 and the Gaussian density diverges — regularize by adding ϵI\epsilon I to every covariance estimate.

Figure
One EM iteration as a two-step loop tightening then climbing the ELBO
θ log p(x|θ) true log-likelihood ℓ(θ) ELBO(q_t, θ) θ_t E-step: touch curve (KL=0) θ_{t+1} M-step: climb bound ℓ increases: ℓ(θ_{t+1}) ≥ ℓ(θ_t)

Complexity & correctness

Time complexity per iteration (Gaussian mixture, dd-dimensional data, KK components, NN points). The E-step evaluates N⋅KN \cdot K Gaussian densities; each density evaluation costs O(d2)O(d^2) for the Mahalanobis term when using a precomputed Cholesky factor of Σk\Sigma_k (or O(d3)O(d^3) once per component per iteration to factor Σk\Sigma_k, amortized over the NN points). So the E-step costs

O(NKd2+Kd3).O(N K d^2 + K d^3).

The M-step computes weighted sums for μk\mu_k (O(NKd)O(NKd)) and weighted outer products for Σk\Sigma_k (O(NKd2)O(NKd^2)), giving

O(NKd2).O(N K d^2).

Total per iteration: O(NKd2+Kd3)O(NKd^2 + Kd^3), dominated by O(NKd2)O(NKd^2) when N≫dN \gg d, which is the typical regime. Space complexity is O(NK)O(NK) for the responsibility matrix γ\gamma (or O(K)O(K) if streamed one point at a time and parameters are accumulated online) plus O(Kd2)O(Kd^2) for the covariances. The number of iterations to convergence is not bounded by the problem size alone — it depends on how close the initialization is to a stationary point — but each individual iteration is cheap and the iteration count is usually small (tens to low hundreds) in practice.

Correctness — the monotonicity theorem. The central claim is:

ℓ(θ(t+1))≥ℓ(θ(t))for every t.\ell(\theta^{(t+1)}) \ge \ell(\theta^{(t)}) \quad \text{for every } t.

The proof follows directly from the ELBO decomposition above. Write, for any qq,

ℓ(θ)=ELBO(q,θ)+KL(q ∥ p(Z∣X,θ)).\ell(\theta) = \mathrm{ELBO}(q, \theta) + \mathrm{KL}(q \,\|\, p(Z\mid X,\theta)).

At the start of iteration tt, the E-step sets q(t)=p(Z∣X,θ(t))q^{(t)} = p(Z \mid X, \theta^{(t)}), which makes the KL term exactly zero, so

ℓ(θ(t))=ELBO(q(t),θ(t)).\ell(\theta^{(t)}) = \mathrm{ELBO}(q^{(t)}, \theta^{(t)}).

The M-step then chooses θ(t+1)=arg⁡max⁡θELBO(q(t),θ)\theta^{(t+1)} = \arg\max_\theta \mathrm{ELBO}(q^{(t)}, \theta), so in particular

ELBO(q(t),θ(t+1))≥ELBO(q(t),θ(t))=ℓ(θ(t)).\mathrm{ELBO}(q^{(t)}, \theta^{(t+1)}) \ge \mathrm{ELBO}(q^{(t)}, \theta^{(t)}) = \ell(\theta^{(t)}).

Finally, because the ELBO is a lower bound for any qq (Jensen's inequality applied to the concave log⁡\log), in particular for q(t)q^{(t)} evaluated at the new parameters,

ℓ(θ(t+1))≥ELBO(q(t),θ(t+1)).\ell(\theta^{(t+1)}) \ge \mathrm{ELBO}(q^{(t)}, \theta^{(t+1)}).

Chaining the two inequalities gives ℓ(θ(t+1))≥ℓ(θ(t))\ell(\theta^{(t+1)}) \ge \ell(\theta^{(t)}), proving monotone non-decrease. Since ℓ\ell is bounded above for well-posed likelihood models (under regularity/regularization to avoid degenerate variance collapse), a monotone bounded sequence converges, so ℓ(θ(t))\ell(\theta^{(t)}) converges to some limit.

What this does not prove. Convergence of the likelihood sequence does not imply convergence to a global maximum, nor even that the parameter sequence θ(t)\theta^{(t)} converges (though under mild conditions it does, to a stationary point of ℓ\ell). EM is exactly coordinate ascent on the joint objective F(q,θ)=ELBO(q,θ)F(q,\theta) = \mathrm{ELBO}(q,\theta): the E-step is exact coordinate maximization over qq (closed form, since the optimal qq is just the posterior), and the M-step is exact or partial coordinate maximization over θ\theta. Coordinate ascent on a function bounded above converges to a point where neither coordinate block can be locally improved — a stationary point, which for non-convex ℓ\ell may be a local maximum or saddle. This is the fundamental tradeoff of EM: guaranteed monotonic progress, no guarantee of global optimality. In practice this is mitigated by multiple random restarts, sensible initialization (e.g. k-means++), and model-selection criteria like BIC to choose KK.

Worked example

Consider N=6N=6 one-dimensional points, K=2K=2 Gaussian components, and a deliberately asymmetric dataset so no accidental symmetry hides an error:

X={1, 2, 3, 9, 10, 25}.X = \{1,\ 2,\ 3,\ 9,\ 10,\ 25\}.

Initialize (deliberately imperfectly): π1=π2=0.5\pi_1=\pi_2=0.5, μ1=2\mu_1 = 2, μ2=8\mu_2 = 8, σ12=σ22=4\sigma_1^2 = \sigma_2^2 = 4.

Iteration 1 — E-step. Using N(x∣μ,σ2)=12πσ2exp⁡ ⁣(−(x−μ)22σ2)\mathcal N(x\mid\mu,\sigma^2) = \frac{1}{\sqrt{2\pi\sigma^2}}\exp\!\big(-\frac{(x-\mu)^2}{2\sigma^2}\big), compute unnormalized responsibilities πkN(xi∣μk,σk2)\pi_k \mathcal N(x_i\mid\mu_k,\sigma_k^2) and normalize:

xix_iN(xi∣2,4)\mathcal N(x_i\mid 2,4) (×π=.5)N(xi∣8,4)\mathcal N(x_i\mid 8,4) (×π=.5)γi1\gamma_{i1}γi2\gamma_{i2}
10.09650.00002210.99980.0002
20.09970.00008660.99910.0009
30.09650.00031830.99670.0033
90.00008660.09650.00090.9991
100.00002210.09970.00020.9998
25≈0≈0 (tiny, ~10−3810^{-38})≈0.0002*≈0.9998*

(*The far outlier x=25x=25 is roughly 101810^{18} times more likely under component 2's density than component 1's at this scale, so it is assigned almost entirely — but not literally 100% — to component 2; the exact ratio still depends on the tails.)

Iteration 1 — M-step. Compute effective counts and weighted moments:

N1≈0.9998+0.9991+0.9967+0.0009+0.0002+0.0002=3.997,N_1 \approx 0.9998+0.9991+0.9967+0.0009+0.0002+0.0002 = 3.997,
N2≈6−N1=2.003.N_2 \approx 6 - N_1 = 2.003.
μ1=1N1∑iγi1xi≈0.9998(1)+0.9991(2)+0.9967(3)+0.0009(9)+0.0002(10)+0.0002(25)3.997≈2.01\mu_1 = \frac{1}{N_1}\sum_i \gamma_{i1} x_i \approx \frac{0.9998(1)+0.9991(2)+0.9967(3)+0.0009(9)+0.0002(10)+0.0002(25)}{3.997} \approx 2.01
μ2=1N2∑iγi2xi≈0.0002(1)+0.0009(2)+0.0033(3)+0.9991(9)+0.9998(10)+0.9998(25)2.003≈14.65\mu_2 = \frac{1}{N_2}\sum_i \gamma_{i2} x_i \approx \frac{0.0002(1)+0.0009(2)+0.0033(3)+0.9991(9)+0.9998(10)+0.9998(25)}{2.003} \approx 14.65

Notice how the single outlier x=25x=25, softly assigned to component 2, pulls μ2\mu_2 up sharply from the initial 8 to about 14.65 — a preview of EM's known sensitivity to outliers in Gaussian mixtures. New variances are computed the same weighted way, and new mixing weights are π1=N1/6≈0.666\pi_1 = N_1/6 \approx 0.666, π2≈0.334\pi_2 \approx 0.334.

Subsequent iterations. As iterations continue, component 1 tightens around the tight cluster {1,2,3}\{1,2,3\}, and component 2 stretches to cover {9,10,25}\{9,10,25\} with an inflated variance to accommodate the outlier — since a single Gaussian must explain both 9–10 and 25 simultaneously. The observed log-likelihood ℓ(θ(t))=∑ilog⁡p^(xi)\ell(\theta^{(t)}) = \sum_i \log\hat p(x_i) increases at every step (monotonicity theorem above); after a handful of iterations the parameters stabilize near μ1≈2\mu_1\approx 2, σ12\sigma_1^2 small, μ2≈14.7\mu_2 \approx 14.7, σ22\sigma_2^2 large, and π1≈0.5\pi_1 \approx 0.5, matching the visually obvious two-cluster-plus-outlier structure of the data — while also exposing that this 2-component model is not a great fit for a true three-group structure (two tight clusters and one outlier), a diagnostic used heavily in Anomaly Detection Fundamentals.

Figure
Responsibility landscape after iteration 1: two components, one outlier pulling μ₂
x 0 5 10 15 20 25 1 2 3 9 10 25 component 1 (μ≈2, tight) component 2 (μ≈14.7, stretched by outlier at 25)

Common pitfalls & traps

PitfallWhy it happensFix
Log-likelihood decreases between iterationsUsually a bug: E-step not using current θ\theta, or normalizing responsibilities incorrectlyRecompute ℓ\ell every iteration and assert monotonicity as a unit test
Singular covariance ("collapsed" component)A component's responsibility concentrates on one point, Σk→0\Sigma_k \to 0, likelihood →∞\to\inftyAdd a regularizing floor Σk←Σk+ϵI\Sigma_k \leftarrow \Sigma_k + \epsilon I; cap component shrinkage
Converging to a bad local optimumNon-convex likelihood surface; EM only guarantees a stationary pointMultiple random restarts, k-means++ initialization, compare final ℓ\ell across runs
Empty / starved cluster (Nk≈0N_k \approx 0)Poor initialization assigns almost no responsibility to a componentRe-seed empty clusters from high-error points; merge/split heuristics
Treating EM as guaranteed to find the MLEConfusing "monotone non-decreasing" with "converges to global maximum"Always report multiple restarts' likelihoods; use held-out likelihood for model selection
Label switching across runs/iterationsComponents are exchangeable — permuting labels gives an identical modelAlign labels post hoc by matching means/moments before comparing runs
Overfitting with too many componentsMore components can only increase (never decrease) training likelihoodUse validation likelihood, BIC/AIC, or held-out data to choose KK

Pioneers & history

The 1977 paper by Dempster, Laird, and Rubin unified a scattered family of ad hoc "fill in the missing data, re-estimate, repeat" procedures — already used piecemeal in genetics, factor analysis, and hidden Markov model estimation — into a single, formally justified algorithm with a general monotonicity proof. This transformed EM from a collection of tricks into a principled tool applicable to any exponential-family latent variable model.

Origins · 1 minArthur Dempster and how this was discovered
AD
Arthur Dempster
born 1929 · Harvard statistician

Dempster co-authored the 1977 Journal of the Royal Statistical Society paper "Maximum Likelihood from Incomplete Data via the EM Algorithm," which formalized the E-step/M-step structure and proved the monotone likelihood-increase property for a broad class of missing-data problems, giving the method its name and its mathematical foundation.

History
1950
s — precursors: hidden Markov model re-estimation (Baum–Welch) and genetics allele-frequency estimation use EM-like iterative updates without a unifying theory.
1977
— Dempster, Laird, and Rubin publish the general EM framework and the monotonicity proof, coining the "EM algorithm" name.
1983
— Wu establishes rigorous convergence conditions clarifying when EM converges to stationary points versus saddle points.
1993
— Neal and Hinton reinterpret EM as coordinate ascent on a free-energy/ELBO functional, directly foreshadowing variational inference.
2000
s–present — EM becomes a core building block behind Gaussian mixtures, HMMs, topic models (variational EM), and missing-data imputation pipelines across industry ML systems.

Where this matters

EM (and its variational generalizations) is embedded in an enormous range of production systems. Speech recognition and bioinformatics pipelines historically relied on the Baum–Welch algorithm — EM specialized to hidden Markov models — to train phoneme and gene-sequence models. Gaussian mixture models fit with EM are used for speaker verification, background subtraction in video, and soft clustering in customer segmentation, directly building on Gaussian Mixture Models and Density Estimation Fundamentals. Recommender systems and survey-data pipelines use EM-style imputation to handle missing entries under a probabilistic model rather than discarding incomplete rows. In probabilistic topic modeling (e.g., variants of latent Dirichlet allocation), variational EM extends the same E-step/M-step alternation to approximate rather than exact posteriors when the exact posterior is intractable. Fitted mixture densities from EM feed directly into likelihood-based outlier scoring, the starting point for Anomaly Detection Fundamentals: points with very low p^(x)\hat p(x) under the learned mixture are flagged as anomalies, making EM not just a clustering tool but a density-estimation engine for downstream detection systems.

Ask the tutor: Why does adding more mixture components always increase training likelihood, and what does that imply about how you should choose K?

Does EM always find the global maximum of the likelihood?

No. EM guarantees that the observed-data log-likelihood is monotonically non-decreasing across iterations, and under mild regularity conditions the parameter sequence converges to a stationary point of the likelihood. That stationary point can be a local maximum, or in rarer cases a saddle point, rather than the global maximum. In practice practitioners run EM from several different random initializations (or use smarter seeding like k-means++), keep the run with the highest final likelihood, and treat convergence of the likelihood sequence as necessary but not sufficient evidence of a good fit.

Why is it called the "E-step" and "M-step" rather than just one update rule?

The names describe two mathematically distinct operations. The E-step takes an expectation: it computes the posterior distribution of the latent variables given the observed data and current parameters, which is used to form the expected complete-data log-likelihood. The M-step then maximizes that expected quantity over the parameters. Separating them clarifies why the algorithm works: the E-step is exact coordinate maximization over the variational distribution qq, and the M-step is exact (or partial) coordinate maximization over θ\theta, jointly performing coordinate ascent on the ELBO.

How does EM relate to k-means clustering?

Hard k-means can be viewed as a limiting, "hard-assignment" special case of EM applied to a Gaussian mixture with equal, isotropic, shrinking-to-zero covariances. In that limit the soft responsibilities γik\gamma_{ik} become 0/1 assignments to the nearest centroid (the E-step becomes nearest-centroid assignment), and the M-step becomes the usual centroid recomputation. EM generalizes k-means by keeping soft, probabilistic assignments and by allowing each cluster its own shape (covariance) and weight, at the cost of a more expensive per-iteration computation.

What happens if the latent variable is continuous rather than discrete, as in factor analysis?

The same E-step/M-step structure applies, but the sum over zz in the ELBO becomes an integral, and the E-step computes a posterior density rather than a finite table of responsibilities. For models in the exponential family with conjugate priors (such as linear-Gaussian factor analysis or probabilistic PCA), this posterior is itself Gaussian and has a closed form, so the E-step remains tractable analytically. When the posterior has no closed form, practitioners fall back to variational EM, replacing the exact posterior with a tractable approximate family and optimizing the same ELBO approximately.

Why does EM sometimes get stuck with an empty or nearly-empty cluster?

If initialization places a component's mean far from any data, or in a very low-density region, the E-step assigns it near-zero responsibility for every point. The M-step then computes Nk≈0N_k \approx 0, and the mean and covariance updates become numerically unstable or undefined, effectively freezing that component in a useless state. Common remedies include re-seeding starved components at high-residual points, initializing means from actual data samples or k-means++ centroids rather than arbitrary values, and monitoring per-component effective counts NkN_k during training to trigger a restart.

Is EM guaranteed to be more efficient than directly maximizing the log-likelihood with gradient ascent?

Not universally, but in many exponential-family latent variable models it is much simpler because the M-step has a closed-form solution (weighted sample statistics), avoiding step-size tuning and line search altogether. Its per-iteration cost is comparable to a gradient step, and it inherits the guaranteed monotonicity property that plain gradient ascent on a non-concave likelihood does not automatically have. Gradient methods can be competitive or faster when the M-step lacks a closed form, or when second-order or accelerated gradient variants are available, so the choice is model-dependent.

Why can outliers distort EM's estimates of a Gaussian mixture so severely?

Gaussian mixtures assign continuous, never-exactly-zero responsibility based on tail probabilities, and Gaussian tails decay only quadratically in the log-density. A distant outlier can still receive substantial or dominant responsibility for the nearest component, since no other component fits it any better, pulling that component's mean and inflating its variance to partially accommodate the outlier. This is visible in the worked example, where a single far point (25) drags a cluster mean well past its naturally tight neighbors (9, 10). Robust alternatives use heavier-tailed component densities (e.g., Student-t mixtures) or explicit outlier/noise components.

Before this

Where this leads