Loading…
Loading…
Derive soft Gaussian responsibilities, weighted parameter updates, and the lower-bound argument behind nondecreasing observed log-likelihood.
A point between two groups need not have one overwhelmingly plausible membership. Hard assignment records only the selected group. A mixture model instead combines several probability densities and retains, for each observation, a probability of membership in every component. These probabilities become weights when estimating the components again.
The challenge is that the likelihood contains a logarithm of a sum. Even when each Gaussian is simple, the parameters of different components are coupled through that sum. Expectation-maximization, abbreviated EM, introduces responsibilities that separate the parameter update into weighted estimation problems. Its two steps optimize a lower bound that touches the observed log-likelihood at the current parameters.
We will derive those weights and updates before calculating a complete iteration. The distinction between a soft probability and a hard label is central: maximizing the density of one selected component is a different objective from maximizing a mixture density. Covariance normalization matters for the same reason. The denominator in a weighted covariance follows from the likelihood being optimized.
Soft weights can also come from geometry. Let distinct sites have old Voronoi cells , with each distance tie assigned to one cell. Insert a query and let be its new Voronoi cell. Assume this cell is bounded and has finite, positive volume. Define
The old cells partition the new cell, so their overlap volumes add to its volume. Every weight is nonnegative; a site with no positive-volume overlap receives zero. The fractions measure how much of the query's new region previously belonged to each old site.
In one dimension, volume is length. For two sites and an inserted query,
The old boundary is . Its left and right overlaps with the new interval have lengths and , respectively, while the new interval has length . These are geometric allocation weights. Gaussian responsibilities, derived next, are conditional probabilities under a fitted mixture model. Both constructions normalize across components, but their definitions use different information.
Let be independent observations, and fix a number of Gaussian components. Component has weight , mean , and positive-definite covariance , with . Write for all these parameters. All logarithms below are natural logarithms.
Definition
The Gaussian density and mixture density are
The observed log-likelihood is
A latent component label takes value with probability . The component density describes conditional on that label.
The mixture weight is part of the model, rather than a normalization applied after choosing a component. Its effect remains even when two component densities happen to have equal values at an observation. The sum over all possible labels is what makes the observed density.
If the labels were observed as well, the log-likelihood would be a sum of terms . Equivalently, a zero-or-one indicator for each component would select one term per observation. The unknown labels prevent us from grouping the observations that way. EM takes the conditional expectation of those indicators instead, producing the responsibilities that appear in . The fractional coefficients have a probabilistic origin: they are expectations of latent indicators under the current model.
This also distinguishes the three functions used in the derivation. The observed log-likelihood sums over possible labels inside each logarithm. The complete-data log-likelihood would use known labels. The function averages that complete-data expression under the current posterior. Keeping track of which quantities are observed, latent, or held fixed explains why an apparently simple weighted Gaussian fit can improve a more complicated mixture likelihood.
Definition
At current parameters , Bayes' rule gives
Each row satisfies . With positive mixture weights and positive-definite Gaussian covariances, every is positive, so . Also .
is the expected number of observations attributed to component under the current posterior labels. It can be fractional. A responsibility is conditional on the current model and the observation; it is not a known class label supplied with the data.
There are two different normalizations. The E-step normalizes across components for each individual observation, so its row sums are one. The mean update normalizes across observations for one component, so its denominator is the column sum . Dividing a mean update by instead would treat responsibility assigned to other components as if it had contributed to this component's total mass. The two denominators correspond to different conditional questions.
A Gaussian density at a point is not itself a membership probability. It can exceed one and changes scale when measurement units change. Responsibilities are dimensionless probabilities obtained by comparing the weighted densities at the same observation. For general covariance, that comparison includes both the Mahalanobis distance in the exponent and the determinant in the normalization. A more spread-out component has a larger volume and a lower peak density, while sets its overall mixture weight. For equal weights and a common isotropic covariance, ranking component densities reduces to comparing Euclidean distances.
Theorem
Hold the responsibilities fixed and define the expected complete-data log-likelihood
When the weighted covariance matrices below are positive definite, its maximizers are
For a model with a prescribed common covariance , , keep that covariance fixed and use the same weight and mean updates.
The weighted covariance is positive definite exactly when its weighted centred observations span all feature directions. Otherwise the displayed matrix is singular and is not a positive-definite Gaussian covariance. The fixed-variance model gives a useful setting in which every update above remains a valid model without estimating covariance matrices.
Theorem
Compute the exact posterior responsibilities at . Choose valid new parameters satisfying
Then
An exact M-step maximizes ; an update that only increases it is a generalized EM step. The conclusion concerns observed log-likelihood values. Global optimality and convergence of the parameter vectors are separate claims.
For the weights, maximize subject to . The stationary equation for a multiplier is . Summing over gives , hence .
For each mean, the terms depending on are a negative weighted sum of squared Mahalanobis distances. Differentiating gives
Since is invertible and , the mean must be the weighted average in the proposition. With a prescribed common isotropic covariance, this is the familiar weighted least-squares minimizer. Every observation contributes to each component in proportion to its responsibility, rather than only to the component with the largest one.
To derive the covariance update, let
The relevant part of is
Its stationary equation is . For positive-definite , concavity of the log determinant gives the maximizer . This is a likelihood estimate, so the denominator is , with no subtraction of one. Omitting that denominator would produce a weighted scatter matrix with the wrong scale.
For any positive probability row , Jensen's inequality gives
Define the summed right-hand side by
The exact gap is
where and denotes the posterior row at parameters . The gap is zero when .
The E-step chooses , making the bound touch the current observed log-likelihood. Holding fixed, its entropy is constant, so increasing increases . Therefore
The two steps have different jobs: the E-step makes the bound exact at the current model, while the M-step improves the model under that fixed bound. Replacing posterior probabilities by hard labels removes the touching equality on which this argument depends.
The responsibilities remain fixed throughout one M-step. Every updated mean, covariance, and weight in that step uses the same posterior matrix calculated from the complete old parameter set. The covariance formula centres its residuals at the new weighted mean because it maximizes the same fixed- problem. Once the new model has been formed, the next E-step recomputes the posterior from that model. This ordering makes the quantities in the chain of inequalities unambiguous: its middle comparison changes parameters while retaining one probability matrix.
The bound and KL identity also extend to probability rows containing zero entries, with and zero-weighted terms interpreted by continuity. This lets us compare the tight posterior bound with the looser bound obtained from a hard assignment.
Worked example
Consider a one-dimensional mixture with means , , common variance , and weights . At , the distances to the two means are equal, so the Gaussian densities are equal. Their common value cancels from Bayes' rule:
The midpoint has equal compatibility with the component shapes, but the model gives the first component three times the prior weight. Normalizing the two densities without their mixture weights would instead give and , which are posterior probabilities for a different mixture. Soft membership therefore involves both density and weight.
Worked example
Take observations , , initial means , equal mixture weights, and prescribed common variance . Set
At each observation, the squared distance to the other mean exceeds the squared distance to its matching mean by , giving the density ratio . Thus
The M-step gives
Although each observation initially lies at one component mean, its positive responsibility for the other component pulls both updated means inward. The common variance stays exactly . Using the full Gaussian density, the observed log-likelihood changes from to , an increase of about .
This NumPy code performs the same single iteration. Logarithmic normalization computes the posterior from all components; it does not select a component before forming the denominator.
import numpy as np
X = np.array([0.0, 2.0])
means = np.array([0.0, 2.0])
weights = np.array([0.5, 0.5])
variance = 1.0
def log_components(means, weights):
return (np.log(weights)[None, :]
- 0.5 * np.log(2.0 * np.pi * variance)
- 0.5 * (X[:, None] - means[None, :]) ** 2 / variance)
joint = log_components(means, weights)
normalizer = np.logaddexp.reduce(joint, axis=1)
responsibilities = np.exp(joint - normalizer[:, None])
mass = responsibilities.sum(axis=0)
new_weights = mass / len(X)
new_means = (responsibilities.T @ X) / mass
before = normalizer.sum()
after = np.logaddexp.reduce(
log_components(new_means, new_weights), axis=1
).sum()
assert np.allclose(responsibilities.sum(axis=1), 1.0)
assert after >= before
print("responsibilities =", np.round(responsibilities, 6).tolist())
print("mass =", np.round(mass, 6).tolist())
print("weights =", np.round(new_weights, 6).tolist())
print("means =", np.round(new_means, 6).tolist())
print(f"log_likelihood: {before:.6f} -> {after:.6f}")
The output is
responsibilities = [[0.880797, 0.119203], [0.119203, 0.880797]]
mass = [1.0, 1.0]
weights = [0.5, 0.5]
means = [0.238406, 1.761594]
log_likelihood: -2.970315 -> -2.886563
Worked example
Take observations and . Give two components weight each, means and , and variances and , respectively. For every , both Gaussian components are valid. Their mixture densities satisfy
Consequently,
Shrinking a component around one observation creates an arbitrarily tall density there, while the other component continues to explain the other observation. This unrestricted likelihood has no finite maximum. The issue is the statistical objective itself, not an instruction to evaluate a Gaussian with a singular covariance. Prescribing a positive common variance, as in Example 2, specifies a different model in which this collapse is impossible.
In the prescribed isotropic-variance model, each component density is at most . A weighted average of those densities has the same upper bound, so
The nondecreasing likelihood values therefore have a finite limit in this model. This statement concerns a real sequence of objective values. It does not identify the best possible mixture or establish a limit for every parameter coordinate. Component-label permutations also describe the same mixture density.
Initialization determines which posterior weights are calculated first, and those weights determine the first weighted fitting problem. Two different initial models can therefore follow different sequences of touching bounds. Inspecting the likelihood is a check of optimization progress within the chosen model; it does not choose the number of components or compare different covariance assumptions automatically.
With equal weights and a common isotropic variance, responsibilities are normalized exponentials of negative squared distances. Smaller variance makes them more concentrated around a uniquely closest mean. For every positive variance the posterior remains soft, whereas a hard nearest-centre update changes the optimization problem. This connection explains the resemblance between weighted mean updates and centre-based clustering without identifying their objectives.
Common mistake
Starting from the updated means in Example 2, a hard assignment sends to the first component and to the second. Replacing each mean by its assigned observation returns the means to . With the same fixed variance and equal weights, observed log-likelihood falls from about to . The hard assignment is not the posterior distribution that makes the EM lower bound touch the current likelihood.
Common mistake
The Gaussian covariance update divides weighted scatter by . The E-step normalizes across components. Both factors arise from the mixture likelihood. Changing either normalization changes the fitting equations and breaks the stated EM derivation.
A Gaussian mixture sums weighted component densities. Its E-step uses normalized posterior responsibilities, and its M-step uses their effective masses to update weights, means, and any estimated covariances. The Jensen lower bound is exact at the current posterior and increases when the M-step increases , proving nondecreasing observed log-likelihood. Positive weights, positive-definite covariances, and positive effective masses keep the formulas within the stated model. The choice between estimated covariance and prescribed variance is part of the objective, and unrestricted covariance can yield unbounded likelihood through component collapse.
Checkpoint
Separate equal component densities from unequal mixture weights.
Checkpoint
Compute each before dividing a weighted sum.
Checkpoint
The covariance is weighted squared deviation from the updated mean, divided by effective mass.
Checkpoint
The midpoint between the current means is still .
The responsibilities are because the common density cancels. Keeping only the first component records a single chosen label and discards the remaining posterior mass .
The masses are . Thus and , while .
The mass is , and the mean is . The weighted squared-deviation sum is . The covariance estimate is .
The hard assignments are one observation per component, returning the means to and the weights to . Observed log-likelihood decreases from to . For the hard probability rows , no longer holds: those rows differ from the strictly positive posterior. Improving that hard-assignment bound cannot use the EM chain of inequalities to guarantee improvement of the observed likelihood.
Continue with least squares and residuals or the course reading list.