Skip to content

Updating the Mixture Weights

Two updates down, one to go — and this one is different. The means and covariances were unconstrained, so setting a derivative to zero was enough. The weights have to stay on a simplex, so §11.2.4 is the only place in the chapter that reaches for Chapter 7.

  • Theorem 11.3, Equation 11.42, and Example 11.5 reproduced: 130.293890, 0.287001, 0.419109\tfrac13 \to 0.293890,\ 0.287001,\ 0.419109, which round to the book’s 0.290.29, 0.290.29 and 0.420.42.
  • The Lagrangian of Equations 11.43–11.48, and λ\lambda solved from each component separately: exactly 7=N-7 = -N, all three agreeing to 0.00.0.
  • Why the constraint is not a formality: the gradient of LL in π\boldsymbol\pi is strictly positive in every coordinate, so unconstrained ascent sends every weight to infinity.
  • Why no projection onto the simplex is ever needed afterwards: measured over 50,00050{,}000 random responsibility matrices, the weights sum to 11 to 2.2×10162.2\times10^{-16} and none ever leaves [0,1][0,1].
  • What this update alone is worth: +0.137132+0.137132 nats, the smallest of the three.
  • The complete cycle, matching the book’s own figures: negative log-likelihood 28.32553614.410485\mathbf{28.325536 \to 14.410485}, printed as 28.314.428.3 \to 14.4.
  • And the one structural thing that separates this update from the other two: it never looks at x\mathbf{x}.

The first two updates asked where and how wide. This one asks how much, and the answer is the one you would write down without any calculus: the share of the data each component ended up owning.

NkN_k is that share — page 1103’s effective count. Divide by NN and you have a proportion. The Lagrange multiplier’s entire job is to confirm that the obvious answer is also the optimal one, and the multiplier it produces, N-N, is exactly the normalising constant you would have divided by anyway.

diagram Why this one needs Chapter 7 and the others do not mermaid

Theorem 11.3 (Update of the GMM Mixture Weights). The mixture weights of the GMM are updated as

πknew=NkN,k=1,,K(11.42)\pi_k^{\text{new}} = \frac{N_k}{N}, \qquad k = 1,\ldots,K \qquad \text{(11.42)}

The proof accounts for kπk=1\sum_k\pi_k = 1 with a Lagrange multiplier:

L=L+λ(k=1Kπk1)(11.43a)\mathfrak{L} = L + \lambda\left(\sum_{k=1}^{K}\pi_k - 1\right) \qquad \text{(11.43a)} Lπk=1πkn=1NπkN(xnμk,Σk)jπjN(xnμj,Σj)=Nk+λ=Nkπk+λ(11.44b)\frac{\partial\mathfrak{L}}{\partial\pi_k} = \frac{1}{\pi_k}\underbrace{\sum_{n=1}^{N}\frac{\pi_k\mathcal{N}(\mathbf{x}_n\mid\boldsymbol\mu_k,\boldsymbol\Sigma_k)}{\sum_j\pi_j\mathcal{N}(\mathbf{x}_n\mid\boldsymbol\mu_j,\boldsymbol\Sigma_j)}}_{=\,N_k} + \lambda = \frac{N_k}{\pi_k} + \lambda \qquad \text{(11.44b)}

Setting both partials to zero gives πk=Nk/λ\pi_k = -N_k/\lambda and kπk=1\sum_k\pi_k = 1, so kNk/λ=1-\sum_k N_k/\lambda = 1, and since kNk=N\sum_k N_k = N:

λ=N(11.48)\lambda = -N \qquad \text{(11.48)}

Measured, solving λ=Nk/πk\lambda = -N_k/\pi_k from each component independently:

λ\lambda
from k=1k=17.000000000000-7.000000000000
from k=2k=27.000000000000-7.000000000000
from k=3k=37.000000000000-7.000000000000
N-N7-7

with a largest deviation of 0.00.0, and Equation 11.44b’s stationarity condition Nk/πk+λN_k/\pi_k + \lambda equal to +0.0+0.0 in every component.

kkπk\pi_k beforeπk\pi_k afterthe bookNkN_k
110.3333330.3333330.293890\mathbf{0.293890}0.290.292.0572282.057228
220.3333330.3333330.287001\mathbf{0.287001}0.290.292.0090082.009008
330.3333330.3333330.419109\mathbf{0.419109}0.420.422.9337632.933763

