Skip to content
BIASED

Mixtures and the EM algorithm

Block 1 of 8~2 min

From k-means to a mixture

The topic Clustering ended with k-means and its two blind spots. Every point goes to exactly one cluster, and nothing says how sure that assignment is. And the objective J=∑i∥xi−μci∥2J = \sum_i \lVert x_i - \mu_{c_i} \rVert^2 counts plain distances, so k-means behaves as if every cluster were a round ball of the same width. This topic turns clustering into a probability model and fits it by maximum likelihood.

A Gaussian mixture describes the data by a two-step story. First pick a component zz with probabilities π1,…,πK\pi_1, \dots, \pi_K. Then draw x∈Rdx \in \mathbb R^d from that component's Gaussian:

z∼Categorical(π1,…,πK),x∣z=k  ∼  N(μk,Σk).z \sim \text{Categorical}(\pi_1, \dots, \pi_K), \qquad x \mid z = k \;\sim\; \mathcal N(\mu_k, \Sigma_k) .

Here KK is the number of components, the clusters of the previous topic. The weights satisfy πk≥0\pi_k \ge 0 and ∑kπk=1\sum_k \pi_k = 1. Each component has its own mean μk\mu_k and covariance Σk\Sigma_k, and θ\theta collects all the parameters. The second argument of N(x∣μ,Σ)\mathcal N(x \mid \mu, \Sigma) is a covariance, a variance in one dimension.

The component zz is a latent variable: the model uses it, the data never show it. So the density of xx alone sums the joint p(x,z=k)=πk N(x∣μk,Σk)p(x, z = k) = \pi_k\, \mathcal N(x \mid \mu_k, \Sigma_k) over kk, by the law of total probability:

p(x∣θ)=∑k=1Kπk N(x∣μk,Σk).p(x \mid \theta) = \sum_{k=1}^K \pi_k\, \mathcal N(x \mid \mu_k, \Sigma_k) .

Each component is a multivariate Gaussian with elliptical contours set by Σk\Sigma_k (the topic The multivariate Gaussian in Probability Theory). So a cluster may be tilted, elongated, small or wide, and each has its own weight.

Example. In one dimension take π=(0.3,0.7)\pi = (0.3, 0.7), μ=(0,4)\mu = (0, 4) and standard deviations 11 and 22. At x=2x = 2 the component densities are N(2∣0,1)=0.0540\mathcal N(2 \mid 0, 1) = 0.0540 and N(2∣4,4)=0.1210\mathcal N(2 \mid 4, 4) = 0.1210, so

p(2)=0.3⋅0.0540+0.7⋅0.1210=0.0162+0.0847=0.1009.p(2) = 0.3 \cdot 0.0540 + 0.7 \cdot 0.1210 = 0.0162 + 0.0847 = 0.1009 .

Answers are saved on the server and tied to this browser until you sign in.