Module contents
Lesson 9 of 24Advanced 110 min

The EM algorithm in general: lower bound, monotonicity and convergence

Expectation-maximization through the evidence lower bound, convergence, variants and missing data.

After this lesson you can

  • Derive the lower bound and EM updates.
  • Explain monotonicity, convergence and the role of missing information.
  • Compare EM variants and coordinate ascent.
  • Explain missing-data assumptions and implement EM.

Before you start

Motivation: latent variables and missing data everywhere

In the previous lesson you fitted a Gaussian mixture by alternating two steps: calculating responsibilities and re-estimating weights, means and covariances as if those responsibilities were labels. That procedure is not a trick unique to mixtures. It is the best-known instance of a general recipe that appears whenever a model has something unobserved:

  • Probabilistic clustering. Each point’s component label is a latent variable. Gaussian, Bernoulli (for binary data) and multinomial mixtures (for word counts) are fitted alike.
  • Sequences. In a hidden Markov model the hidden state at each time is latent; the Baum-Welch algorithm is EM with a forward-backward E-step.
  • Factors. In factor analysis and probabilistic PCA (lesson 12 of this module), each observation is a linear combination of unobserved factors plus noise.
  • Missing data. A survey with unanswered questions, a failed sensor, an incomplete medical record: missing entries are latent variables of the complete-data model.
  • Deep models. The variational autoencoder maximizes the same bound you will derive here, with the posterior approximated by a network.

In all these cases the complete-data likelihood (observed plus latent) is easy: it factorizes, belongs to the exponential family and has a closed-form maximum. The observed-data likelihood is hard: latent variables must be summed or integrated out, and the logarithm of a sum does not separate. EM replaces the hard problem with a succession of easy ones, guaranteeing that likelihood never decreases.

This lesson builds EM from a single identity, the decomposition of log-likelihood into a lower bound plus KL divergence, and derives everything else: the two steps, monotonicity, the points it converges to, why it is sometimes painfully slow, variants used in practice, and conditions under which EM with missing data is valid.

Recap: Jensen and KL non-negativity

Two inequalities underpin the whole lesson. The first is Jensen’s inequality for the strictly concave logarithm: if Y>0Y > 0 is a random variable with finite expectation,

log⁡E[Y]≥E[log⁡Y],\log \E[Y] \ge \E[\log Y],

with equality if and only if YY is constant almost surely. The second is Gibbs’ inequality: for two distributions qq and pp on the same space,

KL⁡(q ∥ p)=Eq ⁣[log⁡q(Z)p(Z)]≥0,\KL(q \,\|\, p) = \E_{q}\!\left[\log \frac{q(Z)}{p(Z)}\right] \ge 0,

with equality if and only if q=pq = p (almost surely). They are the same inequality: apply Jensen to Y=p(Z)/q(Z)Y = p(Z)/q(Z) with Z∼qZ \sim q to obtain −KL⁡(q ∥ p)=Eq[log⁡Y]≤log⁡Eq[Y]=log⁡∑z: q(z)>0p(z)≤0-\KL(q \,\|\, p) = \E_q[\log Y] \le \log \E_q[Y] = \log \sum_{z:\,q(z) > 0} p(z) \le 0.

Complete versus incomplete likelihood

Fix notation for the rest of the lesson. Write xx for all observed data (the whole dataset, not one point) and zz for all unobserved variables. The model is a family of joint densities p(x,z∣θ)p(x, z \given \theta), θ∈Ω⊆Rp\theta \in \Omega \subseteq \R^p. Sums over zz become integrals if zz is continuous; everything below still holds.

With iid data x=(x1,…,xn)x = (x_1, \dots, x_n) and one latent variable per observation, z=(z1,…,zn)z = (z_1, \dots, z_n), the two are

ℓc(θ)=∑i=1nlog⁡p(xi,zi∣θ),ℓ(θ)=∑i=1nlog⁡∑zip(xi,zi∣θ).\ell_c(\theta) = \sum_{i=1}^n \log p(x_i, z_i \given \theta), \qquad \ell(\theta) = \sum_{i=1}^n \log \sum_{z_i} p(x_i, z_i \given \theta).

The difference is the position of the logarithm. In a mixture of KK Gaussians with zik=1[zi=k]z_{ik} = \ind[z_i = k],

ℓc=∑i∑kzik[log⁡πk+log⁡N(xi;μk,Σk)],\ell_c = \sum_{i}\sum_{k} z_{ik}\big[\log \pi_k + \log \Normal(x_i; \mu_k, \Sigma_k)\big],

which separates by component: if you knew the labels, each μk\mu_k would be the mean of its points and each πk\pi_k its proportion. By contrast ℓ=∑ilog⁡∑kπkN(xi;μk,Σk)\ell = \sum_i \log \sum_k \pi_k \Normal(x_i; \mu_k, \Sigma_k) couples all parameters inside the logarithm, is not concave, has at least K!K! equivalent maxima from label permutations, and has no closed-form maximum.

Missing data have the same structure. If each row is split into observed and missing parts, xi=(xi,obs,xi,mis)x_i = (x_{i,\text{obs}}, x_{i,\text{mis}}), the latent variables are z=xmisz = x_{\text{mis}}, complete likelihood is the model likelihood for full rows, and incomplete likelihood integrates out what is missing. EM turns the hard problem, maximizing ℓ\ell, into a succession of problems like the easy one, maximizing ℓc\ell_c with latent variables “filled in” correctly. The lower bound tells us what that means.

The lower bound

Proof

For every zz with q(z)>0q(z) > 0, the product rule gives p(x,z∣θ)=p(z∣x,θ) p(x∣θ)p(x, z \given \theta) = p(z \given x, \theta)\,p(x \given \theta), with both factors positive. Take logarithms and subtract log⁡q(z)\log q(z):

log⁡p(x,z∣θ)q(z)=log⁡p(x∣θ)+log⁡p(z∣x,θ)q(z).\log \frac{p(x, z \given \theta)}{q(z)} = \log p(x \given \theta) + \log \frac{p(z \given x, \theta)}{q(z)}.

Take expectations with Z∼qZ \sim q. The first term on the right does not depend on zz and comes out unchanged; the second is −KL⁡(q ∥ p(z∣x,θ))-\KL(q \,\|\, p(z \given x, \theta)). This gives L(q,θ)=ℓ(θ)−KL⁡(q ∥ p(z∣x,θ))\mathcal{L}(q, \theta) = \ell(\theta) - \KL(q \,\|\, p(z \given x, \theta)). The inequality and equality case follow from Gibbs’ inequality.

∎

L(q,θ)\mathcal{L}(q, \theta) is called the EM lower bound, evidence lower bound (ELBO), or, with its sign reversed, variational free energy by analogy with statistical physics: Eq[log⁡p(x,Z∣θ)]\E_q[\log p(x, Z \given \theta)] acts as energy (with reversed sign) and H⁡(q)\Ent(q) as entropy. The bound also follows directly from Jensen, ℓ(θ)=log⁡Eq[p(x,Z∣θ)/q(Z)]≥Eq[log⁡(p(x,Z∣θ)/q(Z))]\ell(\theta) = \log \E_q[p(x, Z \given \theta)/q(Z)] \ge \E_q[\log(p(x, Z \given \theta)/q(Z))], but that route hides the key point: the gap is exactly a KL divergence, and closes by choosing qq equal to the posterior.

Check the identity numerically in the first interactive’s model: a mixture 12N(0,1)+12N(θ,1)\tfrac12\Normal(0, 1) + \tfrac12\Normal(\theta, 1) in which only θ\theta is unknown, with 36 observations in three groups.

[ ]The decomposition, in numbersBrowser
import numpy as np
from scipy.stats import norm
from scipy.special import logsumexp, expit

def grupo(c, s, m):
    # m cuantiles exactos de N(c, s^2): datos deterministas, sin muestreo
    return c + s * norm.ppf((np.arange(m) + 0.5) / m)

s = 3.0
x = np.concatenate([grupo(-s, 0.6, 10), grupo(0, 0.6, 14), grupo(s, 0.6, 12)])

def log_joint(theta):
    # columna 0: componente fija N(0, 1); columna 1: componente móvil N(theta, 1)
    return np.log(0.5) + np.stack([norm.logpdf(x), norm.logpdf(x - theta)], axis=1)

def ell(theta):
    return logsumexp(log_joint(theta), axis=1).sum()

def cota(r, theta):
    # L(q, theta) con q(z_i = 1) = r_i: E_q[log p(x, z)] + H(q)
    A = log_joint(theta)
    Rq = np.stack([1 - r, r], axis=1)
    H = -np.sum(Rq * np.log(np.clip(Rq, 1e-300, None)))
    return np.sum(Rq * A) + H

def kl(r, theta):
    p = expit(x * theta - theta**2 / 2)          # posterior de z_i = 1
    Rq, P = np.stack([1 - r, r], 1), np.stack([1 - p, p], 1)
    return np.sum(Rq * (np.log(np.clip(Rq, 1e-300, None)) - np.log(P)))

rng = np.random.default_rng(0)
theta = 1.3
for _ in range(3):
    r = rng.uniform(size=len(x))                  # una q cualquiera
    print(f"l = {ell(theta):.6f}   L + KL = {cota(r, theta) + kl(r, theta):.6f}   KL = {kl(r, theta):.3f}")
post = expit(x * theta - theta**2 / 2)
print(f"con q = posterior: L = {cota(post, theta):.6f}, KL = {kl(post, theta):.1e}")