summing to 1.0000000000000001.000000000000000.

It is tempting to treat kπk=1\sum_k\pi_k = 1 as bookkeeping — enforce it at the end and move on. It cannot be done that way, because there is no unconstrained optimum to enforce it on. From Equation 11.44a,

Lπk=n=1NN(xnμk,Σk)jπjN(xnμj,Σj)>0\frac{\partial L}{\partial\pi_k} = \sum_{n=1}^{N}\frac{\mathcal{N}(\mathbf{x}_n\mid\boldsymbol\mu_k,\boldsymbol\Sigma_k)}{\sum_j\pi_j\mathcal{N}(\mathbf{x}_n\mid\boldsymbol\mu_j,\boldsymbol\Sigma_j)} > 0

— a sum of positive terms, in every coordinate. Plain gradient ascent:

stepπ\boldsymbol\pikπk\sum_k\pi_k
000.3333, 0.3333, 0.33330.3333,\ 0.3333,\ 0.33331.0000001.000000
110.4531, 0.4535, 0.51340.4531,\ 0.4535,\ 0.51341.4200001.420000
220.5411, 0.5418, 0.63040.5411,\ 0.5418,\ 0.63041.7133361.713336
660.7925, 0.7936, 0.95080.7925,\ 0.7936,\ 0.95082.5369432.536943
figure Without the constraint there is nothing to find; with it, the answer is a count matplotlib
Left, a red curve climbing steadily away from a flat dashed blue line at one. Right, three identical bars all reaching minus seven, against a dashed line at the same level. Left, a red curve climbing steadily away from a flat dashed blue line at one. Right, three identical bars all reaching minus seven, against a dashed line at the same level.
Every unnormalised weight makes the likelihood larger, so the unconstrained problem has no maximum — the left panel simply climbs. On the right, lambda solved separately from each of the three components gives minus seven every time, which is minus N.

And afterwards, the constraint never needs enforcing again

Section titled “And afterwards, the constraint never needs enforcing again”

Because πk=Nk/N\pi_k = N_k/N with Nk0N_k \geq 0 and kNk=N\sum_k N_k = N:

50,00050{,}000 random responsibility matrices, K=4K = 4value
worst kπk1\lvert\sum_k\pi_k - 1\rvert2.2×10162.2\times10^{-16}
weights falling outside [0,1][0,1]0\mathbf{0}

No clipping, no renormalisation, no projection. This is the same kind of structural guarantee page 1105 found for positive semi-definiteness — the update produces a valid object because of what it is, not because anything checks it afterwards.

Applying all three updates in §11.3’s order, one at a time:

afternegative log-likelihoodgained
the initialisation28.32553628.325536
++ means (§11.2.2)16.00415016.00415012.32138512.321385
++ variances (§11.2.3)14.54761714.5476171.4565331.456533
++ weights (§11.2.4)14.410485\mathbf{14.410485}0.1371320.137132
figure The book's 28.3 and 14.4, and the two steps in between matplotlib
Top, four density plots: the first has three humps well away from the data ticks, and each subsequent one sits more tightly over them. Bottom, a descending line from 28.325536 to 14.410485 with the drop at each step labelled. Top, four density plots: the first has three humps well away from the data ticks, and each subsequent one sits more tightly over them. Bottom, a descending line from 28.325536 to 14.410485 with the drop at each step labelled.
The means do most of the work — 12.321385 of the 13.915051 nats gained — because the initialisation put them furthest from the data. The weights do the least, 0.137132, because with three roughly equal clusters there was not much to reallocate.

μk\boldsymbol\mu_k and Σk\boldsymbol\Sigma_k are averages of x\mathbf{x}. πk\pi_k is a count. Holding the responsibility matrix fixed and permuting the data values:

dataπ\boldsymbol\pi
2.5, 2, 1, 0, 5, 4, 3-2.5,\ 2,\ -1,\ 0,\ 5,\ 4,\ -30.293890, 0.287001, 0.4191090.293890,\ 0.287001,\ 0.419109
3, 2.5, 0, 5, 2, 1, 4-3,\ -2.5,\ 0,\ 5,\ 2,\ -1,\ 40.293890, 0.287001, 0.4191090.293890,\ 0.287001,\ 0.419109
the original0.293890, 0.287001, 0.4191090.293890,\ 0.287001,\ 0.419109

