DS701 Session 7 — Mon Sep 28, 2026
A Gaussian mixture model is a generative story. Describe, in two steps, how the model says a single data point \(x_i\) is produced, and write down the resulting density \(p(x_i \mid \theta)\). What are the parameters \(\theta\)?
In lecture 05 we found the MLE for a single Gaussian by taking the log-likelihood, differentiating, and solving in closed form (sample mean, sample variance). Why does the same approach not work for a mixture, and how do the two EM steps get around it? Say specifically what the E-step and the M-step each compute.
A classmate says “a GMM is just \(k\)-means with probabilities attached.” Name two ways that description is incomplete, and give one dataset the lecture showed where the difference visibly matters.
For each of the \(n\) points, independently:
Forget the die roll and you get the mixture density \[ p(x \mid \theta) = \sum_{k=1}^{K} \pi_k\, \mathcal{N}(x \mid \mu_k, \Sigma_k). \]
Clustering = running the recipe backwards: given only the \(x_i\), recover \(\theta\) and say how each point was probably rolled.

Age 25 in the income example. Black dot: density under below; red dot: density under above.
\[ P(\text{above} \mid 25) = \frac{\text{red}\cdot P(\text{above})}{\text{red}\cdot P(\text{above}) + \text{black}\cdot P(\text{below})} \]
Same thing for every point \(i\) and component \(k\): \[ \gamma_{ik} = \frac{\pi_k\, \mathcal{N}(x_i \mid \mu_k, \Sigma_k)}{\sum_{j} \pi_j\, \mathcal{N}(x_i \mid \mu_j, \Sigma_j)} \]
prior \(\pi_k\), likelihood \(\mathcal{N}(\cdot)\), evidence = the mixture density. Rows sum to 1.

One Gaussian (lecture 05) — the MLE: \[ \bar\mu = \frac{1}{N}\sum_{i} x_i, \qquad \bar\sigma^2 = \frac{1}{N}\sum_{i} (x_i - \bar\mu)^2 \]
Component \(k\) of a mixture — with \(N_k = \sum_i \gamma_{ik}\): \[ \mu_k = \frac{1}{N_k}\sum_i \gamma_{ik}\, x_i, \quad \Sigma_k = \frac{1}{N_k}\sum_i \gamma_{ik}\,(x_i-\mu_k)(x_i-\mu_k)^{\!T}, \quad \pi_k = \frac{N_k}{n} \]
max_iter.
covariance_type="full"
covariance_type is where the assumption becomes a dial (\(K\) components in \(d\) dimensions):
| type | each \(\Sigma_k\) is | shape | covariance parameters |
|---|---|---|---|
spherical |
\(\sigma_k^2 I\) | circle, own radius | \(K\) |
diag |
diagonal | axis-aligned ellipse | \(Kd\) |
tied |
one shared \(\Sigma\) | same ellipse everywhere | \(\sim d^2\) |
full |
its own \(\Sigma_k\) | any ellipse | \(\sim Kd^2\) |
More parameters need more data per cluster; fewer parameters is a stronger claim about the world. Today’s activity makes you see the difference — and see what a 50/50 responsibility looks like next to a \(k\)-means boundary.
Goal: implement the E-step and M-step yourself on a 1-D two-component mixture, iterate while watching the log-likelihood climb, check against sklearn.mixture.GaussianMixture — then go to 2-D: responsibilities as color intensity next to \(k\)-means’ straight boundaries, the four covariance types as fitted ellipses, and one point the GMM calls 50/50.
numpy, scipy, matplotlib, scikit-learn only.The activity notebook goes live on the day of the lecture. Colab is optional — you can also open it on GitHub and run it locally.
Full lecture notes: Soft Clustering with Gaussian Mixture Models
full / tied / diag / spherical