# el paisaje de l(theta): máximos locales en una rejilla fina
g = np.linspace(-6, 6, 4801)
A = np.log(0.5) + np.logaddexp(norm.logpdf(x)[:, None], norm.logpdf(x[:, None] - g[None, :]))
L = A.sum(axis=0)                                 # l(theta) en toda la rejilla de una vez
loc = [i for i in range(1, len(g) - 1) if L[i] > L[i - 1] and L[i] > L[i + 1]]
mins = [i for i in range(1, len(g) - 1) if L[i] < L[i - 1] and L[i] < L[i + 1]]
print("máximos locales:", [(round(g[i], 3), round(L[i], 3)) for i in loc])
print("mínimo local:  ", [(round(g[i], 3), round(L[i], 3)) for i in mins])

The first line of each pair agrees to the last decimal regardless of qq, and with qq equal to the posterior, KL vanishes. The grid also shows that this ℓ\ell has two local maxima, near θ=−2.9\theta = -2.9 and θ=2.9\theta = 2.9, separated by a minimum near 00: the right-hand maximum is global because the right group has 12 points and the left 10.

Drawing the bound

Fix qq at the posterior for a value tt, qt=p(z∣x,t)q_t = p(z \given x, t). In this model p(zi=1∣xi,t)=ri(t)=σ(xit−t2/2)p(z_i = 1 \given x_i, t) = r_i(t) = \sigma(x_i t - t^2/2), and the part of L(qt,θ)\mathcal{L}(q_t, \theta) depending on θ\theta is −12∑iri(t)(xi−θ)2-\tfrac12\sum_i r_i(t)(x_i - \theta)^2. Using the fact that the bound equals ℓ(t)\ell(t) at θ=t\theta = t:

L(qt,θ)=ℓ(t)−12∑i=1nri(t)[(xi−θ)2−(xi−t)2].\mathcal{L}(q_t, \theta) = \ell(t) - \tfrac12 \sum_{i=1}^n r_i(t)\big[(x_i - \theta)^2 - (x_i - t)^2\big].

This is a parabola in θ\theta with curvature ∑iri(t)\sum_i r_i(t), touching ℓ\ell at θ=t\theta = t and lying below it everywhere else. Its maximum is at the weighted mean ∑iri(t)xi/∑iri(t)\sum_i r_i(t) x_i / \sum_i r_i(t).

InteractiveThe bound that touches and pushes
Log-likelihood ℓ(θ)\ell(\theta) and lower bound L(q,θ)\mathcal{L}(q, \theta)
  • ℓ(θ)=log⁡p(x∣θ)\ell(\theta) = \log p(x \mid \theta)
  • bound L(q,θ)\mathcal{L}(q, \theta) with q=p(z∣x,t)q = p(z \mid x, t)
  • gap = KL
  • previous iterates
3.0
−0.40
Iteration kk0
θk\theta_k−0.4000
ℓ(θk)\ell(\theta_k)−136.548
Bound L(q,θk)\mathcal{L}(q, \theta_k)−136.548
Gap: KL between qq and posterior at θk\theta_k0.0000
Largest decrease in ℓ\ell between iterationsn/a
Linear rate at the fixed point, 1−Iobs/Ic1 - I_{\mathrm{obs}}/I_cn/a
After the E-step the bound touches ℓ at θ = −0.40 and stays below it elsewhere. It is a parabola of curvature Σrᵢ = 16.9. Press M-step.
The blue curve is the model's log-likelihood ℓ(θ)\ell(\theta) above; orange is the bound L(q,θ)\mathcal{L}(q, \theta) with qq equal to the posterior at the hollow circle. Press 'M-step' then 'E-step' several times. Watch the magenta segment after each M-step: it is the KL gap opening between the bound and ℓ\ell. Try starting at θ0=0.5\theta_0 = 0.5 and compare the maximum reached with a start at −0.4-0.4. Bring the groups together (s≈1.5s \approx 1.5) and see how each jump shortens.

Three things the figure shows, formalized in the rest of the lesson:

  1. The bound is tangent. Since ℓ(θ)−L(qt,θ)=KL⁡(qt ∥ p(z∣x,θ))\ell(\theta) - \mathcal{L}(q_t, \theta) = \KL(q_t \,\|\, p(z \given x, \theta)) is nonnegative and zero at θ=t\theta = t, it has a minimum at tt, and if everything is differentiable its derivative vanishes there. Thus ∇ℓ(t)=∇θL(qt,θ)∣θ=t\grad\ell(t) = \grad_\theta \mathcal{L}(q_t, \theta)\big|_{\theta = t}: the bound not only touches, it has the same slope. Expanded, this is Fisher’s identity, ∇ℓ(θ)=Ep(z∣x,θ)[∇θlog⁡p(x,Z∣θ)]\grad\ell(\theta) = \E_{p(z \given x, \theta)}[\grad_\theta \log p(x, Z \given \theta)]: the observed-likelihood gradient is the posterior expectation of the complete-likelihood gradient.
  2. The M-step cannot overshoot. Jumping to the parabola’s maximum raises the bound, which lies below ℓ\ell, so ℓ\ell increases by at least as much. The interactive decomposes each increase into “the increase in the bound” plus “the KL gap that opens.”
  3. The destination depends on the start. From θ0=−0.4\theta_0 = -0.4, EM climbs to the left local maximum and stays there. The bound at that point is tangent to ℓ\ell at a maximum of ℓ\ell, so the M-step does not move it: nothing in the algorithm gets it out.

The EM algorithm

The decomposition suggests maximizing L\mathcal{L} instead of ℓ\ell, alternating the two variables.

The E-step sets qq to the unique point making the bound exact at θk\theta_k; the M-step maximizes expected complete likelihood. It “fills in” the latent variables, but not with a value: with their entire posterior distribution.

When the complete model belongs to the exponential family, log⁡p(x,z∣θ)=η(θ)⊤T(x,z)−A(θ)+const\log p(x, z \given \theta) = \eta(\theta)\T T(x, z) - A(\theta) + \text{const}, QQ depends on the data only through E[T(x,Z)∣x,θk]\E[T(x, Z) \given x, \theta_k]. Then:

  • the E-step calculates the expected sufficient statistics Tˉk=E[T(x,Z)∣x,θk]\bar T_k = \E[T(x, Z) \given x, \theta_k];
  • the M-step solves the same equations as the complete-data maximum likelihood estimator, with TT replaced by Tˉk\bar T_k.

In the Gaussian mixture, TT comprises counts ∑izik\sum_i z_{ik}, sums ∑izikxi\sum_i z_{ik} x_i and products ∑izikxixi⊤\sum_i z_{ik} x_i x_i\T; their expectations use responsibilities rik=E[zik∣xi,θk]r_{ik} = \E[z_{ik} \given x_i, \theta_k], and the M-step gives exactly the formulas for EM for Gaussian mixtures from the previous lesson. With Gaussian missing data, TT comprises sums of xix_i and xixi⊤x_i x_i\T, and the E-step needs the conditional mean and covariance of the missing values (as you will see in the missing-data section).

If you also add a prior p(θ)p(\theta), the same derivation with log⁡p(x,z∣θ)+log⁡p(θ)\log p(x, z \given \theta) + \log p(\theta) gives EM for MAP estimation: the M-step maximizes Q(θ∣θk)+log⁡p(θ)Q(\theta \given \theta_k) + \log p(\theta) and the quantity rising monotonically is ℓ(θ)+log⁡p(θ)\ell(\theta) + \log p(\theta). This is used to avoid probabilities exactly 0 or 1 in Bernoulli mixtures.

Monotonicity and convergence

Proof

With qk=p(z∣x,θk)q_k = p(z \given x, \theta_k), decomposition at θk+1\theta_{k+1} and θk\theta_k gives

ℓ(θk+1)=L(qk,θk+1)+KL⁡(qk ∥ p(z∣x,θk+1)),ℓ(θk)=L(qk,θk),\ell(\theta_{k+1}) = \mathcal{L}(q_k, \theta_{k+1}) + \KL(q_k \,\|\, p(z \given x, \theta_{k+1})), \qquad \ell(\theta_k) = \mathcal{L}(q_k, \theta_k),

because at θk\theta_k the KL divergence is zero. Subtract and use L(qk,θ)=Q(θ∣θk)+H⁡(qk)\mathcal{L}(q_k, \theta) = Q(\theta \given \theta_k) + \Ent(q_k): the entropy terms cancel.

∎

This result is the robust part of EM monotonicity and convergence. It has an immediate practical consequence: in exact EM, log-likelihood never decreases. If you see it decrease, even in the fifth decimal, there is an implementation error (an E-step that is not the exact posterior, an M-step that does not maximize, or ℓ\ell computed differently) or a numerical problem to locate, not noise. The implementation section turns this observation into an automatic check.

If ℓ\ell is bounded above, the sequence ℓ(θk)\ell(\theta_k) is monotone and bounded and therefore converges. But that says nothing about where θk\theta_k goes, or even whether it converges. That analysis is Wu’s.

The proof of the first point applies Zangwill’s global convergence theorem to the EM map; here we give the part explaining why stationary points arise.

Proof

Let θ⋆\theta^\star be an EM fixed point in the interior of Ω\Omega, meaning θ⋆∈arg max⁡θQ(θ∣θ⋆)\theta^\star \in \argmax_\theta Q(\theta \given \theta^\star), and suppose QQ is differentiable in its first argument. Being an interior maximum, ∇θQ(θ⋆∣θ⋆)=0\grad_\theta Q(\theta^\star \given \theta^\star) = 0. By tangency of the bound (Fisher’s identity), ∇ℓ(θ⋆)=∇θQ(θ⋆∣θ⋆)=0\grad\ell(\theta^\star) = \grad_\theta Q(\theta^\star \given \theta^\star) = 0. EM fixed points are therefore stationary points of ℓ\ell.

