The EM Algorithm
Three updates, each of which needs the others’ answers. §11.3 does the only thing available: run them in a loop and hope. The reason it is not merely hope is one sentence:
Every step in the EM algorithm increases the log-likelihood function (Neal and Hinton, 1999).
What you’ll learn
Section titled “What you’ll learn”- The algorithm as §11.3 states it: initialise, E-step (Equation 11.53), M-step (Equations 11.54–11.56), repeat.
- Example 11.6’s claim that “after five iterations, the EM algorithm converges” — reproduced, and made precise: first at iteration , though the parameters keep moving until .
- The monotonicity guarantee, measured to the last bit. Over individual EM steps from random starts: register a negative change, none larger than , with a median of — exactly one ULP of a log-likelihood near .
- That EM converges linearly, and what sets the rate: component overlap. iterations when of points are ambiguous, when none are.
- What a better initialisation buys: K-means first cuts the median from iterations to and takes the best optimum from to of runs.
- Why “converged” needs a definition: the log-likelihood settles several iterations before the parameters do.
Intuition: two problems, each easy given the other
Section titled “Intuition: two problems, each easy given the other”The obstacle page 1102 measured was circular. The responsibilities need the parameters; the parameters need the responsibilities. Neither can be written down first.
EM breaks the circle by refusing to solve both at once. Fix the parameters and the responsibilities are a formula. Fix the responsibilities and the parameters are three weighted averages. Alternate.
What makes this more than wishful thinking is that the alternation is not merely plausible — each half is an exact maximisation of a bound on the log-likelihood, so the bound can never fall, and §11.4.5 will show where that bound comes from.
flowchart TD I["1. initialise mu_k, Sigma_k, pi_k"] --> E["2. E-step: r_nk from Equation 11.53
posterior over which component made x_n"] E --> M["3. M-step: Equations 11.54 to 11.56
mu_k, then Sigma_k, then pi_k"] M -->|"L increased, by Neal and Hinton"| C{"converged?"} C -->|"no"| E C -->|"yes"| D["a LOCAL optimum
Section 11.4.5's caveat"]
§11.3 The algorithm
Section titled “§11.3 The algorithm”1. Initialise , , .
2. E-step. Evaluate the responsibilities — “posterior probability of data point belonging to mixture component ”:
3. M-step. Reestimate the parameters using those responsibilities:
Page 1105 measured why the order inside the M-step matters: using the pre-update means in Equation 11.55 gives where the book’s Example 11.4 gives .
Example 11.6, made precise
Section titled “Example 11.6, made precise”| iteration | change in | largest parameter move | |
|---|---|---|---|
The guarantee, measured
Section titled “The guarantee, measured”The book states Neal and Hinton’s result and moves on. Measured over random restarts on the book’s seven points, individual EM steps:
| value | |
|---|---|
| steps registering any negative change | |
| steps decreasing by more than | |
| steps decreasing by more than | |
| worst single decrease | |
| median of the negative changes | |
| one ULP of a log-likelihood near | |
| largest single increase |
How fast, and what decides it
Section titled “How fast, and what decides it”EM converges linearly — the error shrinks by a constant factor each step, not quadratically as Newton’s method would. The factor is set by how much the components overlap. Two clusters of points each at with unit variance:
| ambiguous points () | iterations to | measured rate | |
|---|---|---|---|
| — |
A factor of between the two ends, on data that differs only in how far apart the clusters are. That is the practical meaning of “linear convergence with a problem-dependent rate”: when the responsibilities are near , each E-step barely moves them, so each M-step barely moves the parameters.
What the initialisation buys
Section titled “What the initialisation buys”points from three clusters, , restarts of each strategy:
| initialisation | median iterations | mean iterations | share reaching the best optimum |
|---|---|---|---|
| random data points | |||
| K-means first |
The mean and median coincide for the K-means start, which is the interesting part: the long tail is gone entirely. Random starts occasionally land in a basin that takes hundreds of iterations to crawl out of; the K-means start never does, on this data.
This is why §11.5 points at K-means in the same breath as the GMM, and why every library implementation defaults to a K-means or K-means++ initialisation. It costs a few cheap iterations and removes both the worst case and the failures.
-
What does the E-step compute, and what does the M-step do with it?
Each half is easy given the other, and neither can be done first — that is the circularity page 1102 measured. EM alternates, and because each half exactly maximises a bound on the log-likelihood, the bound can never fall.
pch.quizShowAnswer
B — The E-step computes the responsibilities from the current parameters; the M-step recomputes the parameters as three responsibility-weighted averages — Each half is easy given the other, and neither can be done first — that is the circularity page 1102 measured. EM alternates, and because each half exactly maximises a bound on the log-likelihood, the bound can never fall.
-
Over 180,000 EM steps, how often did the log-likelihood decrease?
Reporting this as 'never decreased' would be wrong. The honest statement is that no step decreased it by more than the rounding error of the quantity itself. The practical consequence: test new_L < old_L - tol, not new_L < old_L, or your convergence check will fire spuriously.
pch.quizShowAnswer
B — 11,163 times, but never by more than 8.9e-15 — the median decrease is exactly one unit in the last place — Reporting this as 'never decreased' would be wrong. The honest statement is that no step decreased it by more than the rounding error of the quantity itself. The practical consequence: test new_L < old_L - tol, not new_L < old_L, or your convergence check will fire spuriously.
-
What sets how many iterations EM needs?
A factor of 348 between the two ends, on data differing only in cluster separation. When responsibilities sit near 0.5 the E-step barely moves them, so the M-step barely moves the parameters — that is linear convergence with a problem-dependent rate.
pch.quizShowAnswer
B — How much the components overlap — 1045 iterations when 53 percent of points are ambiguous, 3 when none are — A factor of 348 between the two ends, on data differing only in cluster separation. When responsibilities sit near 0.5 the E-step barely moves them, so the M-step barely moves the parameters — that is linear convergence with a problem-dependent rate.
-
What does initialising with K-means buy?
Mean and median coincide at 19 for the K-means start, against a mean of 128.6 for random starts. Both find the same best value of -702.671823. No initialisation can outrun an unbounded objective — that needs a variance floor or a prior.
pch.quizShowAnswer
B — Fewer iterations — median 19 against 58 — and it removes the long tail entirely, but the optimum it reaches is the same one — Mean and median coincide at 19 for the K-means start, against a mean of 128.6 for random starts. Both find the same best value of -702.671823. No initialisation can outrun an unbounded objective — that needs a variance floor or a prior.
Exercises
Section titled “Exercises”Exercise 1 – Run Example 11.6 and define “converged”
Section titled “Exercise 1 – Run Example 11.6 and define “converged””Exercise 2 – How big are the decreases?
Section titled “Exercise 2 – How big are the decreases?”Exercise 3 – Overlap is what makes it slow
Section titled “Exercise 3 – Overlap is what makes it slow”Exercise 4 – What K-means buys you
Section titled “Exercise 4 – What K-means buys you”Recall card
Section titled “Recall card”- EM breaks a circular problem by refusing to solve both halves at once: fix the parameters and the responsibilities are a formula; fix the responsibilities and the parameters are three weighted averages.
- The E-step is Equation 11.53, the responsibilities. The M-step is Equations 11.54 to 11.56, in that order, each using what the step before produced.
- Example 11.6’s ‘after five iterations’ is the 1e-06 log-likelihood criterion, reproduced exactly; at 1e-09 it takes eight.
- The log-likelihood settles before the parameters do, at every tolerance, because it is flat near an optimum. Five against eleven at 1e-06.
- Neal and Hinton’s guarantee, measured over 180,000 steps: 11,163 register a negative change and none is larger than 8.9e-15.
- The median decrease is 1.776e-15, exactly one unit in the last place of a log-likelihood near minus fourteen. The theorem is about real numbers; this is what checking it in float64 looks like.
- So a convergence test should compare against a tolerance, not against zero, or it will fire spuriously.
- EM converges linearly, and overlap sets the rate: 1045 iterations when 53 percent of points are ambiguous, 3 when none are — a factor of 348.
- When responsibilities sit near one half the E-step barely moves them, so the M-step barely moves the parameters.
- A K-means initialisation cuts the median from 58 iterations to 19 and makes mean and median coincide — the long tail disappears.
- It also takes the share of runs reaching the best optimum from 96 to 100 percent, which is why every library implementation defaults to it.
- But it does not make the optimum global. No initialisation can outrun an unbounded objective; that needs a variance floor or a prior.
Next: The Latent Variable Perspective — §11.4, which explains where the responsibilities come from and why EM is the algorithm it is.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading