Suppose you record the heights of everyone in a school: students and teachers. Plot a histogram and you see two humps, one around the typical student height and one around the typical adult height. A single Gaussian, with one peak, describes this badly: its maximum likelihood fit puts the peak in the valley between the humps, where hardly anyone is. The data is multimodal, and we need a model that can have several peaks. The Gaussian mixture model (GMM) is the standard answer, and it is also a probabilistic version of clustering.
The generative story
A GMM with components explains each data point by a two-step random process.
- Choose a component. Pick at random, with . The mixing proportions are non-negative and sum to 1.
- Draw from that component. Given , draw from a Gaussian with mean and variance (in dimensions, mean vector and covariance matrix ).
For the school, : component 1 is "student", component 2 is "teacher", and is the fraction of students. Each component has its own centre and its own spread, unlike k-means, where every cluster is described by a centre alone.
The parameters to estimate are
which is numbers in one dimension (the must sum to 1).
Latent variables
We observe the heights but not which component produced each one: nobody wrote "student" or "teacher" next to the measurements. The component choices are latent (hidden) variables. They are exactly the cluster indicators of k-means, except that now they are random, and we will reason about their probabilities instead of assigning them outright.
The mixture density
The probability density of a single observation is found by summing over the component it might have come from:
where is the Gaussian density. It is a weighted average of bell curves, which can have up to peaks and many other shapes. With enough components, a Gaussian mixture can approximate essentially any smooth density, which makes it a general-purpose tool for density estimation as well as clustering.
The log-likelihood, and why it is hard
With i.i.d. data, the log-likelihood is
Compare it with a single Gaussian. There the log could pass through to the exponent, the log-likelihood became a simple quadratic in , and setting its derivative to zero gave the answer in one line. Here the log sits outside a sum, and the derivative with respect to becomes
Setting it to zero does not give a closed-form solution: the weights in front of each term depend on every parameter, including itself. There is no formula for the maximum likelihood estimate of a GMM.
There are further complications. The log-likelihood is not concave, so it can have several local maxima. Swapping the labels of two components gives the same likelihood, so the maxima come in groups of equivalent solutions. And if one component shrinks onto a single data point (, ), its density at that point grows without bound, so the likelihood itself is unbounded: an unconstrained maximum likelihood fit can "cheat" by collapsing a component. In practice a small floor on the variances prevents this.
A clue in the derivative
Look again at the weight in the derivative above:
By Bayes' rule, this is exactly : the probability that point came from component , given its value. It is called the responsibility of component for point . If we knew the responsibilities, setting the derivative to zero would give a simple weighted mean:
And if we knew the parameters, computing the responsibilities would be easy. This chicken-and-egg structure is the same one k-means had (assignments need centres, centres need assignments), and it suggests the same remedy: alternate. The next chapter turns that idea into the EM algorithm and shows why it works.