∎

A stationary point may be a local maximum that is not global, a saddle point or, if you start exactly there, even a local minimum. Stationarity is guaranteed, not optimality. Wu gives an additional condition excluding stationary points that are not local maxima (the M-step must be able to strictly increase QQ at those points), but it is rarely checkable. In practice, saddle points and minima are unstable: rounding noise or generic initialization avoids them. Local maxima are not. The clearest example of a saddle from which EM cannot escape is a symmetry preserved by the algorithm. Murray (1977), discussing Dempster, Laird and Rubin’s paper, noted that EM can converge to a saddle; the cell reproduces this with a bivariate normal of known means (0,0)(0, 0) and twelve pairs, four complete and eight with one coordinate missing.

[ ]A saddle point EM cannot escapeBrowser
import numpy as np

completos = np.array([[1, 1], [1, -1], [-1, 1], [-1, -1]], float)
solo_x1 = np.array([2, 2, -2, -2], float)       # x2 perdida
solo_x2 = np.array([2, 2, -2, -2], float)       # x1 perdida
n = len(completos) + len(solo_x1) + len(solo_x2)

def loglik(S):
    # log-verosimilitud observada, salvo constante, con medias conocidas iguales a 0
    Si = np.linalg.inv(S)
    l = -0.5 * len(completos) * np.log(np.linalg.det(S)) - 0.5 * np.sum((completos @ Si) * completos)
    l += -0.5 * len(solo_x1) * np.log(S[0, 0]) - 0.5 * np.sum(solo_x1**2) / S[0, 0]
    l += -0.5 * len(solo_x2) * np.log(S[1, 1]) - 0.5 * np.sum(solo_x2**2) / S[1, 1]
    return l

def paso_em(S):
    T = completos.T @ completos
    # filas con x2 perdida: E[x2 | x1] = b x1 y Var[x2 | x1] = v
    b, v = S[0, 1] / S[0, 0], S[1, 1] - S[0, 1]**2 / S[0, 0]
    a2 = np.sum(solo_x1**2)
    T = T + np.array([[a2, b * a2], [b * a2, b * b * a2 + len(solo_x1) * v]])
    b, v = S[0, 1] / S[1, 1], S[0, 0] - S[0, 1]**2 / S[1, 1]
    a2 = np.sum(solo_x2**2)
    T = T + np.array([[b * b * a2 + len(solo_x2) * v, b * a2], [b * a2, a2]])
    return T / n

for rho0 in [0.0, 0.01, -0.01]:
    S = np.array([[1.0, rho0], [rho0, 1.0]])
    for k in range(300):
        S = paso_em(S)
    rho = S[0, 1] / np.sqrt(S[0, 0] * S[1, 1])
    print(f"rho0 = {rho0:+.2f}  ->  s11 = {S[0, 0]:.4f}, s22 = {S[1, 1]:.4f}, rho = {rho:+.4f}, l = {loglik(S):.4f}")

# naturaleza del punto (s11, s22, rho) = (2.5, 2.5, 0): hessiano numérico de l
def l_par(p):
    s11, s22, r = p
    c = r * np.sqrt(s11 * s22)
    return loglik(np.array([[s11, c], [c, s22]]))
p0, h = np.array([2.5, 2.5, 0.0]), 1e-4
H = np.zeros((3, 3))
for i in range(3):
    for j in range(3):
        ei, ej = np.eye(3)[i] * h, np.eye(3)[j] * h
        H[i, j] = (l_par(p0 + ei + ej) - l_par(p0 + ei - ej) - l_par(p0 - ei + ej) + l_par(p0 - ei - ej)) / (4 * h * h)
print("autovalores del hessiano en (2.5, 2.5, 0):", np.round(np.linalg.eigvalsh(H), 4))

From ρ0=0\rho_0 = 0, EM converges to σ11=σ22=2.5\sigma_{11} = \sigma_{22} = 2.5 and ρ=0\rho = 0, and never escapes: with zero covariance the E-step imputes E[x2∣x1]=0\E[x_2 \given x_1] = 0 and the M-step returns zero covariance again. The Hessian has two negative eigenvalues and one positive (in the ρ\rho direction): a saddle point. Merely setting ρ0=±0.01\rho_0 = \pm 0.01 makes EM reach one of two global maxima, σ11=σ22=8/3≈2.6667\sigma_{11} = \sigma_{22} = 8/3 \approx 2.6667 and ρ=±1/2\rho = \pm 1/2, with higher log-likelihood. Mixtures behave the same if two components start identical: the E-step gives them equal responsibilities and the M-step leaves them identical forever.

Speed: linear rate and missing information

Near a maximum θ⋆\theta^\star, EM behaves like a fixed-point iteration θk+1=M(θk)\theta_{k+1} = M(\theta_k) with M(θ⋆)=θ⋆M(\theta^\star) = \theta^\star. If MM is differentiable,

θk+1−θ⋆≈J (θk−θ⋆),J=DM(θ⋆),\theta_{k+1} - \theta^\star \approx \mat{J}\,(\theta_k - \theta^\star), \qquad \mat{J} = DM(\theta^\star),

and error decreases as ρ(J)k\rho(\mat{J})^k, where ρ\rho is the spectral radius. Dempster, Laird and Rubin calculated J\mat{J} and gave it a statistical interpretation. Define, all evaluated at θ⋆\theta^\star:

  • complete information Ic=−∇θ2Q(θ∣θ⋆)∣θ⋆\mat{I}_c = -\grad^2_{\theta} Q(\theta \given \theta^\star)\big|_{\theta^\star}, the Fisher information you would have if you also observed zz (averaged over the posterior);
  • missing information Im=−∇θ2 Ep(z∣x,θ⋆)[log⁡p(Z∣x,θ)]∣θ⋆\mat{I}_m = -\grad^2_{\theta}\, \E_{p(z \given x, \theta^\star)}[\log p(Z \given x, \theta)]\big|_{\theta^\star}, what is missing because zz is unseen;
  • observed information Iobs=−∇2ℓ(θ⋆)\mat{I}_{\text{obs}} = -\grad^2 \ell(\theta^\star).

Since ℓ(θ)=log⁡p(x,z∣θ)−log⁡p(z∣x,θ)\ell(\theta) = \log p(x, z \given \theta) - \log p(z \given x, \theta) for every zz, taking the posterior expectation at θ⋆\theta^\star and differentiating twice gives the missing information principle (Orchard and Woodbury, 1972): Iobs=Ic−Im\mat{I}_{\text{obs}} = \mat{I}_c - \mat{I}_m. Observed information is complete information minus missing information.

∇θQ(M(ψ)∣ψ)=0\grad_\theta Q\big(M(\psi) \given \psi\big) = 0
For every ψ\psi near θ⋆\theta^\star: the M-step is an interior maximum of Q(⋅∣ψ)Q(\cdot \given \psi). Suppose QQ is twice differentiable and Ic\mat{I}_c positive definite; the implicit function theorem makes MM differentiable near θ⋆\theta^\star.
1/5
Proof

Ic−1Im\mat{I}_c^{-1}\mat{I}_m is similar to the symmetric matrix Ic−1/2ImIc−1/2\mat{I}_c^{-1/2}\mat{I}_m\mat{I}_c^{-1/2}, so its eigenvalues are real. Im\mat{I}_m is positive semidefinite (it is the posterior covariance of the score of p(z∣x,θ)p(z \given x, \theta), or, without that step, the negative Hessian of a function maximized at θ⋆\theta^\star), so they are ≥0\ge 0. And Ic−1/2ImIc−1/2=I−Ic−1/2IobsIc−1/2\mat{I}_c^{-1/2}\mat{I}_m\mat{I}_c^{-1/2} = \mat{I} - \mat{I}_c^{-1/2}\mat{I}_{\text{obs}}\mat{I}_c^{-1/2} with the last term positive definite, so they are <1< 1. For linear convergence, apply the fixed-point theorem using a norm adapted to DM(θ⋆)DM(\theta^\star).

∎

The interpretation is direct: EM is slower when a larger fraction of information is missing. If latent variables contribute little (well-separated components, few missing entries), λ≈0\lambda \approx 0 and EM converges in a handful of iterations. If almost all information is in what you cannot see (overlapping components, much missing data), λ→1\lambda \to 1 and EM crawls.

An explicit example: zi∼N(θ,1)z_i \sim \Normal(\theta, 1) and xi∣zi∼N(zi,σ2)x_i \given z_i \sim \Normal(z_i, \sigma^2), observing only xx. With complete data, θ\theta is estimated from the ziz_i and Ic=nI_c = n. With observed data, xi∼N(θ,1+σ2)x_i \sim \Normal(\theta, 1 + \sigma^2) and Iobs=n/(1+σ2)I_{\text{obs}} = n/(1 + \sigma^2). The rate is λ=1−1/(1+σ2)=σ2/(1+σ2)\lambda = 1 - 1/(1 + \sigma^2) = \sigma^2/(1 + \sigma^2), and indeed the EM step is exactly θk+1−xˉ=λ(θk−xˉ)\theta_{k+1} - \bar x = \lambda(\theta_k - \bar x). With σ2=9\sigma^2 = 9, λ=0.9\lambda = 0.9. The second interactive, in the next section, uses this same model.

InteractiveWhen EM becomes slow
Error log⁡10∣πk−π⋆∣\log_{10}|\pi_k - \pi^\star| versus iteration kk
  • EM
  • slope log⁡10λ\log_{10}\lambda with λ=1−Iobs/Ic\lambda = 1 - I_{\mathrm{obs}}/I_c
  • where criterion stops
