Tutorials › Multivariate Statistics (Graduate) › Latent Allocations and Complete-Data Likelihood

Gaussian Mixtures and EM · Tutorial 631 of 975

Latent Allocations and Complete-Data Likelihood

Learn how one-hot latent allocations turn a Gaussian mixture’s joint likelihood into an explicit sum of component-specific log-likelihood contributions.

Advanced 10 min read

What You'll Learn

  • Define one-hot latent allocation indicators for a finite Gaussian mixture
  • Distinguish the complete-data likelihood from the likelihood of observed vectors alone
  • Derive the joint likelihood and log-likelihood for weights, means, and covariance matrices
  • Express the allocation contribution through component counts
  • Calculate complete-data log-likelihoods in univariate and multivariate examples
  • Identify why unobserved allocations cannot be treated as known labels

Why Introduce Latent Allocations?

A finite Gaussian mixture describes each observation as coming from one of several Gaussian components, but the component that generated an observed vector is usually unknown. Introducing an explicit variable for that membership gives a precise way to describe the joint model for the observations and their unobserved allocations. The resulting complete-data likelihood is the likelihood we would write if both were available.

This representation is more than bookkeeping. It makes clear which likelihood terms belong to the mixing weights and which belong to the component-specific Gaussian distributions. It also prevents a common conceptual error: treating an unknown allocation as though it were a known class label. Here the goal is to define and derive the complete-data likelihood, not to estimate the parameters or infer allocations.

One-Hot Indicators for Component Membership

Suppose \(X_1,\ldots,X_n\) are independent observations in \(\mathbb{R}^p\) from a \(K\)-component Gaussian mixture. Write the parameter as \(\theta=(\pi_1,\ldots,\pi_K,\mu_1,\ldots,\mu_K,\Sigma_1,\ldots,\Sigma_K)\). The mixing weights satisfy \(\pi_k>0\) and \(\sum_{k=1}^K\pi_k=1\); each mean \(\mu_k\) is in \(\mathbb{R}^p\), and each covariance matrix \(\Sigma_k\) is symmetric positive definite.

For observation \(i\), let \(Z_i=(Z_{i1},\ldots,Z_{iK})\) record its component. The entries are indicators: \(Z_{ik}=1\) means observation \(i\) belongs to component \(k\), and \(Z_{ik}=0\) otherwise. Exactly one entry equals 1.

Definition: A one-hot latent allocation vector \(Z_i\) takes values in \(\{0,1\}^K\) and satisfies \(\sum_{k=1}^K Z_{ik}=1\). Under the mixture model, \(P(Z_{ik}=1)=\pi_k\), and, conditional on \(Z_{ik}=1\), \(X_i\) has distribution \(N(\mu_k,\Sigma_k)\).

The observed vectors are \(x_1,\ldots,x_n\). If their allocation vectors \(z_1,\ldots,z_n\) were also given, the pair \((x_i,z_i)\) would be the complete observation for case \(i\). In the usual mixture problem only \(x_i\) is observed, so the allocations are latent. The complete-data likelihood is the joint density or mass-density of both parts, evaluated at a particular allocation configuration.

Deriving the Complete-Data Likelihood

Let \(\phi_p(x;\mu,\Sigma)\) denote the \(p\)-variate Gaussian density,

$$ \phi_p(x;\mu,\Sigma) =(2\pi)^{-p/2}|\Sigma|^{-1/2} \exp\!\left\{-\frac12(x-\mu)^\mathsf{T}\Sigma^{-1}(x-\mu)\right\}. $$

For a single case, the probability of its allocation and the conditional density of its vector multiply. Because \(z_i\) is one-hot, this joint contribution can be written with indicator exponents: the active component contributes its weight and Gaussian density, while inactive components contribute a factor of 1.

Theorem: Under independent sampling from the specified \(K\)-component Gaussian mixture, the complete-data likelihood at \((x_1,\ldots,x_n,z_1,\ldots,z_n)\) is
$$ L_c(\theta;x,z) =\prod_{i=1}^n\prod_{k=1}^K \left\{\pi_k\phi_p(x_i;\mu_k,\Sigma_k)\right\}^{z_{ik}}. $$

For strictly positive weights and positive-definite covariance matrices, its log-likelihood is

$$ \ell_c(\theta;x,z) =\sum_{i=1}^n\sum_{k=1}^K z_{ik} \left[ \log\pi_k-\frac p2\log(2\pi)-\frac12\log|\Sigma_k| -\frac12(x_i-\mu_k)^\mathsf{T}\Sigma_k^{-1}(x_i-\mu_k) \right]. $$

Proof. For a single observation, the allocation probability is \(P(Z_i=z_i)=\prod_{k=1}^K\pi_k^{z_{ik}}\), since exactly one indicator is 1. Conditional on that allocation, the density of \(X_i=x_i\) is \(\prod_{k=1}^K\phi_p(x_i;\mu_k,\Sigma_k)^{z_{ik}}\), for the same reason. Multiplying these expressions gives the joint contribution for case \(i\). Independence across cases gives the product over \(i\), which proves the likelihood formula. Taking its logarithm turns the product into a sum. Substitution of the Gaussian log-density gives the displayed log-likelihood. \(\square\)

The expression can be regrouped using the component counts \(n_k=\sum_{i=1}^n z_{ik}\). Since each case has exactly one allocation, \(\sum_k n_k=n\). Collecting terms gives

$$ \ell_c =\sum_{k=1}^K n_k\log\pi_k -\frac{np}{2}\log(2\pi) -\frac12\sum_{k=1}^K n_k\log|\Sigma_k| -\frac12\sum_{k=1}^K\sum_{i=1}^n z_{ik} (x_i-\mu_k)^\mathsf{T}\Sigma_k^{-1}(x_i-\mu_k). $$

Thus the allocation pattern enters through which observations contribute to each component’s quadratic terms, as well as through the counts multiplying the log weights and log determinants. This is an exact rewriting, not a parameter estimate or an assumption that the allocations are observed in practice.

Worked Example: A Univariate Complete-Data Log-Likelihood

Take \(K=2\), \(p=1\), and three observations \(x_1=0\), \(x_2=2\), and \(x_3=3\). Suppose the specified allocation assigns \(x_1,x_2\) to component 1 and \(x_3\) to component 2. Let \(\pi_1=0.4\), \(\pi_2=0.6\), \(\mu_1=1\), \(\sigma_1^2=2\), \(\mu_2=3\), and \(\sigma_2^2=1\).

The component counts are \(n_1=2\) and \(n_2=1\). The squared residuals for component 1 sum to \((0-1)^2+(2-1)^2=2\), and the squared residual for component 2 is \((3-3)^2=0\). Dividing by the respective variances, the total quadratic contribution is \(2/2+0/1=1\).

The log-weight term is \(2\log(0.4)+\log(0.6)\approx-2.343407\). The Gaussian constant is \(-\frac32\log(2\pi)\approx-2.756816\). The log-variance term is \(-\frac12[2\log(2)+\log(1)]=-\log(2)\approx-0.693147\), and the quadratic term is \(-\frac12(1)=-0.5\). Therefore,

$$ \ell_c =2\log(0.4)+\log(0.6)-\frac32\log(2\pi)-\log(2)-\frac12 \approx -6.293370. $$

Each contribution follows from the assigned component: the observation \(x_3\) contributes to component 2’s Gaussian terms, while the first two contribute to component 1’s.

Multivariate Terms and Their Interpretation

In dimension \(p>1\), the structure is unchanged, but each component contributes a log-determinant and a Mahalanobis quadratic form. The determinant measures covariance volume, while the quadratic form measures squared distance from the component mean in the geometry defined by that covariance matrix. Positive definiteness ensures that the determinant is positive and the inverse exists, so these terms are well-defined.

Worked Example: Two Bivariate Component Contributions

Let \(p=2\), \(K=2\), and \(n=2\), with \(x_1=(1,0)^\mathsf{T}\) assigned to component 1 and \(x_2=(0,2)^\mathsf{T}\) assigned to component 2. Take \(\pi_1=0.25\), \(\pi_2=0.75\), \(\mu_1=(0,0)^\mathsf{T}\), \(\Sigma_1=\operatorname{diag}(1,4)\), \(\mu_2=(0,1)^\mathsf{T}\), and \(\Sigma_2=\operatorname{diag}(4,1)\).

Both determinants equal 4. For the first observation, \(\Sigma_1^{-1}=\operatorname{diag}(1,1/4)\), so its quadratic form is \((1,0)\operatorname{diag}(1,1/4)(1,0)^\mathsf{T}=1\). For the second, \(x_2-\mu_2=(0,1)^\mathsf{T}\) and \(\Sigma_2^{-1}=\operatorname{diag}(1/4,1)\), so its quadratic form is also 1.

The log weights sum to \(\log(0.25)+\log(0.75)\approx-1.673976\). The Gaussian constant is \(-\frac{np}{2}\log(2\pi)=-2\log(2\pi)\approx-3.675754\). The determinant contribution is \(-\frac12(\log4+\log4)=-\log4\approx-1.386294\). The quadratic contribution is \(-\frac12(1+1)=-1\). Thus,

