Skip to content

Density Estimation Overview

Chapter 10 had no labels and asked for a compact representation. Chapter 11 has no labels either and asks for the density itself: the third of the book’s four pillars, “density estimation, where we are interested in modeling the distribution of the data.”

The chapter opens by admitting the obvious model is inadequate — a single Gaussian cannot have two bumps — and spends the rest of itself on what it costs to fix that.

one Gaussiana mixture of KK
parameters, D=1D = 1, K=3K = 32288
modesalways 11between 11 and KK
fit on the kind of data Figure 11.1 shows1.3886101.388610 nats per point better
the maximum likelihood estimatesample mean and sample variance, Equation 11.11does not exist
finding the parametersone lineSections 11.2, 11.3 and 11.4

The whole chapter follows from one structural fact. Equation 11.10 is

L=n=1Nlogk=1KπkN(xnμk,Σk)L = \sum_{n=1}^{N}\log\sum_{k=1}^{K}\pi_k\,\mathcal{N}(\mathbf{x}_n\mid\boldsymbol\mu_k,\boldsymbol\Sigma_k)

and the logarithm sits outside the sum over components. At K=1K = 1 it lands directly on the Gaussian and the answer is closed-form — confirmed against an optimiser to 6×1086\times10^{-8}. At K>1K > 1 it cannot be moved inside, so the chain rule drags 1/p(xnθ)1/p(\mathbf{x}_n\mid\boldsymbol\theta) into every derivative, and every parameter’s stationarity condition mentions every other parameter.

Equation 11.20 is therefore a fixed point, not a formula. Measured: feeding the means back into their own update moves them by 4.2957134.295713 on the first round, then 0.1307750.130775, then 0.0184140.018414. A formula would move them by zero.

The thread that runs through the chapter is a single ratio. Following it is most of understanding Chapter 11:

where it appearsequationpagewhat it is called there
the factor the chain rule drags into every derivative11.161102nothing yet — it has no name
defined and named11.171103the responsibility rnkr_{nk}
a softmax of minus the energies, matched to 1.1×10161.1\times10^{-16}1103a soft assignment
the weights in all three updates11.20, 11.30, 11.421104–1106importance weights
the E-step11.531107the E-step
the posterior over the latent z\mathbf{z}, matched to 0.00.011.69, 11.72b1108a posterior probability

§11.2 discovers it as an algebraic nuisance. §11.4 shows it was a posterior all along, which is what retroactively licenses everything §11.2 did with it — summing responsibilities as if they were counts, differentiating a soft assignment, alternating at all.

§11.2.2 the means§11.2.3 the covariances§11.2.4 the weights
the update1Nknrnkxn\frac{1}{N_k}\sum_n r_{nk}\mathbf{x}_n1Nknrnk(xnμk)(xnμk)\frac{1}{N_k}\sum_n r_{nk}(\mathbf{x}_n-\boldsymbol\mu_k)(\mathbf{x}_n-\boldsymbol\mu_k)^\topNk/NN_k/N
a weighted average ofthe datathe squared deviationsnothing
needs a Lagrange multipliernonoyesλ=N\lambda = -N
reads the data valuesyesyesno
nats gained on the book’s example12.3212.321.461.460.140.14

The three are the same argument at three moments. Only the weights are constrained — they live on a simplex — which is why only they need a multiplier. Contrast §10.2, where the multiplier was the answer: an eigenvalue, equal to the variance retained. Here λ=N\lambda = -N is the normalising constant and carries no information at all.

Every printed number in the book’s running example reproduces — 28.314.428.3 \to 14.4, the responsibility matrix, all three update examples, “after five iterations”. Six things that turned up beyond them:

The maximum likelihood estimate does not exist. §11.5 says the likelihood “approaches infinity” when a component collapses onto a data point. Measured, it reaches +16.377668+16.377668 at σ2=1030\sigma^2 = 10^{-30} and keeps going. Of 400400 restarts on the book’s seven points, 218\mathbf{218}54.5%54.5\% — collapse a component, and every one reports a higher likelihood than every genuine fit. So the whole chapter is an algorithm for maximising something with no maximum, and page 1109 prices the usual patch: a variance floor buys exactly 12ln10=1.1513\tfrac12\ln 10 = 1.1513 nats per decade.