Linear rate versus separation: theory (line) and measurement (points)
  • missing information fraction
  • rate measured in iterates
  • current separation
1.50
0.30
6
MLE π⋆\pi^\star0.3000
Fraction of missing information 1−Iobs/Ic1 - I_{\mathrm{obs}}/I_c0.6445
Empirical EM rate0.6445
Iterations until ∣πk−π⋆∣<10−8|\pi_k - \pi^\star| < 10^{-8}41
Criterion stops at iteration22
Actual error at stopping ∣πk−π⋆∣|\pi_k - \pi^\star|3.9e−5
Last step ∣πk−πk−1∣|\pi_k - \pi_{k-1}|2.1e−5
Error remaining at stopping is about λ/(1−λ)=1.8\lambda/(1-\lambda) = 1.8 times the last step (prediction: 3.9e−5). With overlapping components, a tiny step does not mean proximity.
Mixture π N(−Δ/2,1)+(1−π) N(Δ/2,1)\pi\,\Normal(-\Delta/2, 1) + (1 - \pi)\,\Normal(\Delta/2, 1) with 400 observations, estimating only weight π\pi starting from π0=0.9\pi_0 = 0.9. Above, error on a logarithmic scale: a straight line with slope predicted by the missing-information fraction (dashed line). Below, that fraction versus separation, with the rate measured from iterates overlaid. Reduce Δ\Delta to 0.5 and observe iterations; then set τ=4\tau = 4 and compare actual stopping error with the last step.

The cell calculates the same table as the interactive so you can check its numbers.

[ ]Measured rate versus missing informationBrowser
import numpy as np
from scipy.stats import norm
from scipy.optimize import brentq

def datos(delta, w, n=400):
    n1 = round(n * w)
    q = lambda c, m: c + norm.ppf((np.arange(m) + 0.5) / m)
    x = np.concatenate([q(-delta / 2, n1), q(delta / 2, n - n1)])
    return norm.pdf(x + delta / 2), norm.pdf(x - delta / 2)

def paso_em(f1, f2, p):
    return np.mean(p * f1 / (p * f1 + (1 - p) * f2))

print(" Delta    pi*    1 - Iobs/Ic   tasa medida   iteraciones hasta 1e-8")
for delta in [0.5, 1.0, 1.5, 2.0, 3.0, 4.0]:
    f1, f2 = datos(delta, 0.3)
    d1 = lambda p: np.sum((f1 - f2) / (p * f1 + (1 - p) * f2))     # l'(pi), decreciente
    ps = brentq(d1, 1e-9, 1 - 1e-9, xtol=1e-15)
    Iobs = np.sum(((f1 - f2) / (ps * f1 + (1 - ps) * f2))**2)
    Ic = len(f1) / (ps * (1 - ps))
    p, err = 0.9, [0.4]
    while err[-1] > 1e-12 and len(err) < 20000:
        p = paso_em(f1, f2, p)
        err.append(abs(p - ps))
    err = np.array(err)
    k8 = int(np.argmax(err < 1e-8))
    cocientes = err[1:] / err[:-1]
    medida = np.median(cocientes[(err[:-1] < 1e-3) & (err[1:] > 1e-10)])
    print(f"{delta:5.1f}  {ps:.4f}     {1 - Iobs / Ic:.4f}        {medida:.4f}        {k8:6d}")

The missing-information fraction and measured rate agree to all four digits in every row. Moving from Δ=4\Delta = 4 to Δ=0.5\Delta = 0.5 raises the rate from below 0.1 to almost 0.95 and multiplies iterations more than fortyfold. Note that this is the mixture’s easiest parameter: with everything unknown (means, variances and weights), the same separation Δ=2.5\Delta = 2.5 gives a rate of 0.97 and almost 600 iterations in the second practice.

The stopping criterion can mislead

The linear rate has an often-forgotten practical consequence. If θk+1−θ⋆≈λ(θk−θ⋆)\theta_{k+1} - \theta^\star \approx \lambda(\theta_k - \theta^\star) in the scalar case, the geometric series gives

∣θk+1−θ⋆∣≈λ1−λ ∣θk+1−θk∣.\abs{\theta_{k+1} - \theta^\star} \approx \frac{\lambda}{1 - \lambda}\,\abs{\theta_{k+1} - \theta_k}.

With λ=0.99\lambda = 0.99, remaining error is about 99 times the last step. A criterion like “stop when ℓ\ell changes by less than 10−610^{-6}” is worse: near the maximum ℓ(θ⋆)−ℓ(θk)≈12Iobs(θk−θ⋆)2\ell(\theta^\star) - \ell(\theta_k) \approx \tfrac12 I_{\text{obs}}(\theta_k - \theta^\star)^2, quadratic in error and also small precisely when IobsI_{\text{obs}} is small, that is, when EM is slow. If parameters matter (not only likelihood), estimate λ\lambda from the ratio of successive steps and correct or accelerate.

Neal and Hinton’s view: coordinate ascent

Neal and Hinton (1998) read the decomposition differently. Call the bound F(q,θ)=L(q,θ)F(q, \theta) = \mathcal{L}(q, \theta), viewed as a function of two arguments: a distribution qq over latent variables and parameters θ\theta. Then:

  • the E-step is qk=arg max⁡qF(q,θk)q_k = \argmax_q F(q, \theta_k), because F(q,θk)=ℓ(θk)−KL⁡(q ∥ p(z∣x,θk))F(q, \theta_k) = \ell(\theta_k) - \KL(q \,\|\, p(z \given x, \theta_k)) is maximal when KL is zero;
  • the M-step is θk+1=arg max⁡θF(qk,θ)\theta_{k+1} = \argmax_\theta F(q_k, \theta).

EM is block coordinate ascent on FF. Neal and Hinton also proved that if (q⋆,θ⋆)(q^\star, \theta^\star) is a local (global) maximum of FF, then θ⋆\theta^\star is a local (global) maximum of ℓ\ell: maximizing FF over both variables maximizes ℓ\ell. This view has three consequences:

  1. Any step increasing FF works. Exact maximization of neither coordinate is required. A partial E-step moving qq closer to the posterior without reaching it, or a partial M-step increasing QQ without maximizing it (generalized EM), maintains monotonicity of FF.
  2. Incremental EM. For iid data, q(z)=∏iqi(zi)q(z) = \prod_i q_i(z_i) and F=∑iFi(qi,θ)F = \sum_i F_i(q_i, \theta). You can update qiq_i for one observation (or a minibatch) and immediately perform the M-step with accumulated sufficient statistics s=∑isˉis = \sum_i \bar s_i, subtracting the old contribution and adding the new. Each update increases FF, and the M-step uses new information without waiting for a full pass, so it often needs fewer passes than standard EM (Neal and Hinton illustrate this with a Gaussian mixture).
  3. Sparse EM. In a mixture with many components, most responsibilities for each point are almost zero. Freeze them and update only those of a few plausible components, with a full E-step occasionally.

To see the geometry, qq must fit on one axis. In the model zi∼N(θ,1)z_i \sim \Normal(\theta, 1), xi∣zi∼N(zi,σ2)x_i \given z_i \sim \Normal(z_i, \sigma^2), the family qt=p(z∣x,t)q_t = p(z \given x, t), indexed by scalar tt, contains the posterior for each θ\theta, and F(t,θ)=L(qt,θ)F(t, \theta) = \mathcal{L}(q_t, \theta) is a function of two real variables. Computing Gaussian expectations, per observation and up to a constant,

F(t,θ)n=−12(θ−c t−(1−c) xˉ)2−c2 (xˉ−t)22σ2,c=σ21+σ2.\frac{F(t, \theta)}{n} = -\tfrac12\big(\theta - c\,t - (1 - c)\,\bar x\big)^2 - \frac{c^2\,(\bar x - t)^2}{2\sigma^2}, \qquad c = \frac{\sigma^2}{1 + \sigma^2}.

Maximizing over tt gives t=θt = \theta (the E-step), and maximizing over θ\theta gives θ=c t+(1−c) xˉ\theta = c\,t + (1 - c)\,\bar x (the M-step). The Hessian of −F/n-F/n in (θ,t)(\theta, t) is [1−c−cc]\begin{bmatrix} 1 & -c \\ -c & c \end{bmatrix}: as c→1c \to 1 it is almost singular and contours are elongated ellipses along the diagonal.

InteractiveEM as coordinate ascent
Contours of F(qt,θ)F(q_t, \theta): θ\theta horizontally, the index tt of qq vertically
move 188
  • EM: vertical (E), horizontal (M)
  • joint gradient
  • t=θt = \theta: qq is the posterior, F=ℓ(θ)F = \ell(\theta)
  • maximum of FF in θ\theta for each tt (M-step)

Starting point (θ0,t0)=(−0.50,4.50)(\theta_0, t_0) = (−0.50, 4.50). The maximum is at (xˉ,xˉ)=(2,2)(\bar x, \bar x) = (2, 2), the MLE.

4.0
Compare EM with
0.60
EM rate c=σ2/(1+σ2)c = \sigma^2/(1+\sigma^2)0.800
EM iterations to 10−310^{-3}38
Gradient steps to 10−310^{-3}94
Best fixed-step gradient rate0.896 (η = 1.11)
Largest decrease in FF along gradient path0.0000
Each EM step exactly maximizes one coordinate. Even its best fixed step (rate 0.896) cannot match EM’s rate (0.800) here.
Contours of F(qt,θ)F(q_t, \theta) with xˉ=2\bar x = 2. EM (blue) alternates a vertical move to the diagonal (E-step: qq becomes the posterior) and a horizontal move to the green line (M-step). Compare with joint gradient ascent (orange) and try its best step; then switch to 'Partial steps' and reduce α\alpha or raise β\beta above 1. Increase σ2\sigma^2: the valley lengthens, EM takes shorter and shorter steps, and rate cc approaches 1.

The figure shows the previous section’s linear rate from another angle. EM’s staircase between the diagonal and M-step line shrinks by a factor cc each iteration, because the lines intersect at an ever smaller angle as c→1c \to 1: the zigzag of block descent in a narrow valley. Joint gradient ascent with a fixed step cannot escape either: with σ2=4\sigma^2 = 4 its best rate is 0.896 versus EM’s 0.8, and beyond step 2/λmax⁡2/\lambda_{\max} it diverges. EM has no learning rate: every move is an exact maximization, which makes it popular despite its slowness.

The move to an online version is natural. Cappé and Moulines (2009) propose, for complete exponential-family models, maintaining an estimate of per-observation sufficient statistics and updating it with each new observation as a Robbins-Monro stochastic approximation:

sn=sn−1+γn(E[T(xn,Z)∣xn,θ(sn−1)]−sn−1),θn=θˉ(sn),s_{n} = s_{n-1} + \gamma_{n}\big(\E[T(x_n, Z) \given x_n, \theta(s_{n-1})] - s_{n-1}\big), \qquad \theta_n = \bar\theta(s_n),

where θˉ(s)\bar\theta(s) is the M-step applied to ss and γn\gamma_n are decreasing steps with ∑nγn=∞\sum_n \gamma_n = \infty and ∑nγn2<∞\sum_n \gamma_n^2 < \infty. They show convergence to stationary points of the KL divergence between data distribution and model and, with steps γn=n−α\gamma_n = n^{-\alpha}, α∈(1/2,1)\alpha \in (1/2, 1), and iterate averaging, to the same optimal rate as maximum likelihood. This version is used for data streams or datasets too large for memory.

EM as an MM algorithm

An even more general view does not need latent variables.

The ascent property follows in one line:

f(θk+1)≥g(θk+1∣θk)≥g(θk∣θk)=f(θk).f(\theta_{k+1}) \ge g(\theta_{k+1} \given \theta_k) \ge g(\theta_k \given \theta_k) = f(\theta_k).

EM is the case f=ℓf = \ell and g(θ∣θk)=L(qk,θ)=Q(θ∣θk)+H⁡(qk)g(\theta \given \theta_k) = \mathcal{L}(q_k, \theta) = Q(\theta \given \theta_k) + \Ent(q_k): decomposition proves it minorizes, and the E-step constructs it. The orange parabola in the first interactive is precisely a minorizer. MM is broader than EM because the minorizer may come from any inequality, not only introducing latent variables. The tutorial by Hunter and Lange (2004) collects common tools: Jensen (giving EM), the arithmetic-geometric mean inequality, a convex function’s tangent bound, or a quadratic bound with uniform Hessian. Two examples worth knowing:

  • Logistic regression with a quadratic bound. The logistic log-likelihood Hessian satisfies −∇2ℓ⪯14X⊤X-\grad^2 \ell \preceq \tfrac14\mat{X}\T\mat{X}. The quadratic with this curvature touching ℓ\ell at wk\vb{w}_k minorizes it, and its maximum gives wk+1=wk+4(X⊤X)−1∇ℓ(wk)\vb{w}_{k+1} = \vb{w}_k + 4(\mat{X}\T\mat{X})^{-1}\grad\ell(\vb{w}_k): a Newton step with a fixed Hessian factored only once (Böhning and Lindsay, 1988).
  • Geometric median. Minimizing ∑i∥xi−m∥\sum_i \norm{\vb{x}_i - \vb{m}} with the majorizer ∥u∥≤∥u∥22∥uk∥+∥uk∥2\norm{\vb{u}} \le \frac{\norm{\vb{u}}^2}{2\norm{\vb{u}_k}} + \frac{\norm{\vb{u}_k}}{2} gives the Weiszfeld iteration, a weighted average with weights 1/∥xi−mk∥1/\norm{\vb{x}_i - \vb{m}_k}.

MM and EM share the guarantee’s structure and its price: monotonicity without a learning rate, in exchange for linear convergence that becomes slower as the minorizer approximates ff‘s curvature more poorly. In EM, that curvature difference is precisely Ic\mat{I}_c versus Iobs\mat{I}_{\text{obs}}.

EM variants

Each part of EM can be relaxed, and these relaxations are the EM variants used in practice.

  • Generalized EM (GEM). Already in Dempster, Laird and Rubin: it suffices to find θk+1\theta_{k+1} with Q(θk+1∣θk)≥Q(θk∣θk)Q(\theta_{k+1} \given \theta_k) \ge Q(\theta_k \given \theta_k), for example a few gradient or Newton steps on QQ. It preserves monotonicity (the theorem above already covers it).
  • ECM (expectation conditional maximization, Meng and Rubin, 1993). When the M-step has no closed form but does by parameter blocks, replace it with conditional maximizations: first θ1\theta_1 with θ2\theta_2 fixed, then θ2\theta_2 with the new θ1\theta_1. It is a GEM and preserves EM convergence properties.
  • Hard EM (or classification EM). The E-step replaces the posterior with its mode: qkq_k places all mass on z^=arg max⁡zp(z∣x,θk)\hat z = \argmax_z p(z \given x, \theta_k). Then F(qk,θ)=log⁡p(x,z^∣θ)F(q_k, \theta) = \log p(x, \hat z \given \theta) and the algorithm is coordinate ascent on complete likelihood over (z,θ)(z, \theta), not on ℓ\ell. Lloyd’s algorithm is hard EM for isotropic Gaussian mixtures with equal variance and weight. It is faster and finishes in finitely many steps, but estimates something different: with overlapping components its means are biased outward.
  • Stochastic and Monte Carlo EM. When the E-step expectation is intractable, approximate it with posterior samples. Stochastic EM (SEM, Celeux and Diebolt, 1985) imputes one sample per iteration: iterates form a Markov chain that fluctuates around the estimator rather than converging to a point, and is averaged. Monte Carlo EM (Wei and Tanner, 1990) uses mm samples and increases mm with iterations. SAEM (Delyon, Lavielle and Moulines, 1999) combines one sample per iteration with stochastic-approximation averaging of QQ, and converges.
  • Incremental and online EM. From the previous section: update qq one observation at a time (Neal and Hinton) or sufficient statistics with decreasing steps (Cappé and Moulines).
VariantWhat changesGuaranteeWhen to use
EMexact E- and M-stepsℓ\ell does not decrease; stationary pointsclosed-form E- and M-steps
GEM, ECMM-step only increases QQℓ\ell does not decreaseno closed-form M-step
incrementalE-step on one observation or minibatchFF does not decreasemany observations fitting in memory
onlinestatistics with decreasing stepsstationary points in the limitstreams, data too large for memory
stochastic, MCEM, SAEME-step by samplingin distribution or with averagingintractable posterior
hardmode instead of posteriorcomplete likelihood does not decreasespeed; biases parameters

The cell compares EM, hard EM and online EM on a two-Gaussian mixture with variance 1 and equal weights, means at ±1\pm 1 (separation 2, substantial overlap), and n=20 000n = 20\,000.

[ ]EM, hard EM and online EM on the same mixtureBrowser
import numpy as np

rng = np.random.default_rng(1)
n, Delta = 20000, 2.0
z = rng.uniform(size=n) < 0.5
x = np.where(z, -Delta / 2, Delta / 2) + rng.normal(size=n)

def resp(x, mu):
    a = -0.5 * (x[:, None] - mu)**2          # varianzas 1 y pesos 1/2 conocidos
    a -= a.max(axis=1, keepdims=True)
    r = np.exp(a)
    return r / r.sum(axis=1, keepdims=True)

mu = np.array([-0.3, 0.3])
for k in range(500):
    R = resp(x, mu)
    nuevo = R.T @ x / R.sum(axis=0)
    if np.max(np.abs(nuevo - mu)) < 1e-9:
        break
    mu = nuevo
print(f"EM            ({k + 1:3d} iteraciones): medias {np.round(mu, 3)}")

mu = np.array([-0.3, 0.3])
for k in range(500):
    R = resp(x, mu)
    D = (R == R.max(axis=1, keepdims=True)).astype(float)   # paso E duro
    nuevo = D.T @ x / D.sum(axis=0)
    if np.max(np.abs(nuevo - mu)) < 1e-12:
        break
    mu = nuevo
print(f"EM duro       ({k + 1:3d} iteraciones): medias {np.round(mu, 3)}")

# EM en línea: s0 = E[r], s1 = E[r x] por componente; una sola pasada por los datos
s0, s1 = np.array([0.5, 0.5]), np.array([-0.15, 0.15])
mu, prom, inicio = s1 / s0, np.zeros(2), n // 10
for i in range(n):
    g = (i + 2) ** -0.6
    r = resp(x[i:i + 1], mu)[0]
    s0 = s0 + g * (r - s0)
    s1 = s1 + g * (r * x[i] - s1)
    mu = s1 / s0
    if i >= inicio:
        prom += (mu - prom) / (i - inicio + 1)
print(f"EM en línea   (1 pasada):          último {np.round(mu, 3)}, promediado {np.round(prom, 3)}")

EM recovers means very close to ±1\pm 1. Hard EM converges in fewer iterations, but to means shifted outward: every point falling on the wrong side is fully assigned to the other component, so each component is estimated from a truncated normal whose mean lies farther from the center. Online EM makes a single pass; its final iterate still fluctuates with step γn=n−0.6\gamma_n = n^{-0.6} and the average of iterates is much closer to the EM means.

Missing data: when EM is valid

