๐Ÿงฎ Brain Teaser

The EM Algorithm That Overshoots: Why Hard Assignment Fails

Consider a simple Gaussian mixture model with two components:

p(x)=ฯ€โ€‰N(x;ฮผ1,ฯƒ2)+(1โˆ’ฯ€)โ€‰N(x;ฮผ2,ฯƒ2)p(x) = \pi \, \mathcal{N}(x;\mu_1,\sigma^2) + (1-\pi)\,\mathcal{N}(x;\mu_2,\sigma^2)

The EM algorithm iterates soft E-steps (computing posterior responsibilities) and M-steps (updating parameters). Suppose instead you replace the E-step with a hard assignment: each data point is assigned to whichever component has higher posterior probability.

The question: Hard-assignment EM (i.e., K-means style) maximizes the same log-likelihood as soft EM โ€” true or false? If false, what objective does hard assignment actually optimize, and why does it tend to produce different (and generally worse) solutions?

Give a precise characterization of the two objectives and explain the conceptual gap between them.

EM algorithmmixture modelsK-meansELBOKL divergencelatent variables

Answer: The EM Algorithm That Overshoots: Why Hard Assignment Fails

Key Idea / Intuition

Soft EM genuinely maximizes the observed-data log-likelihood by carefully averaging over all possible hidden-variable assignments, weighted by their posterior probability. Hard assignment instead maximizes a lower bound called the complete-data log-likelihood with the most probable assignment โ€” effectively it optimizes a different, cruder objective that ignores the uncertainty in cluster membership. Because it commits to one discrete assignment and never hedges, it is equivalent to K-means (when variances are equal and isotropic), which minimizes within-cluster sum of squares, not the true log-likelihood.


Formal Proof / Solution

Setup

Let x={x1,โ€ฆ,xn}\mathbf{x} = \{x_1,\ldots,x_n\} be observed data, and z={z1,โ€ฆ,zn}\mathbf{z} = \{z_1,\ldots,z_n\} latent component indicators (ziโˆˆ{1,2}z_i \in \{1,2\}). The observed log-likelihood is:

โ„“(ฮธ)=โˆ‘i=1nlogโกโˆ‘k=12ฯ€kโ€‰N(xi;ฮผk,ฯƒ2)\ell(\theta) = \sum_{i=1}^n \log \sum_{k=1}^2 \pi_k \, \mathcal{N}(x_i; \mu_k, \sigma^2)


What Soft EM Maximizes

The EM algorithm introduces a variational distribution q(zi)q(z_i) over latent variables and maximizes the Evidence Lower Bound (ELBO):

L(q,ฮธ)=โˆ‘iโˆ‘kq(zi=k)logโกฯ€kโ€‰N(xi;ฮผk,ฯƒ2)q(zi=k)\mathcal{L}(q,\theta) = \sum_i \sum_k q(z_i=k)\log\frac{\pi_k\,\mathcal{N}(x_i;\mu_k,\sigma^2)}{q(z_i=k)}

At the E-step, qq is set to the exact posterior:

qโ‹†(zi=k)=ฮณik=ฯ€kโ€‰N(xi;ฮผk,ฯƒ2)โˆ‘jฯ€jโ€‰N(xi;ฮผj,ฯƒ2)q^\star(z_i=k) = \gamma_{ik} = \frac{\pi_k\,\mathcal{N}(x_i;\mu_k,\sigma^2)}{\sum_{j}\pi_j\,\mathcal{N}(x_i;\mu_j,\sigma^2)}

This choice makes the ELBO tight: L(qโ‹†,ฮธ)=โ„“(ฮธ)\mathcal{L}(q^\star,\theta) = \ell(\theta). So the M-step actually increases the true log-likelihood.


What Hard Assignment Maximizes

In hard assignment, we replace the soft responsibilities ฮณik\gamma_{ik} with:

z^i=argโกmaxโกkฮณik,qhard(zi=k)=1[k=z^i]\hat{z}_i = \arg\max_k \gamma_{ik}, \qquad q^{\text{hard}}(z_i=k) = \mathbf{1}[k=\hat{z}_i]

Now the ELBO becomes:

L(qhard,ฮธ)=โˆ‘ilogโกฯ€z^i+โˆ‘ilogโกN(xi;ฮผz^i,ฯƒ2)\mathcal{L}(q^{\text{hard}},\theta) = \sum_i \log \pi_{\hat{z}_i} + \sum_i \log \mathcal{N}(x_i;\mu_{\hat{z}_i},\sigma^2)

This is exactly the complete-data log-likelihood under the hard assignment โ€” not the observed log-likelihood. The gap is:

โ„“(ฮธ)โˆ’L(qhard,ฮธ)=โˆ‘iKL(qihardโ€‰โˆฅโ€‰p(ziโˆฃxi,ฮธ))โŸโ‰ฅโ€‰0\ell(\theta) - \mathcal{L}(q^{\text{hard}},\theta) = \underbrace{\sum_i \text{KL}(q^{\text{hard}}_{i} \,\|\, p(z_i|x_i,\theta))}_{\geq\, 0}

Hard assignment inflates this KL term because it concentrates all mass on one component, ignoring uncertainty.


The K-means Connection

When ฯƒ2\sigma^2 is fixed and equal, maximizing the complete-data log-likelihood reduces to:

maxโกฮผ1,ฮผ2,z^โˆ‘ilogโกN(xi;ฮผz^i,ฯƒ2)=โˆ’12ฯƒ2โˆ‘i(xiโˆ’ฮผz^i)2+const\max_{\mu_1,\mu_2,\hat{z}} \sum_i \log \mathcal{N}(x_i;\mu_{\hat{z}_i},\sigma^2) = -\frac{1}{2\sigma^2}\sum_i (x_i - \mu_{\hat{z}_i})^2 + \text{const}

This is precisely minimizing within-cluster sum of squares โ€” the K-means objective. So hard-assignment EM is K-means.


Why Hard Assignment Is Generally Worse

| Property | Soft EM | Hard EM (K-means) | |---|---|---| | Objective | True log-likelihood โ„“(ฮธ)\ell(\theta) | Complete-data log-likelihood | | KL gap at E-step | Zero (tight bound) | >0> 0 (inflated by assignment uncertainty) | | Handles overlap | Yes, via soft responsibilities | No, forces crisp boundaries | | Sensitive to initialization | Less | More |

Summary: Hard assignment optimizes a lower bound of the log-likelihood, not the log-likelihood itself. The tightness gap is the KL divergence between the hard distribution and the true posterior, which is nonzero whenever clusters overlap. Soft EM closes this gap exactly at each E-step, guaranteeing monotone increase of the true log-likelihood.

Source: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, Chapter 8 & 14

Type: ML/StatsSource: The Elements of Statistical Learning, Hastie, Tibshirani, Friedman, Chapter 8 & 14Edit on GitHub โ†—