The book’s own initialisation lands in the worse of two basins. Among the honest fits there are exactly two optima. Example 11.6 converges to 13.973323-13.973323; another basin reaches 13.906162-13.906162, a better non-degenerate fit by 0.0671610.067161 nats.

One entry of Equation 11.19 disagrees with the arithmetic. At x=0x = 0 the book prints 0.0010.001 and 0.9990.999; the computed values are 0.0001500.000150 and 0.9998440.999844. The largest disagreement across the printed matrix is 0.0010.001 — a rounding artefact, but the responsibility matrix is the one table in the chapter a reader is most likely to reproduce by hand.

Equation 11.30 does not say which mean it uses, and it matters by a factor of 13.087813.0878. The old means give 1.831.83, 0.600.60, 19.9819.98; the just-updated means give the book’s 0.140.14, 0.440.44, 1.531.53. The M-step’s ordering is the answer, and §11.3 states it only in the order the equations happen to appear.

Two conservation laws the chapter never states. After any M-step, kNkμk=nxn\sum_k N_k\boldsymbol\mu_k = \sum_n \mathbf{x}_n exactly — the mixture’s mean is pinned to the sample mean. Stronger: the mixture’s variance equals the sample variance exactly, measured to 3.6×10153.6\times10^{-15} over 20,00020{,}000 arbitrary responsibility matrices and every KK from 22 to 1010. EM cannot make the model wider or narrower than the data — it only redistributes spread between “within components” and “between components”, which is page 1101’s decomposition in motion.

The monotonicity guarantee, measured to the last bit. Over 180,000180{,}000 EM steps, 11,16311{,}163 register a negative change in LL. None exceeds 8.9×10158.9\times10^{-15}, and the median decrease is 1.776×10151.776\times10^{-15} — exactly one unit in the last place of a log-likelihood near 14-14. The theorem is about real numbers; a convergence test must compare against a tolerance and never against zero.

#pagebook sectionthe measured claim
1101The Gaussian Mixture Model§11.1two Gaussians merge into one bump at exactly 2σ2\sigma apart
1102Maximum Likelihood and Its Obstacle§11.21717 optima on 77 points; 54.5%54.5\% of restarts collapse
1103Responsibilities§11.2.1Equation 11.17 as written returns 2121 NaNs of 2121
1104Updating the Means§11.2.2kNkμk=nxn\sum_k N_k\boldsymbol\mu_k = \sum_n\mathbf{x}_n to 3.6×10153.6\times10^{-15}
1105Updating the Covariances§11.2.3the mixture’s variance is the sample variance, always
1106Updating the Mixture Weights§11.2.4the multiplier is exactly N-N, deviation 00
1107The EM Algorithm§11.311,16311{,}163 of 180,000180{,}000 steps go down, by one ULP
1108The Latent Variable Perspective§11.4the M-step is the exact argmax of QQ, to 5.3×10155.3\times10^{-15}
1109Chapter 11 Worked Problems§11.5eight problems, this module’s own
1110Chapter 11 Formula Sheetevery equation and every measured constant

§11.4 arrives after the algorithm already works, which makes it easy to skip. It is not optional:

what §11.2 haswhat §11.4 addsmeasured
rnkr_{nk}, a ratio that appeared in a derivativernk=p(zk=1xn)r_{nk} = p(z_k=1\mid\mathbf{x}_n), a posterioragreement 0.00.0
three weighted averages that workthe exact argmax of Q(θθ(t))Q(\boldsymbol\theta\mid\boldsymbol\theta^{(t)})5.3×10155.3\times10^{-15} over 4040 restarts
LL does not decrease” as an assertionL=Q+H(r)L = Q + H(\mathbf{r}), so QQ is a tight lower bound1.1×10141.1\times10^{-14}
a fitted densitya generative process — and therefore a truth to recovererrors fall 10×10\times, 20×20\times, 11×11\times as NN grows

