Tutorials › Measure Theory › Conditional Expectations in Mixture Models

Expectation, Conditional Expectation and Independence · Tutorial 765 of 798

Conditional Expectations in Mixture Models

Learn to update mixture weights from observed data, combine component-specific conditional means, and verify the result against the unconditional expectation.

Advanced 12 min read

What You'll Learn

  • Define a mixture model using a latent component label and component-specific laws.
  • Calculate posterior component probabilities for finite observations.
  • Derive conditional means by averaging component means with posterior weights.
  • Apply the density form of Bayes’ rule to continuous mixture models.
  • Verify conditional-mean calculations using the law of total expectation.
  • Identify why prior weights alone generally do not give a conditional mean.

Mixture Models: Update First, Then Average

A mixture model describes a population assembled from several component distributions. A latent label \(Z\) records which component generated the observation, but \(Z\) may not be observed. Once an observation \(X=x\) is available, the chance of each component generally changes: components that make \(x\) more likely receive greater posterior weight. A conditional mean in a mixture must use these updated weights, not simply the original proportions.

Work on a probability space \((\Omega,\mathcal{F},\mathbb{P})\). Let \(Z\) take values in \(\{1,\ldots,k\}\), with \(\mathbb{P}(Z=i)=\pi_i\), where \(\pi_i\ge0\) and \(\sum_{i=1}^k\pi_i=1\). The variable \(Z\) is the component label. Suppose \(X\) is an observation and \(Y\) is a real-valued integrable response. Conditional expectations are equalities \(\mathbb{P}\)-almost surely; formulas indexed by a continuous observation \(x\) specify versions and are meaningful up to sets of zero marginal probability.

Definition: A finite mixture with component laws \(P_i\) is a probability law that assigns an event \(A\) probability \(\sum_{i=1}^k\pi_iP_i(A)\). Equivalently, one first draws \(Z\) with probabilities \(\pi_i\), then draws from component \(P_i\) given \(Z=i\). The prior weights are \(\pi_i\); the posterior weights after observing \(X=x\) are \(\mathbb{P}(Z=i\mid X=x)\), when this conditional probability is defined.

Finite Observations and Posterior Means

When \(X\) takes values in a finite or countable set, write \(q_i(x)=\mathbb{P}(X=x\mid Z=i)\). For an observation \(x\) with \(\mathbb{P}(X=x)>0\), the mixture formula gives \(\mathbb{P}(X=x)=\sum_j\pi_jq_j(x)\). Bayes’ rule therefore gives the posterior weight \(\mathbb{P}(Z=i\mid X=x)=\pi_iq_i(x)/\sum_j\pi_jq_j(x)\). If \(m_i(x)=\mathbb{E}[Y\mid X=x,Z=i]\) is defined for the component and observation in question, then the conditional mean given \(X=x\) is the posterior-weighted average of these component means.

Proposition: Suppose \(Z\) has finitely many values, \(Y\) is real-valued and integrable, and \(x\) satisfies \(\mathbb{P}(X=x)>0\). For every \(i\) with \(\mathbb{P}(X=x,Z=i)>0\), let \(m_i(x)=\mathbb{E}[Y\mid X=x,Z=i]\). Then \(\mathbb{E}[Y\mid X=x]=\sum_i\mathbb{P}(Z=i\mid X=x)m_i(x)\). Terms with zero posterior weight contribute zero.

Proof. The event \(\{X=x\}\) is the disjoint union of the events \(\{X=x,Z=i\}\). By the definition of conditional expectation on an event of positive probability, \(\mathbb{E}[Y\mid X=x]=\mathbb{E}[Y\chi_{\{X=x\}}]/\mathbb{P}(X=x)\). Finite additivity of the integral over the disjoint union makes the numerator \(\sum_i\mathbb{E}[Y\chi_{\{X=x,Z=i\}}]\). For each term with positive event probability, this equals \(m_i(x)\mathbb{P}(X=x,Z=i)\). Divide by \(\mathbb{P}(X=x)\), and use \(\mathbb{P}(X=x,Z=i)/\mathbb{P}(X=x)=\mathbb{P}(Z=i\mid X=x)\). A zero-probability event contributes zero to the numerator. This proves the formula. \(\square\)

Worked Example: A Binary Observation in a Two-Component Model

Let \(\mathbb{P}(Z=1)=2/5\), \(\mathbb{P}(Z=2)=3/5\), and let \(X\) be binary with \(\mathbb{P}(X=1\mid Z=1)=4/5\) and \(\mathbb{P}(X=1\mid Z=2)=1/4\). Suppose \(Y\) is integrable, with \(\mathbb{E}[Y\mid X,Z=1]=2\) and \(\mathbb{E}[Y\mid X,Z=2]=6\). Find the conditional means given each value of \(X\), then check their average.

