EM Algorithm

The Expectation-Maximization (EM) algorithm is a deterministic iterative procedure for computing maximum-likelihood (MLE) or maximum-a-posteriori (MAP) estimates in models with latent variables , whose marginal likelihood is intractable but whose complete-data likelihood has a tractable form. EM alternates two steps:

  1. E-step (Expectation). Given the current parameter estimate , compute the responsibilities — the posterior of the latent variables under the current parameters:

    Then form the Q-function (expected complete-data log-likelihood):
  2. M-step (Maximization). Update the parameters by maximizing :

EM guarantees monotonic improvement of the observed-data log-likelihood: at every step. Under mild regularity conditions the iterates converge to a stationary point (local max, saddle, or local min), so multiple restarts are standard practice. EM is not a Bayesian posterior sampler — it produces a point estimate, not samples — but it sits adjacent to Bayesian methods both historically and algorithmically.

Relation to Gibbs sampling. EM is the deterministic analog of Gibbs for the same latent-variable augmentation. Gibbs draws and and produces samples from the joint posterior; EM replaces the Gibbs draw of with its expectation (the E-step) and replaces the Gibbs draw of with an argmax (the M-step), producing the MAP estimate instead of posterior samples. The same latent-variable augmentation and the same full conditionals power both algorithms — they differ only in “sample” vs. “replace with conditional expectation / argmax.”

Canonical application: Gaussian mixture models. For , the latent is the component assignment. The E-step computes responsibility ; the M-step updates to their responsibility-weighted MLEs. The algorithm reduces to the soft-assignment version of Lloyd’s -means.

Prerequisites

  • 3.11.2 Gibbs Sampling — Gibbs samples from the same latent-variable augmentation; EM replaces the draws with expectations/argmaxes.
  • 3.11 MCMC — parent context; EM is not MCMC but the latent-variable augmentation idea is shared.
  • 3.1 Bayesian Framework — prior, likelihood, posterior; EM computes the MAP rather than sampling the posterior.

Intuition

For many real models, the marginal likelihood is a sum over a combinatorially large latent space, and maximizing it directly by gradient ascent is numerically unstable or impossible. The EM trick is to introduce the latent explicitly and alternate between (E) inferring given current , and (M) re-estimating given current inferred . Each step is an easy sub-problem: the E-step is a posterior calculation on with held fixed, and the M-step is a weighted MLE calculation on with summarized by its responsibilities. Repeating drives the observed-data log-likelihood uphill.

The central tension is between the tractable complete data log-likelihood (which EM uses through its expectation) and the intractable marginal log-likelihood (what we actually want to maximize). EM exploits a variational identity (Jensen’s inequality applied to the marginal) to turn the intractable log-sum into a tractable sum-of-logs that can be optimized in closed form at each M-step. The cost is that EM finds only a local optimum — the landscape of typically has many modes in latent-variable models — so multiple restarts from different initializations are the practical norm.

Properties

(Monotonic Ascent) Observed-data log-likelihood never decreases across an iteration.

The EM update satisfies for every , with equality only at stationary points. This is proved via the evidence lower bound (ELBO): for any distribution , . Setting makes the bound tight at ; maximizing over (the M-step) can only increase the bound and hence cannot decrease . See Derivation.

(E-step as Posterior Computation) Responsibilities are the posterior .

For discrete , the responsibility is computed by Bayes’ rule using the current parameters: , normalized over . For continuous (linear factor models, Kalman smoothers) the E-step is a conditional Gaussian computation. In every case, the E-step is a posterior inference problem on the latent variables with parameters frozen; it is the step where the latent structure of the model is exploited.

(M-step as Weighted MLE) is usually a weighted complete-data MLE.

When is a sum over data points with separable -terms, decomposes into the same sum, now weighted by responsibilities. For a Gaussian mixture,

and maximizing over gives the responsibility-weighted sample estimators:

These are the MLE formulas with “soft counts” replacing hard indicators.

(Relation to Gibbs Sampling) EM replaces Gibbs draws with expectations and argmaxes.

For the same latent-variable augmentation , Gibbs alternates and — producing samples from the joint posterior. EM replaces with the full responsibility distribution (E-step) and replaces with its argmax (M-step). Gibbs gives the full posterior distribution but is slower; EM gives the MAP point estimate much faster but loses uncertainty quantification. The two algorithms sit at opposite ends of a compute-vs-uncertainty tradeoff on the same model.

