Skip to content
BIASED

EM and Bayesian PCA

Block 1 of 8~2 min

Latent variables and mixtures

In the topic The Laplace approximation and Bayesian classification we found the mode of a posterior by Newton's method and put a Gaussian there. That worked because the log-posterior was a sum of simple terms. Now each object gets a hidden part that we never observe, and even finding the mode becomes hard.

A latent variable ziz_i is a quantity attached to the object xix_i that the model uses but the data do not contain. The classic example is a mixture of Gaussians. Each point first picks a component kk with probability πk\pi_k, then is drawn from that component:

p(zi=k)=πk,xi∣zi=k∼N(μk,σk2),∑k=1Kπk=1.p(z_i = k) = \pi_k, \qquad x_i \mid z_i = k \sim \mathcal N(\mu_k, \sigma_k^2), \qquad \sum_{k=1}^{K} \pi_k = 1.

The parameters are θ={πk,μk,σk2}k=1K\theta = \{\pi_k, \mu_k, \sigma_k^2\}_{k=1}^K. We observe only X=(x1,…,xn)X = (x_1, \dots, x_n), so the likelihood sums the latent variable out:

ℓ(θ)=log⁡p(X∣θ)=∑i=1nlog⁡∑k=1Kπk N(xi∣μk,σk2).\ell(\theta) = \log p(X \mid \theta) = \sum_{i=1}^{n} \log \sum_{k=1}^{K} \pi_k\, \mathcal N(x_i \mid \mu_k, \sigma_k^2).

The logarithm sits outside the inner sum. Setting the gradient to zero couples all components at once, and there is no closed-form solution.

Compare this with the complete-data log-likelihood, the one we would have if the labels Z=(z1,…,zn)Z = (z_1, \dots, z_n) were known:

log⁡p(X,Z∣θ)=∑i=1n[log⁡πzi+log⁡N(xi∣μzi,σzi2)].\log p(X, Z \mid \theta) = \sum_{i=1}^{n} \Big[ \log \pi_{z_i} + \log \mathcal N(x_i \mid \mu_{z_i}, \sigma_{z_i}^2) \Big].

Here the logarithm acts on single terms, and the problem splits into one small Gaussian fit per component. EM exploits exactly this: we do not know ZZ, but for given θ\theta we know its posterior, and we can average the easy complete-data log-likelihood over it.

Running example. Seven points on a line,

x=(−0.8, −0.2, 0.3, 0.9, 2.1, 2.8, 3.4),x = (-0.8,\ -0.2,\ 0.3,\ 0.9,\ 2.1,\ 2.8,\ 3.4),

and a mixture of two components with unit variances:

p(x∣θ)=π N(x∣μ1,1)+(1−π) N(x∣μ2,1),θ=(π,μ1,μ2).p(x \mid \theta) = \pi\, \mathcal N(x \mid \mu_1, 1) + (1 - \pi)\, \mathcal N(x \mid \mu_2, 1), \qquad \theta = (\pi, \mu_1, \mu_2).

Here π\pi is the weight of the first component, not 3.143.14. We start from θ(0)=(0.5, 0, 1)\theta^{(0)} = (0.5,\ 0,\ 1), where ℓ(θ(0))=−14.69\ell(\theta^{(0)}) = -14.69. Later topics of the course return to this mixture.

Answers are saved on the server and tied to this browser until you sign in.