The Latent Variable Perspective
Everything so far has worked without a story. §11.4 supplies one, and is explicit that it is not decoration:
The advantages of the probabilistic perspective are that (i) it will justify some ad hoc decisions we made in the previous sections, (ii) it allows for a concrete interpretation of the responsibilities as posterior probabilities, and (iii) the iterative algorithm for updating the model parameters can be derived in a principled manner.
All three are checkable, and this page checks them.
What you’ll learn
Section titled “What you’ll learn”- Equations 11.58–11.62: the one-hot latent , the prior , and the joint.
- Ancestral sampling, run million times: the samples reproduce Equation 11.66b to in bin probability, against a sampling floor of .
- Equation 11.72b: the responsibility is a posterior. Computed the long way — joint over marginal — it matches Equation 11.17 to , and the empirical posterior from labelled samples matches it too.
- Equation 11.73’s , and §11.4.5’s claim that the M-step maximises it — verified against a -restart numerical search: , with every parameter agreeing to six decimals.
- The decomposition , tight at to , which is why raising raises .
- And the one thing the generative story buys that the algebra could not: data. Generate from a known mixture, refit, and watch the errors fall — from to as goes from to .
Intuition: the missing column
Section titled “Intuition: the missing column”Imagine the dataset had one more column: which component produced each point. Fitting would be trivial — split by that column and use Chapter 8’s closed forms. The column exists; you just cannot see it.
That is the whole content of §11.4. is the missing entry, one-hot over values. Everything the previous sections invented — the responsibilities, the weighted averages, the alternation — is what you get by writing down that model and applying Bayes’ theorem. The responsibility stops being a useful weight and becomes the posterior over the missing column.
flowchart TD Z["z one-hot in R^K
p(z) = pi, Equation 11.59"] -->|"p(x | z_k = 1) = N(x | mu_k, Sigma_k)
Equation 11.58"| XX["x"] Z --> J["joint p(x, z_k=1) = pi_k N(...)
Equation 11.61"] XX --> J J -->|"sum over z"| MARG["p(x) = sum_k pi_k N(...)
Equation 11.66b = the GMM"] J -->|"Bayes"| POST["p(z_k = 1 | x) = r_nk
Equation 11.72b = Equation 11.17"] POST --> Q["Q = E[log p(x, z | theta)]
Equation 11.73"] Q -->|"maximise"| MSTEP["the M-step
Equations 11.54 to 11.56"]
§11.4.1 The generative process
Section titled “§11.4.1 The generative process”A binary indicator says whether component made the point:
has zeros and exactly one — a one-hot encoding. Since the indicators are not observed, they get a prior:
and the joint follows:
Ancestral sampling — sample , then given it, then throw away — gives “valid samples from the GMM”. Run million times:
| value | |
|---|---|
| empirical mean | against a theoretical |
| empirical variance | against |
| largest gap in bin probability, bins | |
| total variation distance | |
| sampling floor, |
§11.4.3 The responsibility is a posterior
Section titled “§11.4.3 The responsibility is a posterior”Bayes’ theorem on the joint:
which we identify as the responsibility of the th mixture component for data point .
Computed the long way on the book’s seven points — form the joint of Equation 11.61, divide by the marginal of Equation 11.66b — against page 1103’s Equation 11.17:
| value | |
|---|---|
Not approximately. The same arithmetic, written twice, three sections apart.
§11.4.5 The M-step maximises Q
Section titled “§11.4.5 The M-step maximises Q”Given the current parameters , the E-step computes
and “the M-step selects an updated set of model parameters by maximizing” it. The book states this and stops. Checked, on the book’s own initialisation:
| at the M-step’s answer (Equations 11.54–11.56) | |
| at a -restart Nelder–Mead maximum of | |
| difference |
and parameter by parameter:
| optimiser | the M-step | |
|---|---|---|
What the story buys that the algebra could not
Section titled “What the story buys that the algebra could not”Generate data from a known mixture — , , — and fit it back, best of five restarts:
Each row is a single dataset, so individual rows fluctuate — the draw is unlucky on the means. Across the three orders of magnitude the trend is unambiguous: improves by , by , by , against the a perfectly behaved estimator would give.
This check is only possible because of §11.4. Without a generative process there is no “truth” to recover — you can measure a likelihood, but you cannot ask whether the parameters are right.
-
What is the latent variable z in Section 11.4?
Chapter 10's latent variable was continuous and lived in R^M; this one is discrete with K states. Think of it as a missing column in the dataset: if you could see which component made each point, fitting would be Chapter 8's closed forms applied group by group.
pch.quizShowAnswer
B — A one-hot indicator saying which of the K components generated the point — Chapter 10's latent variable was continuous and lived in R^M; this one is discrete with K states. Think of it as a missing column in the dataset: if you could see which component made each point, fitting would be Chapter 8's closed forms applied group by group.
-
What is the relationship between the responsibility and the posterior over z?
Section 11.2.1 could only call the responsibility a soft assignment. Now it has a referent: the probability that component k did in fact generate the point. That is what licenses treating the column sums as counts, and what makes the assignment differentiable.
pch.quizShowAnswer
B — They are the same quantity — computing the joint over the marginal reproduces Equation 11.17 to exactly 0.0 — Section 11.2.1 could only call the responsibility a soft assignment. Now it has a referent: the probability that component k did in fact generate the point. That is what licenses treating the column sums as counts, and what makes the assignment differentiable.
-
Does the M-step really maximise Q, or is that an approximation?
Every parameter agrees: the weights, the means and the variances. The three weighted averages of Section 11.2 are not a heuristic that happens to work — they are the closed-form argmax of the expected complete-data log-likelihood.
pch.quizShowAnswer
B — It is exact — a 40-restart numerical maximisation of Q lands on the same parameters to six decimals, differing in Q by 5.3e-15 — Every parameter agrees: the weights, the means and the variances. The three weighted averages of Section 11.2 are not a heuristic that happens to work — they are the closed-form argmax of the expected complete-data log-likelihood.
-
Why does raising Q raise L?
Measured at the book's initialisation: Q is minus 28.7899, H is 0.4644, and their sum is L to 1.1e-14. After the M-step, Q rose by 13.480070 and L by 13.915050 — L gains more, because the new responsibilities are more confident and the entropy term grows too.
pch.quizShowAnswer
B — Because L = Q + H with H the entropy of the responsibilities, so Q is a lower bound on L that is tight at the current parameters — Measured at the book's initialisation: Q is minus 28.7899, H is 0.4644, and their sum is L to 1.1e-14. After the M-step, Q rose by 13.480070 and L by 13.915050 — L gains more, because the new responsibilities are more confident and the entropy term grows too.
Exercises
Section titled “Exercises”Exercise 1 – Sample from the story, recover the density
Section titled “Exercise 1 – Sample from the story, recover the density”Exercise 2 – The responsibility, computed as a posterior
Section titled “Exercise 2 – The responsibility, computed as a posterior”Exercise 3 – Does the M-step maximise Q?
Section titled “Exercise 3 – Does the M-step maximise Q?”Exercise 4 – L equals Q plus an entropy
Section titled “Exercise 4 – L equals Q plus an entropy”Exercise 5 – Generate, then recover
Section titled “Exercise 5 – Generate, then recover”Recall card
Section titled “Recall card”- Section 11.4 adds a missing column to the dataset: a one-hot indicator saying which component made each point. If you could see it, fitting would be Chapter 8’s closed forms group by group.
- Chapter 10’s latent variable was continuous; this one is discrete with K states, and the prior over it is the mixture weights.
- Ancestral sampling from the model reproduces the mixture density — 1.5 million draws matching Equation 11.66b to a bin-probability gap of 3.4e-04, against a sampling floor of 1.7e-04.
- The responsibility is a posterior, exactly. Computing the joint over the marginal reproduces Equation 11.17 to 0.0, not approximately.
- That is what licenses three earlier moves: summing responsibilities as counts, differentiating a soft assignment, and alternating at all.
- The M-step is the exact argmax of Q, the expected complete-data log-likelihood — matched by a forty-restart numerical search to 5.3e-15, with every parameter agreeing to six decimals.
- So the three weighted averages of Section 11.2 are not heuristics. They are a closed-form maximisation of something.
- L equals Q plus the entropy of the responsibilities, measured to 1.1e-14, so Q is a lower bound that is tight at the current parameters.
- Raising a tight lower bound cannot lower what it bounds, which is page 1107’s monotonicity guarantee with a reason attached.
- And L rises by more than Q does — 13.915050 against 13.480070 — because the new responsibilities are sharper, so the entropy grows too.
- The generative story also supplies a truth to recover. Fitting data generated from known parameters, the errors fall by factors of 10, 20 and 11 as N goes from 200 to 200,000.
- Without Section 11.4 that check does not exist: you can measure a likelihood, but you cannot ask whether the parameters are right.
Next: Chapter 11 Worked Problems — problems built from the chapter’s own claims, this module’s own.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading