A sample of measurements can mix two overlapping subpopulations, so that a value lying between them could plausibly come from either. A hard clustering such as k-means must still put that value in exactly one group. A Gaussian mixture model instead describes the whole distribution as a weighted sum of normal densities and gives every observation a probability of coming from each component. This lesson defines the model and its hidden component labels, computes those probabilities, carries out one exact iteration of the expectation-maximization algorithm on four constructed observations, and shows why the likelihood that the algorithm increases can grow without bound.
Key terms
Gaussian mixture model
Definition A Gaussian mixture model with components gives a feature vector in the density
where the mixing weights satisfy and , each mean lies in , each covariance matrix is symmetric positive definite, and
is the normal density with . In one dimension a component has a mean and a variance , and
The parameters are all weights, means and covariances, and the number of components is chosen by the analyst, for example by comparing log likelihoods on validation data. Exchanging the labels of two components together with their parameters gives the same density, so a component label has no meaning of its own.
In plain words The model blends bell-shaped densities, each with its own center, spread and share of the data. A blend of two components need not have two humps. With equal weights and a common variance , two one-dimensional components give a single hump whenever their means are at most apart. A component is a piece of a density model, so it need not correspond to a real subgroup, and one skewed group can need several components.
Example Four constructed one-dimensional observations, without units, are , , and . A starting model has , weights , means and , and variances . Its means are 3 apart, more than , so its density has two humps. At the component densities are about 0.398942 and 0.004432, and the mixture density is their average, about 0.201687. Swapping the two components gives the same density at every .
Latent variable
Definition A latent variable is a random variable of a model that is never observed. In a Gaussian mixture each observation has a latent component label with values in , and the model generates the data in two stages,
with the pairs independent across . The joint density of an observation and its label is , and summing it over gives back the mixture density, so the mixture is the distribution of once the label is ignored. The pairs are called the complete data and the observations alone the observed data.
In plain words Picture each observation as made in two moves. First a hidden component is drawn with probabilities , then a value is drawn from that component’s normal distribution, and only the value is recorded. If the labels were known, fitting would reduce to an ordinary proportion, mean and variance for each group. Not knowing them is what makes the problem harder. The hidden label is part of a model’s account of how the data could arise, not a measured fact.
Example In the starting model, , and given the observation is drawn from . The observation could also have come from component 2, since a normal density is positive everywhere. It is only much less likely. If the labels of the four observations were known to be 1, 1, 2 and 2, the group means would be and , and the group variances, dividing by the group size, would be 0.25 each.
Responsibility
Definition Write for . Under parameters , the responsibility of component for observation is the posterior probability of its label given the observation, obtained from Bayes’ rule with densities,
Each lies in , and . A soft assignment gives observation the whole vector . A hard assignment keeps only a component with the largest responsibility, with a rule for ties. The values are densities, not probabilities. They can exceed 1 and need not add to 1 over , and they become probabilities only after weighting by and normalizing. With equal weights and a common covariance , the largest responsibility belongs to the nearest mean, which is the k-means assignment rule. In computation, work with , subtract the largest of these values, exponentiate and normalize, which gives the same result without underflow.
In plain words A responsibility answers the question of how likely each component is to have produced this observation, given the current model. The weights play the part of prior probabilities and the densities say how well each component explains the value. A point near one mean and far from the others gets a share near 1, and a point between overlapping components gets sizable shares in several.
Example For under the starting model, the densities are and , and the equal weights cancel, so . For any in this model,
so the responsibility of component 1 is , the logistic sigmoid of .
| Observation | ||
|---|---|---|
A hard assignment gives the labels 1, 1, 2 and 2 and discards the small chance of the other component. At , halfway between the means, the two densities are equal, so with equal weights the responsibilities are each and a hard assignment needs its tie rule. With weights and the responsibility of component 1 at becomes , all of it from the prior.
E step and M step
Definition One iteration of the expectation-maximization algorithm for a Gaussian mixture starts from current parameters and has two steps. The E step computes every responsibility from the current parameters. The M step holds those responsibilities fixed and sets
where . In one dimension the last line is a weighted variance with in place of . These values maximize the expected complete-data log likelihood
over all parameters, for the fixed responsibilities, provided every and every is positive definite. Setting the derivative with respect to to zero gives the weighted mean, and maximizing the weighted sum of under gives . The effective count need not be a whole number, and the covariance divides by , as maximum likelihood does, not by . A component with or a singular has no valid update and needs a declared rule.
In plain words The E step asks, for each observation, how much each component explains it. The M step refits every component as if each observation belonged to it with that fractional weight, giving a weighted proportion, a weighted mean and a weighted spread. With hard labels these would be the ordinary group proportions, means and variances.
Example From the responsibility table, , exactly, because the shares at and and at and mirror each other. So and both weights stay . The weighted sum is about , so . The data and the starting model are symmetric about , so . The weighted squared deviations of component 1 from its new mean are about 0.268033, 0.229903, 0.133220 and 0.011105, so
and component 2 gets the same variance. The means moved outward toward and , and the variances shrank from 1 to about 0.321.
Expectation-maximization algorithm
Definition The expectation-maximization (EM) algorithm is an iterative method for maximum likelihood estimation in a model with observed data , latent variables and parameters . It seeks a large value of the log likelihood , where the density of the observed data has the latent variables summed out. For a Gaussian mixture with independent observations, . Starting from , iteration computes the posterior distribution of under in the E step, and in the M step chooses to maximize the expected complete-data log likelihood under that posterior. It stops when the change in log likelihood or in the parameters falls below a stated tolerance, or after a stated maximum number of iterations. For every probability distribution on the latent values that is positive at each value, Jensen’s inequality for the concave logarithm gives
with equality when is the posterior under . Let be the right side with equal to the posterior under . The M step maximizes , because differs from the expected complete-data log likelihood by a term that does not depend on . With exact steps,
So the log likelihood never decreases, and when it is bounded above its values converge. The limit can be a local maximum or another stationary point rather than a global maximum, and different starting values can lead to different fits.
In plain words EM alternates between guessing the hidden labels softly from the current parameters and refitting the parameters to those soft guesses. Each guess builds a lower bound on the log likelihood that touches it at the current parameters, and the refit climbs that bound, so the log likelihood cannot fall. That makes EM stable, but a likelihood that has stopped rising only shows that the algorithm reached a stationary point. Running several starting values and comparing the results is standard practice.
Example With natural logarithms, the log likelihood of the four observations is about under the starting model and after the iteration above. A second iteration brings the means to about and and the variances to about 0.25, with log likelihood about , and later iterations change these values only in far decimal places. This limit is a local maximum. It is not the largest possible value of the likelihood, because, as the next card shows, this likelihood has no largest value at all. Starting instead from the means 2 and reaches the same fit with the two labels exchanged.
Covariance collapse
Definition Covariance collapse is the failure in which a component’s covariance matrix approaches a singular matrix while the component concentrates on very few observations. In one dimension its variance tends to 0 while its mean sits on one observation. In dimensions it can happen whenever a component’s weight concentrates on or fewer points, since such points lie in a lower-dimensional flat. For a mixture with , set with , and hold the other components fixed with . As ,
while the mixture density at every other observation stays above the positive value . So the log likelihood grows without bound, an unconstrained maximum likelihood estimate does not exist, and EM can drift toward such a degenerate fit. The usual safeguards are a floor with a stated , or a small positive amount added to the diagonal of every covariance matrix, a prior on the covariances, several starting values, a rule for components whose effective count falls near 1, and a comparison of fits by log likelihood on validation data. With a floor, every one-dimensional component density is at most , so the likelihood is bounded. A fit with a safeguard maximizes a constrained or penalized objective, and a report should say which.
In plain words The likelihood rewards a component for placing high density where observations are. A component that wraps itself around a single observation can make that density as large as it likes, so the likelihood can grow without limit while the model becomes useless for new data. A record-high likelihood is then a symptom, not a better model. A tiny component that claims one observation with almost no spread is nearly always this failure rather than a discovered group.
Example For the four observations, give each component weight , put component 2 at mean with variance 4, and put component 1 on the observation with variance . The log likelihood is about for , about for and about for . Dividing by 100 raises it by about , and already at it exceeds the of the sensible fit from the previous card. With a floor on the variances, every component density is at most , so the log likelihood of four observations cannot exceed .
Check yourself
- A two-component mixture has weights 0.2 and 0.8. At an observation , the two component densities are 2.0 and 0.1. Find both responsibilities and the hard assignment. A classmate says the value 2.0 shows an error, since a probability cannot exceed 1. Is that right?
Show the answer
The weighted densities are and , with total , so
The shares add to 1 and the hard assignment is component 1. The classmate is wrong. The value 2.0 is a density, a probability per unit of , not a probability. A normal density reaches at its mean, which is above 2 whenever . For example, with the peak is about 2.660. Probabilities come from areas under the density, and the responsibilities, which are probabilities, stay in .
- Four observations , , and have responsibilities , , and for component 1 of a two-component mixture. Carry out the M step for component 1, then compare its mean and variance with those from a hard assignment to the component with the larger responsibility.
Show the answer
The effective count is , so . The weighted mean is
The squared deviations from are , , and , and weighting them by the responsibilities gives , , and . Their sum is , so .
A hard assignment gives component 1 the observations 0 and 2, whose responsibilities are at least 0.75, and gives 4 and 10 to component 2. The hard mean is 1 and the hard variance, dividing by 2, is 1. The soft update lets the observation 4 pull the mean up with a quarter of its weight and widen the spread, and it counts 2 as only three quarters of a member. For component 2 the soft update gives , mean and variance , against the hard mean 7 and variance 9.
- A three-component mixture is fitted to 200 one-dimensional training observations from several random starts. One run reports a component with weight 0.005, a mean equal to the observation 7.31 and variance , and its training log likelihood is far above that of every other run. What has happened, and what should be done?
Show the answer
The effective count of that component is , so it describes a single observation. Its standard deviation is , and its density at its own mean is
Weighted by 0.005 this is about 199.5, so the mixture density at 7.31 is at least 199.5, and that single observation contributes at least to the log likelihood. Each further halving of the variance would multiply the spike’s height by and add about , so this direction has no maximum to find. This is covariance collapse. The high training likelihood is an artifact, not evidence of a real group of identical values, and on new observations the spike contributes almost nothing, since a new value almost never falls within a few multiples of of 7.31.
The run should be discarded or refitted with a safeguard, such as a stated floor on the variances or a small amount added to each variance, and the remaining runs and choices of compared by log likelihood on validation data rather than on the training data. If collapse keeps recurring, the model may simply have more components than the data support.