Skip to content
mlmentorship

Expectation-Maximization (EM)

Compute posterior expected complete-data statistics, then improve a touching likelihood bound. Trace one exact two-coin EM iteration.

Published · 7 min read ·Role-specific ·Intermediate
Reading depth

Summary

Expectation-Maximization alternates posterior computation with parameter improvement for a latent-variable model. An exact posterior makes a likelihood lower bound touch the current objective; improving that fixed bound cannot decrease observed likelihood. This guarantee is not a global-optimum or component-identification guarantee.

The two steps

Let x be observations, z latent variables, and theta parameters. Require available exact posteriors, common support, finite required expectations, and an M-step that does not reduce its target.

E-step

Given current parameters , compute the posterior over latents:

Current theta stays fixed while q is computed. Calculate expected complete-data sufficient statistics, not merely a substituted mean latent value. For example, generally differs from .

M-step

Update to maximize the expected complete-data log-likelihood:

Here q stays fixed while theta changes. Write .

For a teaching mixture, choose a coin independently for each two-toss group. Initial weights are and head probabilities ; observe head counts two and one. The binomial probability includes . Count two has likelihoods , giving responsibilities . Count one has likelihoods , giving responsibilities .

Effective group counts are ; weighted heads are . The M-step sets weights to and head probabilities to . The denominators count expected tosses, not expected groups. Observed likelihood rises from to approximately . Its log rises from to .

Why it works

EM maximizes a lower bound on :

Write when q is the current posterior. The identity says , with a nonnegative KL gap. Exact E sets the gap to zero at theta_t. Improving Q with q fixed then yields:

Learning objective

Raise a touching lower bound to prevent the likelihood from falling

Maximize a bound that touches the current objectiveThis illustrative bound touches at 0.5. Its maximum at 0.25 raises the objective from -0.25 to -0.0625.Climb a supporting bound that touchesnowContact at 0.5; bound maximum at 0.25Objective rises: -0.25 to -0.0625
Derivation
EM climbs a lower bound on the observed-data log-likelihood A solid curve is the observed-data log-likelihood. A dashed lower-bound curve touches it at the current parameter theta t because the E-step sets q t to the exact posterior and makes the KL gap zero. Holding q t fixed, the M-step moves right to theta t plus 1, where the lower bound is higher. The solid likelihood at the new parameter is at least as high as that bound. The next E-step closes the remaining gap. parameter θ objective log p(x; θ) observed likelihood · solid F(qt, θ) fixed lower bound · dashed θt θt+1 M-step raises bound → 1 · E-step: make the bound tight qt = p(z|x; θt) ⇒ KL gap = 0 2 · M-step: improve the fixed bound F(qt, θt+1) ≥ F(qt, θt) = log p(x; θt) 3 · Likelihood stays above its bound log p(x; θt+1) ≥ F(qt, θt+1)
exact E makes the dashed bound touch observed log likelihood at the current parameter. M improves that fixed bound. Likelihood remains above it, proving nondecrease under the stated assumptions. The next exact E-step closes the new gap.
Check: Which two inequalities ensure the new likelihood cannot fall after the bound is improved?
Read it this way: This illustrative bound touches at 0.5. Its maximum at 0.25 raises the objective from -0.25 to -0.0625.
Why is the true objective at the new bound maximum no lower than the old objective?

Add a Parameter Prior

New task: Prefer interior coin probabilities with independent Beta(2,2) priors; leave mixture weights unregularized.

Picture and change: Keep posterior responsibilities, but maximize Q plus log prior.

Check: Probability updates become and .

Use when: A MAP estimator is required. The protected objective is log posterior, not bare observed likelihood.

Improve Only Part of M

New task: Update mixture weights while keeping both coin probabilities at their initial values.

Picture and change: This generalized M-step improves Q without jointly maximizing every parameter.

Check: Weights give observed likelihood , above the initial value.

Use when: A verified improving parameter block is available but joint optimization is expensive.

Identical components can remain identical; nondecreasing likelihood does not distinguish them or identify a global solution. Under appropriate regularity and convergence conditions, limit points can be stationary, including saddles. Unconstrained Gaussian mixtures can instead diverge through covariance collapse.

Canonical example: GMM

Gaussian mixtures apply this owner to posterior component responsibilities and weighted Gaussian sufficient statistics. Detailed covariance updates belong to that application, not a second generic EM derivation.

Variants

  • Hard assignment: k-means relates to restricted mixtures through hard-assignment or small-variance limits, not ordinary finite-variance exact EM.
  • Stochastic approximations: sampling noise need not preserve likelihood nondecrease at every iteration.
  • Variational E: improving a restricted lower bound does not automatically increase observed likelihood; the touching-bound step may be missing.
  • MAP-EM: an explicit prior changes the optimized objective.

Limitations

Initialization, latent-model specification, missing information, and numerical optimization affect convergence and usefulness. Comparing restarts does not turn a nonconvex model into a globally solved problem.

Common pitfalls

Ad hoc covariance stabilization and approximate E/M updates require their own objective/monotonicity analysis. Alternating two convenient steps is not enough to establish the exact EM proof.