ContentsChapter 11 · Clustering2 of 2

11.2

Gaussian mixtures and EM

In this chapter
  1. 11.1k-means
  2. 11.2Gaussian mixtures and EM
Before you readTwo machines make the same part. Their lengths overlap, and machine A makes three quarters of the parts. If a length is equally typical of both machines, which machine probably made it?
Watch: Gaussian mixture models and EM · Alexander Ihler

A Gaussian mixture models each group with a bell curve rather than just a centre. First choose a component jj with probability πj\pi_j then draw xx from its Gaussian density fjf_j The weights πj\pi_j sum to one, and the overall density is

p(x)=∑jπjfj(x).p(x) = \sum_j \pi_j f_j(x).

Given a point xix_i reverse the question: how likely is each component to have drawn it? By Bayes’ rule, the responsibility of component jj is

rij=πjfj(xi)∑ℓπℓfℓ(xi).r_{ij} = \frac{\pi_j f_j(x_i)}{\sum_\ell \pi_\ell f_\ell(x_i)}.

Divide the component’s weighted curve height by the total height at that point. The responsibilities across components sum to one. A half-and-half answer is allowed: this is soft assignment.

00.10.2-6-3036AB
A responsibility = 75.0%B responsibility = 25.0%
Curve heights include the weights (A: 0.75, B: 0.25). Move x to the right of zero. How far until B is more likely than A?

At the midpoint in the figure, the unweighted Gaussian heights are equal. The responsibility for A is still 0.750.75 because A has three times the weight. In several dimensions, a component’s covariance also affects its height: a Gaussian can be long and narrow, not just round.

Fit the mixture with EM

If we knew which machine made each part, we could count the parts and estimate each machine’s mean and spread. If we knew the machines’ distributions, we could estimate who made each part. Expectation–maximisation (EM) alternates between those two tasks:

  1. E-step: using the current weights and Gaussians, calculate every rijr_{ij}
  2. M-step: use those responsibilities as fractional counts. With Nj=∑irijN_j = \sum_i r_{ij} set the weight to Nj/nN_j/n and the mean to μj=∑irijxi/Nj\mu_j = \sum_i r_{ij} x_i / N_j Update the spread using squared deviations from the new mean, weighted by the same responsibilities.

In one dimension that last update is σj2=∑irij(xi−μj)2/Nj\sigma_j^2 = \sum_i r_{ij}(x_i-\mu_j)^2 / N_j in higher dimensions use the weighted covariance. A point with responsibility 0.80.8 counts four times as much for that component as one with responsibility 0.20.2

These steps do not decrease the data log-likelihood, ∑ilog⁡p(xi)\sum_i \log p(x_i) but the fit can depend on where you start. Compare the two algorithms: k-means updates each centre using only points assigned to it; EM updates each Gaussian using all points, weighted by how much each belongs.

Recall
How do you turn the component densities at a point into responsibilities?
Recall
In a Gaussian mixture, what is held fixed during the E-step and what is held fixed during the M-step?
Exercise
At a point xx component A has weight 0.20.2 and density 0.40.4 B has weight 0.80.8 and density 0.10.1 Give A’s responsibility as a decimal or fraction.
Exercise
Two points 22 and 88 have responsibilities 0.750.75 and 0.250.25 for component A. Give A’s updated mixture weight and its updated mean, in that order, as decimals or fractions.