Identical, because Equation 11.42 reads only the column sums of r\mathbf{r}. The data enters the weight update only through the responsibilities — which is exactly the structure §11.4.5 will formalise as the E-step supplying sufficient statistics to the M-step.

pch.quizTag Is the weight update clear?
  1. Why does Section 11.2.4 need a Lagrange multiplier when Sections 11.2.2 and 11.2.3 do not?

    pch.quizShowAnswer

    B — Because the log-likelihood's gradient in pi is strictly positive in every coordinate, so there is no unconstrained stationary point to find — Measured: plain gradient ascent takes the weights from summing to 1 to summing to 2.54 in six steps and keeps climbing. The means and covariances have genuine interior optima; the weights only have one once the simplex constraint is imposed.

  2. What does the Lagrange multiplier come out to be?

    pch.quizShowAnswer

    B — Exactly minus N — it is the normalising constant, because the N_k already sum to N — Solved independently from each of the three components it gives minus 7.000000000000 every time, to a deviation of 0.0. Contrast Section 10.2's Lagrangian, where the multiplier was an eigenvalue and carried real information; here the constraint only rescales.

  3. After the update, how are the weights kept on the simplex?

    pch.quizShowAnswer

    B — Nothing is needed — N_k over N is automatically non-negative and sums to one, because the responsibilities' rows sum to one — Measured over 50,000 random responsibility matrices with K = 4: the weights sum to 1 to 2.2e-16 and not one falls outside [0, 1]. The same kind of structural guarantee page 1105 found for positive semi-definiteness.

  4. What is structurally different about the weight update compared to the other two?

    pch.quizShowAnswer

    B — It never looks at the data values — only at the column sums of the responsibility matrix — Permuting the data while holding the responsibilities fixed leaves the weights identical to six decimals. The means and covariances are averages of x; the weight is a count. Section 11.4.5 formalises this as the E-step passing sufficient statistics to the M-step.

Exercise 1 – Reproduce Example 11.5, and solve for lambda

Section titled “Exercise 1 – Reproduce Example 11.5, and solve for lambda”

Exercise 2 – Try it without the constraint

Section titled “Exercise 2 – Try it without the constraint”

Exercise 3 – The simplex takes care of itself

Section titled “Exercise 3 – The simplex takes care of itself”

Exercise 4 – The complete cycle, and the book’s two numbers

Section titled “Exercise 4 – The complete cycle, and the book’s two numbers”

Exercise 5 – The weights never see the data

Section titled “Exercise 5 – The weights never see the data”
  • Theorem 11.3: each weight becomes that component’s share of the data, its total responsibility divided by the number of points.
  • This is the only update in the chapter that needs a Lagrange multiplier, because the weights must lie on a simplex and the other two parameters are unconstrained.
  • The constraint is not bookkeeping. The log-likelihood’s gradient in the weights is strictly positive in every coordinate, so unconstrained ascent has nothing to converge to — measured, the weights’ sum reaches 2.54 in six steps and keeps climbing.
  • The multiplier comes out as exactly minus N, solved independently from each component to a deviation of zero. It is the normalising constant, not new information.
  • Contrast Section 10.2’s Lagrangian, where the multiplier was an eigenvalue and told you the variance retained.
  • Afterwards the simplex looks after itself: over fifty thousand random responsibility matrices the weights sum to one to 2.2e-16 and never leave the unit interval.
  • Example 11.5 reproduced: a third becomes 0.293890, 0.287001 and 0.419109, rounding to the book’s 0.29, 0.29 and 0.42.
  • The complete cycle takes the negative log-likelihood from 28.325536 to 14.410485, which is the book’s 28.3 and 14.4.
  • The means supply 12.32 of the 13.92 nats gained, the variances 1.46, the weights 0.14 — an ordering that reflects how badly each was initialised.
  • But the weights can only ever reallocate mass between components that already exist, so with balanced clusters their update does almost nothing whatever the initialisation.
  • And this is the only update that never reads the data values. Permuting the data with the responsibilities held fixed leaves the weights identical and moves every mean.

Next: The EM Algorithm — §11.3, which puts the three updates in a loop and states the guarantee that makes the loop worth running.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading