Quiz: fitting a mixture with EM

Short questions to test your understanding. Try each on paper first, then open the answer. E-step: responsibilities r_{ik}; M-step: N_k = \sum_i r_{ik}, \pi_k = N_k/n, weighted means and covariances.


Q1. In one sentence each: what does the E-step compute, and what does the M-step compute?

One step uses the parameters to get labels, the other the labels to get parameters.

E-step: with the current parameters, the responsibility of every component for every point (soft labels, by Bayes’ rule). M-step: with these responsibilities as weights, new weights \pi_k, means and covariances (a weighted fit of each Gaussian).


Q2. Three points x = 0, 1, 10 have responsibilities r_{i1} = 1, 0.5, 0 for component 1. What are N_1, \mu_1 and \pi_1 after the M-step?

Weighted mean with weights r_{i1}.

N_1 = 1.5, \mu_1 = (1 \cdot 0 + 0.5 \cdot 1 + 0 \cdot 10)/1.5 = 0.33, \pi_1 = 1.5/3 = 0.5.


Q3. What do you have to change in EM to get exactly k-means?

Labels, covariances, weights.

Make the labels hard (each point fully to its nearest centre), give every component the same round covariance \sigma^2 I (not re-estimated) and equal weights (not re-estimated). Equivalently: equal round covariances with \sigma \to 0, where the soft responsibilities become 0 or 1 by themselves.


Q4. The log-likelihood plot of your EM run shows a drop between two iterations. What can you conclude?

What does the theory say about EM’s log-likelihood?

Something is not plain EM: a bug, a numerical problem (for instance a variance clipped at a floor in a way the M-step does not account for), or a modified algorithm (hard assignments, fixed weights). Exact EM never decreases the log-likelihood.


Q5. Two runs of EM on the same data end with log-likelihoods −1520 and −1384. Which do you keep, and why can this happen?

Local maxima.

Keep the run with −1384 (higher likelihood). EM only finds a local maximum, which depends on the start; the other run got stuck, for example with two components sharing one group.


Q6. One component of your fit has a variance of 10^{-9} and sits on a single pixel value, and the log-likelihood is huge. What happened, and how do you prevent it?

What is the density of a Gaussian at its centre when σ → 0?

The component collapsed onto one data point: its density there grows like 1/\sigma, so the likelihood is unbounded, although the fit is useless. Prevent it with a variance floor (add \varepsilon to every variance), by restarting collapsed components, or with a prior on the covariances. Many identical values (e.g. saturated pixels) make it especially likely.


Q7. Adding a fourth component raises \log p(\mathcal D) from −2050 to −2046 on n = 500 points; it adds 6 parameters. Does BIC accept it? Does AIC?

Compare 2 \times the gain in log-likelihood with p\ln n and with 2p.

-2\log p drops by 8. BIC adds 6\ln 500 = 37.3: worse by 29.3, rejected. AIC adds 12: worse by 4, also rejected. (With a gain of 10 in \log p, i.e. 20 in -2\log p, AIC would accept and BIC still reject.)


Q8. Why is the log-likelihood alone useless for choosing the number of components?

What happens with one component per point?

More components (or more flexible covariances) can only fit the same data at least as well, so the maximum likelihood never decreases with K; with one component per point it is even infinite. A penalty for the number of parameters (BIC, AIC), or a test on held-out data, is needed.


Q9. (math) Show that for any distribution q(k) over the components, \log p(\mathbf x) \ge \sum_k q(k)\log\frac{\pi_k\mathcal N_k(\mathbf x)}{q(k)}, with equality when q(k) = r_k(\mathbf x).

Jensen’s inequality for the concave \log: \log E[Y] \ge E[\log Y].

\log p(\mathbf x) = \log\sum_k q(k)\,\frac{\pi_k\mathcal N_k(\mathbf x)}{q(k)} = \log E_q[Y] \ge E_q[\log Y] with Y = \pi_k\mathcal N_k(\mathbf x)/q(k). For q(k) = r_k(\mathbf x) = \pi_k\mathcal N_k(\mathbf x)/p(\mathbf x), Y = p(\mathbf x) for every k: a constant, so both sides equal \log p(\mathbf x).