How do you derive the E-step and M-step of the EM algorithm for a Gaussian mixture model with components?
Probabilistic models, EM algorithm
Level L3 Intermediate. Length Long. Nature Mat Mathematical.
What's being asked
Whether you can introduce latent assignments, compute responsibilities with Bayes' rule, and maximise the expected complete-data log-likelihood in closed form.
Key idea
With latent , the E-step computes responsibilities and the M-step maximises , giving weighted means, weighted covariances and mixing proportions .
Steps
- Model: , where are mixing weights that sum to 1 and is a Gaussian with mean and covariance . The log-likelihood has a log of a sum, so setting its gradient to zero has no closed-form solution.
- Introduce with and . The complete-data log-likelihood has no log of a sum.
- E-step: replace by its posterior expectation , computed with Bayes' rule as in the key idea. It is the "soft" share of point that belongs to cluster . Let , the effective number of points in cluster .
- M-step for the means: setting gives . Similarly .
- M-step for the weights: maximise subject to with a Lagrange multiplier. This gives ; summing over gives , so .
- Iterate until the log-likelihood stops improving. Note that with shared covariance and , the responsibilities become hard assignments and EM reduces to k-means.
Common mistakes
- Ignoring the constraint when differentiating with respect to .
- Using the old means in the covariance update; the standard update uses the new .
- Not mentioning collapse: a component that shrinks onto one point sends and the likelihood to infinity. Add a small ridge to or restart.
- Claiming EM finds the global maximum. It finds a local one and depends on initialisation.
How long your answer should be
One page; 8–10 minutes.
Last checked on 4 December 2026.
Read this
- Bishop, Pattern Recognition and Machine Learning, Section 9.2.2: Free PDF. Section 9.2.2, EM for Gaussian Mixtures (pp. 435–439): responsibilities, the μ, Σ and π updates with the Lagrange multiplier, and the singularity problem.
- Stanford CS229 Lecture Notes, Chapter 11: EM Algorithms: Free PDF. Sections 11.1 and 11.4 (pp. 150–153, 160–162): the same GMM derivation done step by step, including the M-step for the mixing weights.
- NPTEL: Introduction to Machine Learning (IIT Madras, Prof. Balaraman Ravindran): Week 11: Gaussian Mixture Models and Expectation Maximization, which cover the E-step responsibilities and M-step updates.
Previous in Probabilistic models: How is the forward recursion for a hidden Markov model derived? For the HMM with states Rainy (R) and Sunny (S), , transitions , , , , and emissions , , , , what is ?
Next in Probabilistic models: Why does an iteration of the EM algorithm never decrease the observed-data log-likelihood?