With missing data, the question is not only how to compute the estimator, but whether it estimates what you want. Rubin (1976) formalized this with an indicator RR of which entries are missing, distributed as p(R∣xobs,xmis,ϕ)p(R \given x_{\text{obs}}, x_{\text{mis}}, \phi):

  • MCAR (missing completely at random): p(R∣x,ϕ)=p(R∣ϕ)p(R \given x, \phi) = p(R \given \phi). Missingness does not depend on any data.
  • MAR (missing at random): p(R∣x,ϕ)=p(R∣xobs,ϕ)p(R \given x, \phi) = p(R \given x_{\text{obs}}, \phi). It may depend on observed values, not missing ones.
  • MNAR (missing not at random): it also depends on missing values.
Proof
p(xobs,R∣θ,ϕ)=∫p(xobs,xmis∣θ) p(R∣xobs,xmis,ϕ) ⁣dxmis=p(R∣xobs,ϕ)∫p(xobs,xmis∣θ) ⁣dxmis,p(x_{\text{obs}}, R \given \theta, \phi) = \int p(x_{\text{obs}}, x_{\text{mis}} \given \theta)\, p(R \given x_{\text{obs}}, x_{\text{mis}}, \phi) \dd x_{\text{mis}} = p(R \given x_{\text{obs}}, \phi) \int p(x_{\text{obs}}, x_{\text{mis}} \given \theta) \dd x_{\text{mis}},

where the second equality is the MAR assumption, allowing the factor outside the integral. The integral is p(xobs∣θ)p(x_{\text{obs}} \given \theta), and the factor p(R∣xobs,ϕ)p(R \given x_{\text{obs}}, \phi) does not depend on θ\theta.

∎

This defines EM with missing data: applied to p(xobs∣θ)p(x_{\text{obs}} \given \theta) with z=xmisz = x_{\text{mis}}, it calculates the correct maximum likelihood estimator under MCAR and MAR. Under MNAR, the mechanism factor depends on xmisx_{\text{mis}}, cannot leave the integral, and ignoring it biases the estimator; model RR explicitly (selection or pattern-mixture models) and, because the data cannot distinguish MAR from MNAR, accompany it with sensitivity analysis.

For a multivariate normal N(μ,Σ)\Normal(\vb{\mu}, \mat{\Sigma}) with entries missing at arbitrary positions, sufficient statistics are ∑ixi\sum_i \vb{x}_i and ∑ixixi⊤\sum_i \vb{x}_i\vb{x}_i\T. In row ii, with observed indices oo and missing indices mm, the E-step uses the conditional normal:

x^i,m=μm+ΣmoΣoo−1(xi,o−μo),Ci,mm=Σmm−ΣmoΣoo−1Σom.\hat{\vb{x}}_{i,m} = \vb{\mu}_m + \mat{\Sigma}_{mo}\mat{\Sigma}_{oo}^{-1}(\vb{x}_{i,o} - \vb{\mu}_o), \qquad \mat{C}_{i,mm} = \mat{\Sigma}_{mm} - \mat{\Sigma}_{mo}\mat{\Sigma}_{oo}^{-1}\mat{\Sigma}_{om}.

E[xi∣xi,o]\E[\vb{x}_i \given \vb{x}_{i,o}] is x^i\hat{\vb{x}}_i (observed and imputed values) and E[xixi⊤∣xi,o]=x^ix^i⊤+Ci\E[\vb{x}_i\vb{x}_i\T \given \vb{x}_{i,o}] = \hat{\vb{x}}_i\hat{\vb{x}}_i\T + \mat{C}_i, with Ci\mat{C}_i equal to Ci,mm\mat{C}_{i,mm} in the missing block and zero elsewhere. The M-step is the complete-data step:

μ=1n∑ix^i,Σ=1n∑i(x^ix^i⊤+Ci)−μμ⊤.\vb{\mu} = \frac1n\sum_i \hat{\vb{x}}_i, \qquad \mat{\Sigma} = \frac1n\sum_i\big(\hat{\vb{x}}_i\hat{\vb{x}}_i\T + \mat{C}_i\big) - \vb{\mu}\vb{\mu}\T.

The Ci\mat{C}_i term distinguishes EM from impute-and-forget: filling in the conditional mean and estimating covariance of filled data underestimates variances because it treats imputed values as observed without uncertainty.

InteractiveEM with missing data
  • complete rows
  • x1x_1 of incomplete rows
  • 2σ2\sigma ellipse: complete sample
  • complete cases
  • mean imputation
  • EM
  • true model
Missingness mechanism for x2x_2
40 %
Rows with missing x2x_2120 of 300 (40 %)
EM iterations86
μ^2\hat\mu_2σ^22\hat\sigma_2^2ρ^\hat\rho
Complete sample−0.160.960.71
Complete cases−0.550.760.54
Mean imputation−0.550.460.31
EM−0.210.960.66
MAR: x2x_2 is missing mostly when x1x_1 is large. Complete cases underestimate μ2\mu_2 (error 0.388); EM recovers it (error 0.047) because it models x2∣x1x_2 \mid x_1 using complete rows.
300 pairs from a bivariate normal with correlation 0.7; x2x_2 is missing in a proportion of rows according to the mechanism. The 2σ2\sigma ellipses compare complete cases (orange), mean imputation (purple) and EM (blue) to the full sample (gray), the best any method can aspire to. Start with MAR: complete cases move downward while EM stays with gray. Switch to MNAR and MCAR, and raise the proportion to 70%.

In the initial state (MAR, 40% of x2x_2 missing, more likely when x1x_1 is larger), complete cases lose mostly high-x1x_1 rows, and since x2x_2 correlates with x1x_1, their x2x_2 mean is too low. EM uses incomplete rows through x1x_1: the regression of x2x_2 on x1x_1 estimated from complete rows is valid under MAR because missingness depends only on x1x_1, and it reconstructs the marginal distribution of x2x_2. Mean imputation leaves μ^2\hat\mu_2 exactly equal to complete cases (it fills with their mean) and also compresses variance and correlation because it adds points with no spread in x2x_2. Under MNAR (missingness depends on x2x_2 itself), EM reduces mean bias because x1x_1 carries some information about missing values, but does not eliminate it, and the interactive cannot help detect it: observed data alone do not distinguish MAR from MNAR.

Implementation from scratch

What all EM algorithms share fits in a base class: a loop alternating e_step and m_step, evaluating log-likelihood and checking monotonicity every iteration. This check is the safety net separating a correct implementation from one that only looks correct.

[ ]Generic EM with monotonicity checking and a Bernoulli mixtureBrowser
import numpy as np
from scipy.special import logsumexp
from sklearn.datasets import load_digits

class EM:
    """Bucle común. Las subclases definen e_step, m_step y objective (log-verosimilitud, más log p(theta) si es MAP)."""
    def e_step(self, X): raise NotImplementedError
    def m_step(self, X, stats): raise NotImplementedError
    def objective(self, X): raise NotImplementedError

    def fit(self, X, max_iter=200, rtol=1e-8, check=True):
        self.history = [self.objective(X)]
        for it in range(1, max_iter + 1):
            self.m_step(X, self.e_step(X))
            obj = self.objective(X)
            prev = self.history[-1]
            if check and obj < prev - 1e-10 * abs(prev):
                raise RuntimeError(f"el objetivo bajó en la iteración {it}: {prev:.6f} -> {obj:.6f}")
            self.history.append(obj)
            if obj - prev < rtol * abs(obj):
                break
        return self

class BernoulliMixture(EM):
    """Mezcla de K productos de Bernoulli, con a priori Beta(1 + a, 1 + a) sobre cada mu_kj (EM para el MAP)."""
    def __init__(self, K, seed, a=1e-3):
        self.K, self.rng, self.a = K, np.random.default_rng(seed), a

    def init(self, X):
        self.pi = np.full(self.K, 1 / self.K)
        self.mu = self.rng.uniform(0.25, 0.75, size=(self.K, X.shape[1]))
        return self

    def log_joint(self, X):                                   # n x K: log pi_k + log p(x_i | mu_k)
        return np.log(self.pi) + X @ np.log(self.mu).T + (1 - X) @ np.log1p(-self.mu).T

    def e_step(self, X):
        A = self.log_joint(X)
        return np.exp(A - logsumexp(A, axis=1, keepdims=True))   # responsabilidades r_ik

    def m_step(self, X, R):
        Nk = R.sum(axis=0)
        self.pi = Nk / len(X)
        self.mu = (R.T @ X + self.a) / (Nk[:, None] + 2 * self.a)

    def objective(self, X):
        log_prior = self.a * np.sum(np.log(self.mu) + np.log1p(-self.mu))
        return logsumexp(self.log_joint(X), axis=1).sum() + log_prior

digits = load_digits()
X = (digits.data > 7).astype(float)        # 1797 dígitos de 8 x 8, binarizados
y = digits.target
mejor = None
for seed in range(3):
    m = BernoulliMixture(10, seed).init(X).fit(X)
    print(f"semilla {seed}: {len(m.history) - 1:3d} iteraciones, objetivo final {m.history[-1]:.1f}, "
          f"menor subida {np.min(np.diff(m.history)):.2e}")
    if mejor is None or m.history[-1] > mejor.history[-1]:
        mejor = m
z = mejor.e_step(X).argmax(axis=1)
pureza = sum(np.bincount(y[z == k]).max() for k in range(10) if np.any(z == k)) / len(y)
print(f"pureza del mejor ajuste respecto a las etiquetas (que EM no ha visto): {pureza:.3f}")