For \(X=1\), the joint probabilities are \(\mathbb{P}(X=1,Z=1)=(2/5)(4/5)=8/25=32/100\) and \(\mathbb{P}(X=1,Z=2)=(3/5)(1/4)=3/20=15/100\). Thus \(\mathbb{P}(X=1)=47/100\), and the posterior weights are \(32/47\) and \(15/47\). The conditional mean is \(\mathbb{E}[Y\mid X=1]=(32/47)2+(15/47)6=(64+90)/47=154/47\).

For \(X=0\), the component likelihoods are \(1/5\) and \(3/4\). The joint probabilities are \((2/5)(1/5)=2/25=8/100\) and \((3/5)(3/4)=9/20=45/100\). Hence \(\mathbb{P}(X=0)=53/100\), with posterior weights \(8/53\) and \(45/53\). Therefore \(\mathbb{E}[Y\mid X=0]=(8/53)2+(45/53)6=(16+270)/53=286/53\).

Check: the unconditional mean computed by conditioning on \(Z\) is \((2/5)2+(3/5)6=4/5+18/5=22/5\). Averaging the two conditional means over \(X\) gives \((47/100)(154/47)+(53/100)(286/53)=154/100+286/100=440/100=22/5\), as required.

Continuous Observations and Density Weights

For continuous observations, the probability of a single value \(X=x\) is often zero, so conditional expectation on the event \(\{X=x\}\) is not defined by dividing event probabilities. Instead, express component distributions by densities. Let \(\lambda\) be a sigma-finite measure on the observation space, and suppose the conditional law of \(X\) given \(Z=i\) has a nonnegative measurable density \(f_i\) with respect to \(\lambda\), with \(\int f_i\,d\lambda=1\). The marginal density is \(f(x)=\sum_i\pi_i f_i(x)\). Where \(f(x)>0\), the posterior component weights are \(\pi_i f_i(x)/f(x)\).

Theorem: In the finite-component model above, suppose \(Y\) is real-valued and integrable and, for each \(i\) with \(\pi_i>0\), \(m_i(X)\) is a version of \(\mathbb{E}[Y\mid \sigma(X,Z)]\) on \(\{Z=i\}\). Assume these component conditional means can be represented by measurable functions \(m_i(x)\). Then a version of \(\mathbb{E}[Y\mid \sigma(X)]\) is \(g(x)=\dfrac{\sum_i\pi_i f_i(x)m_i(x)}{\sum_i\pi_i f_i(x)}\) where the denominator is positive. Define \(g\) arbitrarily where \(f=0\); those values do not affect the almost-sure conditional expectation.

Proof. The function \(g\) is measurable on \(\{f>0\}\), as it is a quotient of measurable functions with positive denominator there. To verify the conditional expectation, it suffices to check its defining integral identity on every event \(\{X\in A\}\), for measurable \(A\). The marginal law of \(X\) has density \(f\), so \(\mathbb{E}[g(X)\chi_{\{X\in A\}}]=\int_A g(x)f(x)\,d\lambda(x)=\int_A\sum_i\pi_i f_i(x)m_i(x)\,d\lambda(x)\). The last integral equals \(\sum_i\mathbb{E}[Y\chi_{\{X\in A,Z=i\}}]\): in component \(i\), the conditional mean given \(X\) is \(m_i(X)\), and the joint contribution of \(X\) and \(Z=i\) has density \(\pi_i f_i\). Summing over the finite set of labels gives \(\mathbb{E}[Y\chi_{\{X\in A\}}]\). The identity holds for all measurable \(A\), and \(g(X)\) is integrable because the absolute integral is bounded by \(\mathbb{E}[|Y|]\), using the same component identity with \(|m_i(X)|\le\mathbb{E}[|Y|\mid X,Z=i]\). Thus \(g(X)\) satisfies the defining integral characterization of conditional expectation. \(\square\)

Worked Example: A Mixture of Two Densities on [0,1]

Let \(\mathbb{P}(Z=1)=1/3\) and \(\mathbb{P}(Z=2)=2/3\). With respect to Lebesgue measure \(m\) on \([0,1]\), take \(f_1(x)=1\) and \(f_2(x)=2x\). Given \(X=x,Z=1\), let the conditional mean of \(Y\) be \(m_1(x)=x+1\); given \(X=x,Z=2\), let it be \(m_2(x)=3-x\). Compute the posterior weights, the conditional mean function, and the overall mean.