$$ \ell_c =\log(0.25)+\log(0.75)-2\log(2\pi)-\log(4)-1 \approx -7.736025. $$

The example shows why the covariance contribution is not just a function of the residual lengths: it depends on the covariance matrix used to measure each residual.

How the Complete Likelihood Relates to Observed Data

For fixed observed vectors \(x_1,\ldots,x_n\), there are \(K^n\) possible allocation configurations. The observed-data likelihood is obtained by summing the joint likelihood over all of them. This follows directly from the rule that the probability density of an observed event is the sum of the joint probabilities or densities over its mutually exclusive latent states.

Result: Summing the complete-data likelihood over every one-hot allocation configuration recovers the observed-data likelihood:
$$ \sum_{z_1,\ldots,z_n}L_c(\theta;x,z) =\prod_{i=1}^n\left\{\sum_{k=1}^K\pi_k\phi_p(x_i;\mu_k,\Sigma_k)\right\}. $$

Proof. For each \(i\), the sum over its \(K\) possible one-hot vectors selects one of the \(K\) component contributions. Therefore,

$$ \sum_{z_1,\ldots,z_n}\prod_{i=1}^n\prod_{k=1}^K \{\pi_k\phi_p(x_i;\mu_k,\Sigma_k)\}^{z_{ik}} =\prod_{i=1}^n\sum_{k=1}^K\pi_k\phi_p(x_i;\mu_k,\Sigma_k), $$

because the allocation choices for different observations range independently over their \(K\) possibilities. The right side is exactly the density of the observed vectors under independent sampling from the mixture. \(\square\)

Worked Example: Two Different Allocations for the Same Data

Let \(K=2\), \(p=1\), and observe \(x_1=0,x_2=2\). Set \(\pi_1=0.4\), \(\pi_2=0.6\), and let both component variances be 1, with means \(\mu_1=0\) and \(\mu_2=2\). Consider two possible allocation configurations.

Under allocation A, \(x_1\) is assigned to component 1 and \(x_2\) to component 2. The complete-data likelihood is \(0.4\phi_1(0;0,1)\,0.6\phi_1(2;2,1)=0.24/(2\pi)\), since both residuals are zero.

Under allocation B, both observations are assigned to component 1. The likelihood is \(0.4^2\phi_1(0;0,1)\phi_1(2;0,1)=0.16e^{-2}/(2\pi)\), since the second observation has squared residual 4 and contributes the Gaussian factor \(e^{-4/2}=e^{-2}\).

The ratio of the two complete-data likelihoods is \(0.24/(0.16e^{-2})=1.5e^2\approx11.084\). The observed vectors and parameters were held fixed; only the assumed latent allocation changed. This calculation illustrates why a complete-data likelihood is indexed by an allocation configuration, whereas the observed-data likelihood sums over configurations.

Common Pitfall: Treating Unknown Membership as a Known Label

A frequent mistake is to insert a fractional allocation, such as \(z_{i1}=0.7\) and \(z_{i2}=0.3\), into the complete-data likelihood and call it a possible latent state. That is not a valid one-hot allocation: the definition requires each indicator to be either 0 or 1, with exactly one equal to 1. Fractional values may arise in other calculations, but they are not realizations of \(Z_i\) and do not define a complete-data likelihood at an allocation.

A related error is to use only the Gaussian density for the assigned component and omit its mixing weight. The joint contribution for an observation assigned to component \(k\) is \(\pi_k\phi_p(x_i;\mu_k,\Sigma_k)\), not merely \(\phi_p(x_i;\mu_k,\Sigma_k)\). The weight is part of the allocation probability and therefore belongs in the complete-data likelihood.

The distinction matters whenever a derivation uses latent membership: the complete-data expression is a joint model for vectors and allocations; the observed-data likelihood is obtained by summing out allocations. Keeping those two objects separate makes the role of every factor explicit.

Check Your Understanding

Use the definitions and formulas above to answer the following.

  1. For \(K=4\), list the possible one-hot allocation vectors for a single observation and state how many entries equal 1 in each.
  2. Why does the complete-data likelihood include \(\pi_k\) for an observation assigned to component \(k\)?
  3. In the log-likelihood, explain why the determinant term for component \(k\) is multiplied by its allocation count \(n_k\).
  4. What conditions on \(\Sigma_k\) make the multivariate Gaussian log-likelihood terms well-defined?
  5. In words, distinguish the complete-data likelihood from the observed-data likelihood.
Clinical Biostats