The three seeds end at different objectives: different local maxima, with hundreds of log-likelihood units between best and worst. The smallest per-iteration increase is positive in all three, as the theorem requires. Purity measures the fraction of digits in a group whose majority label matches theirs; without seeing labels, the mixture groups most by digit. Look at the ten prototypes μk\vb{\mu}_k:

[ ]Mixture prototypesBrowser
import matplotlib.pyplot as plt

orden = np.argsort(-mejor.pi)
fig, ejes = plt.subplots(1, 10, figsize=(10, 1.4))
for eje, k in zip(ejes, orden):
    eje.imshow(mejor.mu[k].reshape(8, 8), cmap="gray_r", vmin=0, vmax=1)
    eje.set_title(f"{mejor.pi[k]:.2f}", fontsize=8)
    eje.axis("off")
plt.show()

Now use the check. This subclass has a common error: the E-step forgets (1−xij)log⁡(1−μkj)(1 - x_{ij})\log(1 - \mu_{kj}). Responsibilities still sum to 1 and the result looks reasonable, but they are no longer the posterior.

[ ]Monotonicity checking catches an incorrect E-stepBrowser
class BernoulliMixtureConError(BernoulliMixture):
    def e_step(self, X):
        A = np.log(self.pi) + X @ np.log(self.mu).T          # falta (1 - X) @ log(1 - mu).T
        return np.exp(A - logsumexp(A, axis=1, keepdims=True))

for seed in range(3):
    try:
        BernoulliMixtureConError(10, seed).init(X).fit(X)
        print(f"semilla {seed}: no ha saltado la comprobación")
    except RuntimeError as e:
        print(f"semilla {seed}: {e}")

For at least one seed the objective decreases after a few iterations and the check catches it. For another it may not trigger during the fit: monotonicity is necessary for correct EM, not sufficient. Therefore combine it with a check that the gradient of ℓ\ell is near zero at the endpoint.

The same base class works for a normal with missing data. Here a bivariate example has x2x_2 missing under MAR (more likely as x1x_1 increases); the final coding exercise asks for the general version with arbitrary patterns in dd dimensions.

[ ]A bivariate normal with MAR missing dataBrowser
from scipy.stats import multivariate_normal

class Gauss2Faltante(EM):
    """x2 puede faltar (NaN); x1 se observa siempre."""
    def init(self, X):
        obs = ~np.isnan(X[:, 1])
        self.mu = np.array([X[:, 0].mean(), X[obs, 1].mean()])
        self.S = np.diag([X[:, 0].var(), X[obs, 1].var()])
        return self

    def e_step(self, X):
        falta = np.isnan(X[:, 1])
        b = self.S[0, 1] / self.S[0, 0]
        v = self.S[1, 1] - self.S[0, 1] * b
        Xh = X.copy()
        Xh[falta, 1] = self.mu[1] + b * (X[falta, 0] - self.mu[0])
        extra = np.zeros(len(X))
        extra[falta] = v                     # Var[x2 | x1]: el término que olvida la imputación simple
        return Xh, extra

    def m_step(self, X, stats):
        Xh, extra = stats
        self.mu = Xh.mean(axis=0)
        S = Xh.T @ Xh / len(X) - np.outer(self.mu, self.mu)
        S[1, 1] += extra.mean()
        self.S = S

    def objective(self, X):
        falta = np.isnan(X[:, 1])
        l = multivariate_normal(self.mu, self.S).logpdf(X[~falta]).sum()
        return l + multivariate_normal(self.mu[0], self.S[0, 0]).logpdf(X[falta, 0]).sum()

rng = np.random.default_rng(3)
n, rho = 2000, 0.7
Xc = rng.multivariate_normal([0, 0], [[1, rho], [rho, 1]], size=n)
p_falta = 1 / (1 + np.exp(-(2.5 * Xc[:, 0] - 0.5)))       # MAR: depende solo de x1
X = Xc.copy()
X[rng.uniform(size=n) < p_falta, 1] = np.nan
cc = X[~np.isnan(X[:, 1])]

m = Gauss2Faltante().init(X).fit(X, max_iter=500, rtol=1e-12)
print(f"falta x2 en {np.isnan(X[:, 1]).mean():.0%} de las filas; EM: {len(m.history) - 1} iteraciones")
print(f"{'':18s}{'mu2':>8s}{'s22':>8s}{'rho':>8s}")
def fila(nombre, mu2, S):
    print(f"{nombre:18s}{mu2:8.3f}{S[1, 1]:8.3f}{S[0, 1] / np.sqrt(S[0, 0] * S[1, 1]):8.3f}")
fila("muestra completa", Xc[:, 1].mean(), np.cov(Xc.T, bias=True))
fila("casos completos", cc[:, 1].mean(), np.cov(cc.T, bias=True))
fila("EM", m.mu[1], m.S)

With 42% of x2x_2 missing, complete cases clearly underestimate μ2\mu_2, variance and correlation because they have lost mostly high-x1x_1 rows. EM recovers all three full-sample values with error on the order of sampling error. For this pattern (only one variable missing, the other always observed), the maximum likelihood estimator even has a closed form, and EM converges to it.

EM versus direct optimization

EM is not the only way to maximize ℓ\ell. With Fisher’s identity gradient you can use any optimizer, such as L-BFGS, on an unconstrained parameterization (weight logit, log standard deviations). The cell compares, for a two-Gaussian 1D mixture with all five parameters unknown, n=1000n = 1000 observations and true weights 0.40.4 and 0.60.6:

  • EM, with its linear rate measured from iterates;
  • L-BFGS-B from scipy.optimize, with exact gradient;
  • SQUAREM (Varadhan and Roland, 2008), an extrapolation using two EM steps to estimate the zigzag direction and make a longer jump, with a safeguard falling back to an EM step if the jump reduces ℓ\ell.
[ ]EM, L-BFGS and SQUAREM across overlap levelsBrowser
import numpy as np
from scipy.optimize import minimize
from scipy.special import logsumexp, expit

def log_joint(x, th):
    w, m1, m2, s1, s2 = th
    return np.stack([np.log(w) - np.log(s1) - (x - m1)**2 / (2 * s1**2),
                     np.log1p(-w) - np.log(s2) - (x - m2)**2 / (2 * s2**2)], 1) - 0.5 * np.log(2 * np.pi)

def loglik(x, th):
    return logsumexp(log_joint(x, th), axis=1).sum()

def paso_em(x, th):
    A = log_joint(x, th)
    R = np.exp(A - logsumexp(A, axis=1, keepdims=True))
    N = R.sum(axis=0)
    m = R.T @ x / N
    s = np.sqrt((R * (x[:, None] - m)**2).sum(axis=0) / N)
    return np.array([N[0] / len(x), m[0], m[1], s[0], s[1]])

def em(x, th, tol=1e-9, kmax=3000):
    tray = [th]
    for _ in range(kmax):
        th = paso_em(x, th)
        tray.append(th)
        if np.max(np.abs(tray[-1] - tray[-2])) < tol:
            break
    return th, np.array(tray)

def menos_ll_y_grad(u, x):
    # u = (logit w, m1, m2, log s1, log s2); gradiente por la identidad de Fisher
    w, m1, m2, s1, s2 = expit(u[0]), u[1], u[2], np.exp(u[3]), np.exp(u[4])
    A = log_joint(x, (w, m1, m2, s1, s2))
    L = logsumexp(A, axis=1)
    R = np.exp(A - L[:, None])
    g = np.array([np.sum(R[:, 0] - w),
                  np.sum(R[:, 0] * (x - m1)) / s1**2, np.sum(R[:, 1] * (x - m2)) / s2**2,
                  np.sum(R[:, 0] * ((x - m1)**2 / s1**2 - 1)), np.sum(R[:, 1] * ((x - m2)**2 / s2**2 - 1))])
    return -L.sum(), -g

def squarem(x, th, tol=1e-9, kmax=2000):
    evals = 0
    for k in range(1, kmax + 1):
        t1 = paso_em(x, th); t2 = paso_em(x, t1); evals += 2
        r, v = t1 - th, t2 - 2 * t1 + th
        a = min(-np.linalg.norm(r) / max(np.linalg.norm(v), 1e-300), -1.0)
        tp = th - 2 * a * r + a * a * v
        if not (0 < tp[0] < 1 and tp[3] > 0 and tp[4] > 0) or loglik(x, tp) < loglik(x, th):
            tp = t2                                   # salvaguarda: si el salto no sube l, nos quedamos con EM
        nuevo = paso_em(x, tp); evals += 1
        if np.max(np.abs(nuevo - th)) < tol:
            return nuevo, k, evals
        th = nuevo
    return th, kmax, evals