Both component densities integrate to one: \(\int_0^1 1\,dx=1\) and \(\int_0^1 2x\,dx=[x^2]_0^1=1\). The marginal density is \(f(x)=(1/3)1+(2/3)2x=(1+4x)/3\). It is positive on all of \([0,1]\). The posterior weights are \(\mathbb{P}(Z=1\mid X=x)=1/(1+4x)\) and \(\mathbb{P}(Z=2\mid X=x)=4x/(1+4x)\). They sum to \((1+4x)/(1+4x)=1\). The conditional mean is therefore \(\mathbb{E}[Y\mid X=x]=[(x+1)+4x(3-x)]/(1+4x)=(1+13x-4x^2)/(1+4x)\).

Compute the overall mean first by components. Under \(Z=1\), \(X\) is uniform on \([0,1]\), so \(\mathbb{E}[Y\mid Z=1]=\int_0^1(x+1)\,dx=1/2+1=3/2\). Under \(Z=2\), \(\mathbb{E}[Y\mid Z=2]=\int_0^1(3-x)2x\,dx=\int_0^1(6x-2x^2)\,dx=3-2/3=7/3\). Hence \(\mathbb{E}[Y]=(1/3)(3/2)+(2/3)(7/3)=1/2+14/9=37/18\).

Check: integrating the conditional mean against the marginal density gives \(\int_0^1 [(1+13x-4x^2)/3]\,dx=(1+13/2-4/3)/3=(37/6)/3=37/18\). The two computations agree.

Worked Example: Posterior Weights in a Gaussian Mixture

Let \(\mathbb{P}(Z=0)=1/3\), \(\mathbb{P}(Z=1)=2/3\), and suppose \(X\mid Z=0\) has density \(\phi(x)\), while \(X\mid Z=1\) has density \(\phi(x-2)\), where \(\phi(t)=(2\pi)^{-1/2}e^{-t^2/2}\). Set \(Y=Z\). Find the posterior probability of component 1 and the conditional mean of \(Y\) at \(x=1\) and \(x=0\).

For a point where the marginal density is positive, Bayes’ density formula gives \(\mathbb{P}(Z=1\mid X=x)=\frac{(2/3)\phi(x-2)}{(1/3)\phi(x)+(2/3)\phi(x-2)}\). At \(x=1\), both density arguments have square \(1\): \((1-2)^2=1\) and \(1^2=1\). Thus \(\phi(1-2)=\phi(1)\), and the posterior probability is \((2/3)/(1/3+2/3)=2/3\). Since \(Y=Z\), \(\mathbb{E}[Y\mid X=1]=2/3\).

At \(x=0\), \(\phi(-2)/\phi(0)=e^{-2}\), since the common factor \((2\pi)^{-1/2}\) cancels and \(e^{-(-2)^2/2}/e^0=e^{-2}\). The posterior probability is consequently \(\frac{(2/3)e^{-2}}{1/3+(2/3)e^{-2}}=\frac{2}{e^2+2}\), which is also \(\mathbb{E}[Y\mid X=0]\). Check: integrating the posterior probability against the marginal density recovers the prior probability: its numerator is \((2/3)\phi(x-2)\), whose integral over \(\mathbb{R}\) is \(2/3\), because the shifted normal density integrates to one.

A Common Pitfall: Using Prior Weights After Observing Data

In the binary example, averaging component means with the prior weights gives \((2/5)2+(3/5)6=22/5\). That is the unconditional mean of \(Y\), not \(\mathbb{E}[Y\mid X=1]\). After observing \(X=1\), the likelihoods \(4/5\) and \(1/4\) change the weights to \(32/47\) and \(15/47\). The correct conditional mean is \((32/47)2+(15/47)6=154/47\), not \(22/5\). The distinction is the same whether component distributions are discrete or continuous: condition on the observation by updating the weights, then average the component-specific conditional means.

These calculations are useful whenever an unobserved group, class, or regime generates data—for example, when combining populations with different response patterns. They also provide an internal consistency check: averaging \(\mathbb{E}[Y\mid X]\) over the marginal law of \(X\) must recover \(\mathbb{E}[Y]\), by the tower property of conditional expectation.

Check Your Understanding

For each question, identify whether the required weights are prior or posterior weights and check that the relevant probabilities sum to one.

  1. In a two-component finite mixture, derive \(\mathbb{P}(Z=i\mid X=x)\) from the joint probabilities \(\mathbb{P}(Z=i,X=x)\).
  2. For the binary example, calculate \(\mathbb{E}[Y\mid X=1]\) using the posterior weights and explain why the prior-weighted mean answers a different question.
  3. In a density mixture, what should be done at points \(x\) where the marginal density \(f(x)\) is zero?
  4. For the mixture on \([0,1]\), evaluate the posterior weights at \(x=1/2\) and verify the conditional mean there.
  5. Explain how integrating a conditional mean against the marginal distribution checks that the overall expectation has been computed consistently.