EM maximization step 2026-10-14
Maximize over the permitted statistical parameters, with the E-step conditional distribution held fixed.[ref] A finite mixture model has
For normal distributions with known common variance and fixed positive mixture weights, only the means are fitted. Dropping terms independent of these candidate means gives
The derivative in is , and its second derivative is . Thus a positive weighted count gives a unique maximizing weighted mean. This is a maximization of the surrogate ; the observed-data log-likelihood need not be concave. Recompute the mixture responsibilities after updating the means. The broader EM for Gaussian mixtures with a common variance also estimates mixture weights and the shared variance.
Expectation-maximization algorithm Created 2026-10-03 Updated 2026-10-14
The expectation-maximization algorithm fits a latent-variable model by alternating a conditional expectation over the latent variables with a maximization over the statistical parameters. Its target is the observed-data likelihood function, although its updates use the simpler complete-data log-likelihood.[ref]
Write for the observations, for the latent variables, and for their joint probability density function or probability mass function. The observed-data log-likelihood is
where the integral becomes a sum for discrete . Directly maximizing a logarithm of this sum can be awkward. The E-step instead computes a conditional distribution at the current statistical parameters ; the M-step uses it to construct a new fit. The attractive idea is to retain uncertainty about the hidden labels while recovering simple weighted means and other complete-data updates. The Known-variance Gaussian mixture EM example shows the mechanism without estimating a variance or mixture weight.
Arthur Pentland Dempster, Nan M. Laird, and Donald B. Rubin gave the general framework its name in their 1977 paper, which also discusses earlier special-case algorithms.[ref]
Choose six illustrative values , fixed mixture weights , known standard deviation , and initial means . These are constructed data for a Gaussian mixture distribution, not measurements. With the standard normal distribution probability density function, the fitted log-likelihood is
At the initial means, the component density ratio is . The first E-step therefore gives
Figure 1.
The first E-step retains two soft label probabilities at each chosen data point
. Initial means are minus one and one, mixture weights are one half, and the known standard deviation is one. Stacked bars show the two conditional label probabilities; every row sums to one. Small but nonzero probabilities remain visible in the numerical labels. Details.
The paired values and have complementary mixture responsibilities, so exactly. The first M-step gives
The hyperbolic tangent expression follows by pairing the contributions at and . Assigning every negative value wholly to the first mixture component and every positive value wholly to the second would instead give means . Those hard assignments discard the overlap: the expectation-maximization algorithm is not the same update as K-means clustering.
The observed-data log-likelihood rises from initially to after one update and after two. Further updates approach means , with log-likelihood approximately . These values describe this initialization; EM likelihood monotonicity supplies no certificate of a global maximum.
Figure 2.
Likelihood ascent and mean updates for the chosen data, compared with an identical-means initialization
. Iteration zero is the initial fit; each subsequent point follows one E-step and one M-step. Starting at minus one and one increases the likelihood. Starting both means at zero leaves them at zero with a lower constant likelihood. All runs keep variance one and weights one half. Details.
For stable numerical evaluation, put and . The log-sum-exp function gives
Subtracting keeps at least one exponential equal to one, avoiding the all-zero sum that direct evaluation of tiny component densities can produce.
Law of total variance Created 2026-09-24 Updated 2026-10-14
The law of total variance separates the spread of a population into spread inside groups and spread between their means. For a real square-integrable random variable , so that , and another random variable on the same probability space,
The first term averages the conditional variance over the possible information ; the second measures how much the conditional mean changes with that information. There is no independence assumption, and need not be numerical or have finite variance. Conditioning is useful precisely when knowing tells us something about . See MIT tutorial on using conditional expectation and variance.
More generally, the available information can be a sub-sigma-algebra of the ambient probability space. With , the existing conditional expectation definition gives
Taking recovers the displayed formula. The conditional mean and conditional variance are themselves random variables: before learning the group, we do not yet know which group average or group spread will apply. Their outer expectation and variance turn these varying quantities into numbers.
For a fully explicit mixture distribution, choose a group or with equal probabilities. In group , choose or with equal conditional probabilities; in group , choose or with equal conditional probabilities. Thus the complete joint probability distribution consists of , each with probability , and no other outcomes. The conditional means are and . Squaring the deviations and gives conditional variances and , respectively. The law of total expectation gives the overall mean .
The within-group contribution to variance is
For the between-group contribution, the conditional mean takes values and , each three units from the overall mean. Consequently,
We can check this without any conditioning: the discrete random variable takes values with equal probabilities, so
Equivalently, its second moment is , and subtracting the squared mean gives . These are population variances, with the stated probabilities as weights, rather than estimates using the corrected denominator of a sample variance.
Figure 1.
Four equally likely outcomes split total variance into within-group 5 and between-group 9
. Details.
The figure makes the two sources of spread visible. The outcomes in group cluster tightly around , while those in group sit farther apart around . Replacing every outcome by its conditional mean removes the internal spread but leaves the separation between groups. Conversely, subtracting each group's conditional mean aligns the two groups around zero. Averaging only the conditional variances would miss nine units of variance; retaining only the conditional means would miss five. Neither summary alone describes the whole population.
Two modifications clarify what each contribution measures. Shift group to outcomes and group to outcomes , keeping all four probabilities equal. Both conditional means are now , while the conditional variances remain . The between-group contribution vanishes, and total variance is just . Group membership still tells us how uncertain an outcome is, even though the best point prediction stays the same. Alternatively, let every outcome in group equal and every outcome in group equal . Now both conditional variances vanish, and all nine units of total variance come from group separation. Knowing the group predicts the outcome perfectly. These limiting cases distinguish differences in average outcome from differences in internal spread; the original mixture distribution contains both.
The same calculation answers a prediction question. If the group is hidden, the best constant prediction is the overall mean , with mean squared error , by variance as the minimum mean squared error of a constant. If the group is revealed, predict for and for . The errors become , and their mean squared error is . Knowing the group therefore improves the best achievable mean squared error by , exactly the between-group contribution. This is an interpretation relative to the information available: the remaining uncertainty could shrink further if additional information were revealed.
For any square-integrable measurable function used as a predictor, write . The prediction identity is
Thus predicting with the regression function gives the conditional expectation and minimizes mean squared error over every permitted predictor, including nonlinear ones. This minimizes average squared error, not the error for each individual outcome. See Berkeley Statistics 201A notes, sections 36–37.
Why do the two pieces add cleanly? Put . Its conditional expectation given is zero, so and for every square-integrable measurable function . In particular, and are uncorrelated random variables. Splitting and squaring therefore leaves no cross term after taking expectation. Geometrically, the conditional expectation is an orthogonal projection in the L2 space, and the law of total variance is its Pythagorean theorem for centered random variables.
Figure 2.
Conditional prediction leaves zero group means but different residual spreads
. Details.
In our example, the four products are , which average to zero. Yet and are not independent: observing identifies group , while observing identifies group . This is a concrete instance of heteroscedasticity, with different conditional variances despite zero conditional means of the errors. A group can predict uncertainty even when it cannot predict the error's sign.
The law of total variance is useful whenever aggregated data conceal distinct groups. Changing mixture weights changes both contributions, so the weighting must match the population being described. For example, giving group weight changes the overall mean to , the within-group variance contribution to , and the between-group contribution to , making the total . Group differences account for spread and prediction gains; assigning them a causal explanation requires a separate causal inference argument.
Mixture component 2026-10-14
A mixture component is the conditional distribution of given a component label . Its probability density function integrates to one; its weighted contribution to the mixture distribution integrates to the mixture weight . Thus a mixture component is a distribution, rather than a region assigned to it by a clustering rule.
Mixture distribution 2026-10-06
A mixture distribution first chooses a component with nonnegative mixture weights summing to one, then samples from its law . Consequently , and any finite moment-generating function is the same weighted sum of the component transforms. A component may be a Dirac measure, so a mixture may have both discrete and continuous parts.
Mixture identifiability 2026-10-14
Simultaneously applying a permutation to the mixture weights and mixture components leaves unchanged. Thus identifiability of named components requires a convention, such as ordering distinct component means; label switching describes the associated inferential issue.[ref]
Even after choosing label names, identical mixture components reveal only their combined mixture weight, and an inactive mixture component has undetermined statistical parameters. Adding mixture components increases flexibility but can cause overfitting; judge predictions using cross-validation, rather than interpreting every fitted component as a discovered population.[ref]
Mixture model Created 2026-09-24 Updated 2026-10-14
A mixture model represents a population probability distribution by choosing one mixture component at random and then drawing from its probability distribution. For a finite mixture model whose mixture components have probability density functions , the resulting mixture distribution has probability density function
The mixture weights ensure and . For discrete random variables the same formula uses probability mass functions; without either kind of density, write for component distributions . A zero mixture weight makes that mixture component inactive.[ref]
The mixture components need not occupy disjoint bins of . Two normal distributions both have positive probability density functions everywhere, so the same value can plausibly come from either mixture component. The Two-Gaussian mixture example makes this overlap visible, and its mixture responsibilities quantify the remaining uncertainty about the latent variable. This is useful when a single normal distribution cannot represent the population's shape, but a fitted mixture model alone does not establish that its mixture components are real biological or social groups.
Fit the finite Gaussian mixture with a common variance for candidate values , using several initializations of the expectation-maximization algorithm for each, and retain the best likelihood value found. Maximized likelihood alone cannot select the number of components: a smaller mixture embeds in a larger one by giving an added component zero weight, so its likelihood cannot decrease.
There are free mixture weights, means and one common variance, hence
A standard working choice is the Bayesian information criterion:
The penalty balances fit against parameter count. The Akaike information criterion instead uses and is another possible comparison, particularly when predictive fit is the goal. The parameter count would differ if component variances were separate, but that is not this model.
Likelihood fitting must first be made well posed. Even a shared variance does not prevent all degeneracy: if , choose , and let the common variance tend to zero. Each observed density is at least , so the full log-likelihood function tends to . The same construction works when reaches the number of distinct observed values. Thus one must not feed infinite fitted likelihoods into an information criterion. Restrict candidate sizes to a sensible range below that degeneracy, or impose a fixed positive variance floor and use that same constrained model in every comparison. Under a variance floor , the M-step variance becomes .
There is also nonregular mixture model selection: at a missing component its weight is on a boundary and its mean is unidentified, while permuting labels leaves the distribution unchanged. Consequently an ordinary chi-squared calibration for a likelihood-ratio test between successive component counts is not generally justified. Information criteria are practical comparisons, not an automatic universal proof that the true number has been recovered. Predictive cross-validation or a suitably constructed parametric bootstrap comparison can supplement them. Select the component count by a penalized, well-defined mixture fit, rather than by unpenalized likelihood increase.
Conditioning on the intensity in the Poisson mixture gives
Thus has the negative binomial distribution with two successes and success probability , counting failures; explicitly for . The probability generating function is finite for real .
The claim-size moment-generating function is . Substituting into the aggregate moment-generating function and using gives
Put , the moment-generating function of an exponential distribution with rate . The identity
then yields
The gamma-mixed Poisson aggregate with exponential claims has three nonnegative mixture weights summing to one. By uniqueness of the moment-generating function near zero, the aggregate distribution is
Here is the Dirac measure at zero. In particular , consistently with . The positive components have respective expected values and ; their mixture distribution accounts for the possibility of no aggregate payout.
An exact finite mixture model follows from the binomial theorem:
Define positive mixture weights
Here is the Beta function, so the component probability distributions are . All coefficients are computable from the observed integer counts.
Use inverse transform sampling with the supplied to choose : writing and , take . Then recycle its position inside that interval,
Recycling a uniform random variable after discrete sampling makes uniform independently of , since . It is also independent of all supplied random variables with gamma distributions. Transform these by the probability integral transform:
They are independent random variables with uniform distributions because has a unit-rate exponential distribution.
Conditional on , put and . Form the values and return their th order statistic. This uses at most the supplied random variables with gamma distributions, since . The uniform order statistic formula gives
Averaging these component probability density functions with weights recovers exactly the normalized posterior density. Unused inputs can be discarded. When , , , and the output is , as required. Interval endpoints and ties have probability zero; any consistent convention there is harmless. Exactness here concerns the mathematical algorithm; finite-precision arithmetic can be stabilized with logarithmic mixture weights.
Let . The label likelihood for the mixture weights is proportional to . Multiplication by the density and Dirichlet-multinomial conjugacy gives
Conditional on the labels, the observations and component means provide no further information about .
For positive mixture weights summing to one, set and choose when , where has a uniform distribution. Then has a uniform distribution independently of : for , . This permits exact finite mixture model sampling with a recycled continuous random variable.
For fixed statistical parameters and , Bayes' theorem gives the mixture responsibility
It is the conditional expectation of the mixture allocation indicator. This posterior probability concerns the hidden label, with held fixed; it does not require a prior distribution over . For a continuous , use the density ratio to define this conditional distribution, rather than dividing probabilities of the zero-probability event .[ref]
For the Two-Gaussian mixture example, the component density ratio is , so the posterior probability ratio and the mixture responsibilities are
At the two unweighted component densities are equal, so the mixture responsibilities equal the mixture weights: , . At , the second component density is twice the first and its mixture responsibility is . Equal mixture responsibilities instead occur at : the more frequent second mixture component is favored even slightly to the left of the midpoint.
Figure 1.
Posterior responsibilities change with x while the stipulated mixture weights stay fixed
. Original analytic responsibilities for the same two-Gaussian mixture, with prior label probabilities shown as dotted horizontal lines. Both responsibilities remain strictly between zero and one at every finite x; the vertical marker denotes equal posterior probabilities, not disjoint component supports. Details.
The mixture weights describe membership before learning ; mixture responsibilities describe membership after learning . The law of total expectation gives under this statistical model, although varies across individual values. In fitting by the expectation-maximization algorithm, evaluate mixture responsibilities at the current statistical parameters and recompute them after an update.
Second moment of a mixture likelihood ratio Created 2026-10-06 Updated 2026-10-07
If and the nonnegative mixture weights sum to one, the likelihood ratio of the mixture model is . Expanding proves the displayed chi-squared divergence identity. For independent random variables sampled from a fixed component, one-observation cross moments multiply across observations. The component is drawn once for the whole sample; redrawing it per observation gives a different mixture model.