Explicit comparison for Gaussian mixtures: Gibbs draws (hard stochastic assignment at iteration ), then updates by drawing from their conjugate posteriors given . EM uses the responsibilities as soft probabilistic assignments and sets to their MLEs given the weighted soft assignments. As the prior becomes uninformative (Dirichlet , Gaussian , Inverse-Gamma ), the Gibbs update for shrinks toward its MLE, and EM emerges as the limit of the Gibbs update.

(MAP Extension) EM computes the MAP instead of the MLE by adding a prior to the M-step.

Replace the M-step objective with the posterior-aware quantity . The monotonic-improvement property generalizes immediately: EM now climbs rather than . Conjugate priors turn the M-step into a closed-form posterior-mode computation — for Gaussian mixtures with Dirichlet / Normal / Inverse-Gamma priors, the MAP M-step is

which is recognizably the posterior mode (mean) of the conjugate Gibbs update rather than a pure sample.

(Convergence to Stationary Points, Not Necessarily Global) EM can get trapped in local maxima or saddles.

The monotonic-ascent guarantee is qualitative: the sequence is nondecreasing and bounded above, so it converges. Under regularity (Wu 1983), converges to a stationary point of , but which stationary point depends on the initialization. In mixture models, label-switching and empty clusters are classical local-optimum pathologies. Running EM from multiple random restarts and keeping the best result is the standard workaround; in critical applications, combining EM with simulated annealing or running a short Gibbs warmup before EM is also common.

(Convergence Speed) Linear near the optimum, with rate determined by the fraction of missing information.

Near a local optimum , EM converges linearly: with . The rate is the largest eigenvalue of the information ratio , where and are the complete-data and missing-data Fisher informations at . When carries little information beyond (responsibilities near or ), EM converges fast; when is highly informative about and the responsibilities are near for all components (highly ambiguous cluster membership), EM converges slowly. Direct gradient-based or Newton-based maximization of can be faster near the optimum but requires evaluating the observed-data log-likelihood, which is the reason EM exists in the first place.

(Generalizations) ECM, GEM, and stochastic EM handle intractable M-steps and scale to large data.

When the M-step does not have a closed form, the Generalized EM (GEM) algorithm only requires (a partial ascent) rather than the exact argmax — monotonic ascent of still holds. Expectation Conditional Maximization (ECM) replaces the joint M-step with coordinate-wise maximizations. Stochastic EM replaces the full responsibility computation at each iteration with a Monte Carlo estimate (useful for large or intractable posteriors), trading monotonic ascent for scalability. Each variant preserves some version of the ELBO inequality.

Examples

Derivation

Goal. Prove the EM monotonic ascent property , and show how the E-step and M-step together guarantee it.

Step 1 — ELBO decomposition. For any parameter and any distribution over the latent variable ,

This identity follows from writing , taking expectations under , and rearranging. Since ,

for every , with equality when .

Step 2 — E-step makes the bound tight. At iteration , set . Then , so

where is the entropy of . The Q-function is the part of ELBO that depends on ; the entropy does not.

Step 3 — M-step increases ELBO at . With held fixed, maximize the ELBO over :

since the entropy does not depend on . By construction,

Step 4 — Conclude monotonic ascent. Apply the ELBO inequality at the new parameter and any distribution :

The first inequality is ELBO log-likelihood for any ; the second is the M-step improvement. Combined,

which is the promised monotonic ascent. The sequence is nondecreasing and bounded above (by the global maximum of the log-likelihood), so it converges. Under mild regularity conditions (continuity of in ), itself converges to a stationary point of — local max, saddle, or local min — but not necessarily the global max.

Why this works algorithmically. The E-step replaces an intractable with a tractable expectation , using the best possible (the posterior under ) so that nothing is thrown away. The M-step then optimizes the tractable surrogate. Because the ELBO touches at and lies beneath it everywhere, improving the ELBO is guaranteed to improve .

See Also

  • 3.11.2 Gibbs Sampling — stochastic version of EM on the same latent-variable augmentation; gives posterior samples rather than point estimate.
  • 3.11 MCMC — parent index; EM is adjacent to rather than an instance of MCMC.
  • 3.1 Bayesian Framework — prior, likelihood, posterior; EM finds MAP (or MLE) rather than sampling the full posterior.
  • 3.9 Laplace Approximation — related tool: approximates the posterior around the MAP (which EM can find) using the Hessian.
  • 3.7 Marginal Likelihood — the ELBO is a lower bound on the log marginal likelihood, linking EM to variational inference.