rng = np.random.default_rng(0)
print(" Delta | EM: iter   tasa   | L-BFGS: iter  eval | SQUAREM: ciclos  pasos EM | max |Delta l|")
resultados = {}
for Delta in [4.0, 3.0, 2.5]:
    z = rng.uniform(size=1000) < 0.4
    x = np.where(z, -Delta / 2, Delta / 2) + rng.normal(size=1000)
    th0 = np.array([0.5, np.quantile(x, 0.25), np.quantile(x, 0.75), x.std(), x.std()])
    thE, tray = em(x, th0)
    pasos = np.linalg.norm(np.diff(tray, axis=0), axis=1)
    cola = pasos[len(pasos) // 2:-1]
    tasa = np.median(cola[1:] / cola[:-1])
    u0 = np.array([0.0, th0[1], th0[2], np.log(th0[3]), np.log(th0[4])])
    res = minimize(menos_ll_y_grad, u0, args=(x,), jac=True, method="L-BFGS-B",
                   options=dict(maxiter=5000, gtol=1e-8, ftol=1e-15))
    thS, kS, eS = squarem(x, th0)
    lls = [loglik(x, thE), -res.fun, loglik(x, thS)]
    print(f"  {Delta:.1f} | {len(tray) - 1:8d}  {tasa:.4f} | {res.nit:12d}  {res.nfev:4d} | {kS:15d}  {eS:8d} | {max(lls) - min(lls):.1e}")
    resultados[Delta] = (x, thE, tasa)

All three methods reach the same log-likelihood (the last column gives their maximum difference). Cost changes. EM needs tens of iterations with Δ=4\Delta = 4 and hundreds with Δ=2.5\Delta = 2.5 because its rate approaches 1; L-BFGS stays below twenty iterations in all three cases, and SQUAREM, using the same EM step as its only building block, needs 30, 42 and 60 EM steps versus 79, 221 and 580: its advantage grows with the rate. EM’s advantage is not speed: each step is simple, respects constraints (weights on the simplex, positive variances) without reparameterization, has no learning rate and never decreases ℓ\ell.

The measured rate should be the largest eigenvalue of DM(θ⋆)DM(\theta^\star). Calculate DMDM by numerically differentiating the EM map itself, without writing down Fisher information; this is the idea of Meng and Rubin’s (1991) SEM (supplemented EM) algorithm for obtaining standard errors from EM.

[ ]The rate matrix by differentiating the EM mapBrowser
x, thE, tasa = resultados[3.0]
thE, _ = em(x, thE, tol=1e-13)                      # afinar el punto fijo
h = 1e-6
DM = np.column_stack([(paso_em(x, thE + h * e) - paso_em(x, thE - h * e)) / (2 * h) for e in np.eye(5)])
autovalores = np.sort(np.linalg.eigvals(DM).real)[::-1]
print("autovalores de DM:", np.round(autovalores, 4))
print(f"tasa medida en los iterados: {tasa:.4f}")

The largest eigenvalue matches the measured rate, and the others are smaller: after a few iterations error aligns with the dominant eigenvector, the least well-determined parameter direction. The library you normally use, sklearn.mixture.GaussianMixture, implements EM with a stopping criterion on the increase in mean lower bound per observation (tol=1e-3 by default). With overlapping components, this criterion stops far from the parameter optimum, as you have just seen.

Bridge: variational inference and variational autoencoders

EM’s E-step requires calculating the posterior p(z∣x,θ)p(z \given x, \theta). In a mixture this is a sum of KK terms per observation; in a model with many coupled latent variables (a topic model, a deep network) it is intractable. The decomposition says what to do: restrict qq to a tractable family Q\mathcal{Q} and maximize L(q,θ)\mathcal{L}(q, \theta) over q∈Qq \in \mathcal{Q}. Now the E-step no longer closes the KL gap, the bound is not tangent, and the quantity increasing monotonically is L\mathcal{L}, not ℓ\ell. This is variational EM, and its inference part is the variational inference of module 14.

The variational autoencoder goes further: instead of optimizing one qiq_i per observation, an encoder network qϕ(z∣x)q_\phi(z \given x) produces the posterior approximation for any xx (amortized inference), and θ\theta and ϕ\phi are optimized jointly by stochastic gradient on the same L\mathcal{L}, the ELBO. The identity log⁡p(x∣θ)=L(q,θ)+KL⁡(q ∥ p(z∣x,θ))\log p(x \given \theta) = \mathcal{L}(q, \theta) + \KL(q \,\|\, p(z \given x, \theta)) you proved at the start is exactly the one used there.

Common mistakes

Exercises

ProofDecomposition and monotonicity
Prove: For any distribution qq over zz supported within the posterior's support, ℓ(θ)=L(q,θ)+KL(q ∥ p(z∣x,θ))\ell(\theta) = \mathcal{L}(q, \theta) + \mathrm{KL}(q \,\|\, p(z \mid x, \theta)); consequently EM does not decrease log-likelihood.
0
Let L(q,θ)=Eq[log⁡p(x,Z∣θ)−log⁡q(Z)]\mathcal{L}(q, \theta) = \mathbb{E}_q[\log p(x, Z \mid \theta) - \log q(Z)] and p(x∣θ)>0p(x \mid \theta) > 0.

Step 1 of 4. Which identity starts the proof for each zz with q(z)>0q(z) > 0?

ProofThe M-step for a Bernoulli mixture
Prove: In a mixture p(x∣θ)=∑k=1Kπk∏j=1dμkjxj(1−μkj)1−xjp(\mathbf{x} \mid \theta) = \sum_{k=1}^K \pi_k \prod_{j=1}^d \mu_{kj}^{x_j}(1 - \mu_{kj})^{1 - x_j} with x∈{0,1}d\mathbf{x} \in \{0, 1\}^d, the M-step is πk=Nk/n\pi_k = N_k/n and μkj=∑irikxij/Nk\mu_{kj} = \sum_i r_{ik} x_{ij} / N_k, with Nk=∑irikN_k = \sum_i r_{ik}.
0
You have the E-step responsibilities rik=p(zi=k∣xi,θold)r_{ik} = p(z_i = k \mid \mathbf{x}_i, \theta_{\text{old}}).

Step 1 of 4. What is Q(θ∣θold)Q(\theta \given \theta_{\text{old}})?

NumericIterations at rate 0.9
EM converges linearly at rate 0.90.9: error is multiplied by 0.90.9 each iteration. What is the minimum number of iterations needed to reduce it by a factor of 10610^6?
NumericFilling in the mean
You want to estimate mean μ\mu of a normal with known variance using n=100n = 100 observations, 30 missing (MCAR). EM imputes each missing value with the current mean: μk+1=(S+30 μk)/100\mu_{k+1} = (S + 30\,\mu_k)/100, with SS the sum of the 70 observed. What is the minimum number of iterations to reduce initial error by a factor of 10610^6?
QuizWhere does EM converge?
Which statements about EM convergence are generally correct (with continuous ℓ\ell, compact level sets and interior iterates)?

More than one answer may be correct.

NumericHow much remains?
EM for a scalar parameter has linear rate λ=0.95\lambda = 0.95 near the optimum, and the last step was ∣θk+1−θk∣=10−6\abs{\theta_{k+1} - \theta_k} = 10^{-6}. Estimate remaining error ∣θk+1−θ⋆∣\abs{\theta_{k+1} - \theta^\star}.
QuizWhich missingness mechanism?
A clinical study measures blood pressure at baseline (always) and six months (sometimes missing). When can you apply EM to the normal model of both measurements, ignoring the mechanism?

More than one answer may be correct.

QuizWhat hard EM maximizes
In hard EM the E-step assigns each observation to its most likely component. Which statements are correct?

More than one answer may be correct.

CodeEM for a normal with missing values
Implement em_normal_faltantes(X, max_iter=500, tol=1e-10), accepting a matrix X of shape (n, d) with np.nan for missing entries (arbitrary patterns; some rows may have no observed entries) and returning (mu, Sigma), the maximum likelihood estimates of μ\boldsymbol\mu and Σ\boldsymbol\Sigma (divisor nn) under MAR. Initialize using column means and variances (ignoring NaNs) and zero covariances, and stop when the largest absolute change in mu and Sigma is less than tol. Do not forget the conditional covariance term in the M-step.
import numpy as np

def em_normal_faltantes(X, max_iter=500, tol=1e-10):
  X = np.asarray(X, dtype=float)
  n, d = X.shape
  # tu código: arranque, y repetir paso E (media y covarianza condicionales de cada fila) y paso M
  mu = np.nanmean(X, axis=0)
  Sigma = np.diag(np.nanvar(X, axis=0))
  return mu, Sigma
Shift+Enter to run

Summary

Key idea
For any qq, log⁡p(x∣θ)=L(q,θ)+KL⁡(q ∥ p(z∣x,θ))\log p(x \given \theta) = \mathcal{L}(q, \theta) + \KL(q \,\|\, p(z \given x, \theta)). EM alternates closing KL (E-step: qq is the posterior) and raising the bound (M-step); that is why likelihood never decreases and why it is slower when more information is missing.
  • Incomplete likelihood has the logarithm outside the sum over latent variables; complete likelihood has it inside. The M-step maximizes expected complete likelihood Q(θ∣θk)Q(\theta \given \theta_k), which in the exponential family is the MLE with sufficient statistics replaced by posterior expectations.
  • Monotonicity: ℓ(θk+1)−ℓ(θk)=[Q(θk+1∣θk)−Q(θk∣θk)]+KL⁡≥0\ell(\theta_{k+1}) - \ell(\theta_k) = [Q(\theta_{k+1} \given \theta_k) - Q(\theta_k \given \theta_k)] + \KL \ge 0, also for generalized EM and ECM. If ℓ\ell decreases, there is an error.
  • Wu (1983): under regularity, limit points are stationary. They may be local maxima or saddle points (the bivariate normal with ρ0=0\rho_0 = 0); restart from several points.
  • Speed: linear convergence with rate equal to the largest eigenvalue of Ic−1Im=I−Ic−1Iobs\mat{I}_c^{-1}\mat{I}_m = \mat{I} - \mat{I}_c^{-1}\mat{I}_{\text{obs}}, the fraction of missing information. Remaining error at stopping is about λ/(1−λ)\lambda/(1 - \lambda) times the last step.
  • EM is coordinate ascent on F(q,θ)F(q, \theta) (Neal and Hinton) and an MM algorithm. This yields partial steps and incremental and online EM; hard, stochastic and Monte Carlo EM change the E-step.
  • With missing data, EM is valid under MCAR and MAR (ignorability), needs conditional covariance as well as mean, and is biased under MNAR.
  • Restricting qq to a tractable family gives variational inference and the VAE ELBO from the same bound.