That last row is the one that matters most in practice. Without a generative story you can measure a likelihood but you cannot ask whether the parameters are right. With one, you can generate data from known parameters, fit it, and watch the error fall — which is how every claim on pages 1107 and 1109 was checked.

What the chapter assumes, and what those assumptions cost

Section titled “What the chapter assumes, and what those assumptions cost”

§11.5 is a page of caveats. Page 1109 runs each one:

the assumptionmeasured
“the number of components KK is known”held-out likelihood, BIC and AIC pick 33, 33 and 44 on one table
— and as NN growsBIC reaches 20/2020/20; held-out likelihood peaks at 19/2019/20 and falls back to 14/2014/20
— and on data that is not a mixture of Gaussiansa uniform asks for 55 or 66; a Student-tt asks for 33 that mean nothing
the likelihood has a maximumit does not, and a floor only prices the singularity
the components are distinguishableevery optimum has K!K! identical copies, spread 0.000×1000.000\times10^{0}
the non-parametric alternativea KDE stores 600600 points to finish 13.713.7 nats behind 88 numbers

The last two rows say something worth carrying forward. A GMM’s KK is a count only when the data really is made of groups; otherwise it is a budget for approximating a shape, and no criterion in the chapter can tell the difference. And the clustering reading of the GMM — component kk is a group, rnkr_{nk} is a soft membership — is an interpretation the mathematics does not supply. §11.5’s own comparison to K-means is measured on page 1103: from the same starting means the two methods land 1.5041191.504119 apart and split seven points 33-22-22 against effectively 22-22-33, because K-means has no variances with which to weigh a tight cluster against a loose one.

§11.5’s pointerand where it already appeared
K-means — the hard-assignment limitpage 1103 drove the variances to zero and measured the disagreement
nested cross-validation for choosing KKpage 1109 ran it, and found where it stops working
a Bayesian prior on the parametersremoves the singularity page 1102 measured; gives the model evidence BIC approximates
variational inference for the resulting posteriorChapter 8’s §8.4, and the marginal likelihood of page 908
EM for general latent-variable modelspage 1108’s QQ and H(r)H(\mathbf{r}) never mention Gaussians
kernel density estimationpage 1109 put it on the same held-out set

And the last pillar: Chapter 12 turns to classification, with support vector machines.

  • Chapter 11 estimates a density, the third pillar, and starts by admitting a single Gaussian often cannot do it.
  • A mixture buys multimodality cheaply — 1.388610 nats per point for twelve extra parameters — and pays with the closed form.
  • The logarithm in Equation 11.10 sits outside a sum over components, so it cannot reach the Gaussians, and every parameter’s equation ends up mentioning every other.
  • So Equation 11.20 is a fixed point, not a formula. Feeding it back into itself moves the means by 4.295713 on the first round.
  • One ratio appears six times under five names — a nuisance factor in a derivative, the responsibility, a softmax, an importance weight, the E-step, and finally a posterior.
  • Section 11.4 is what licenses Section 11.2, retroactively: summing responsibilities as counts and differentiating a soft assignment are only legitimate because the responsibility is a posterior.
  • The three updates are one derivation run at three moments, and only the mixture weights need a Lagrange multiplier because only they are constrained.
  • EM conserves the data’s mean and its variance exactly, after every M-step, for every K. It only moves spread between within-component and between-component.
  • The maximum likelihood estimate does not exist. The likelihood is unbounded above, 54.5 percent of restarts on seven points collapse a component, and every collapse outscores every honest fit.
  • The monotonicity guarantee holds to one unit in the last place, so convergence must be tested against a tolerance rather than against zero.
  • Overlap sets the convergence rate — 1045 iterations at 53 percent ambiguous against 3 at none — and a K-means initialisation removes the long tail.
  • The chapter’s heaviest assumption is that K is known. Held-out likelihood is not even a consistent estimator of it, and on data that is not a mixture of Gaussians K stops being a count at all.

Start here: The Gaussian Mixture Model

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading