Tutorials › Statistical Theory I - Probability and Distribution Theory › Conditional Expectation Given a Discrete Variable

Conditional Expectation · Tutorial 324 of 994

Conditional Expectation Given a Discrete Variable

Learn to compute a conditional mean at each positive-probability value of a discrete conditioning variable and express those values as a random variable.

Intermediate 9 min read

What You'll Learn

  • Define the conditional distribution of one discrete variable at a positive-probability value of another.
  • Calculate the conditional expectation of a function using conditional masses.
  • Represent the conditional mean as a function of the conditioning variable.
  • Recognize why values at zero-probability points do not affect the resulting random variable.
  • Apply the definition to finite-support and infinite-support examples.

From Conditioning on an Event to Conditioning on a Variable

A discrete variable can take several possible values, and each value identifies an event on which we can calculate a conditional mean. Conditioning on the variable means assembling those event-specific means into one random variable: its value depends on which value of the conditioning variable is observed. The key is to distinguish the number obtained at a particular value from the random variable that records the appropriate number across all outcomes.

Let \(X\) and \(Y\) be discrete random variables, and let \(g\) be a real-valued function. We will define the conditional expectation of \(g(X)\) given \(Y\). At any value \(y\) with \(P(Y=y)>0\), this is the ordinary conditional mean of \(g(X)\) on the event \(\{Y=y\}\). Collecting those means over the possible values of \(Y\) gives a function of \(Y\).

Definition: Let \(X\) and \(Y\) be discrete random variables, and suppose \(E[|g(X)|]<\infty\). For each \(y\) such that \(P(Y=y)>0\), define the conditional mass function \(P(X=x\mid Y=y)=P(X=x,Y=y)/P(Y=y)\). The conditional expectation of \(g(X)\) at \(Y=y\) is \(E[g(X)\mid Y=y]=\sum_x g(x)P(X=x\mid Y=y)\). The conditional expectation given \(Y\), denoted \(E[g(X)\mid Y]\), is the random variable \(h(Y)\), where \(h(y)=E[g(X)\mid Y=y]\) at every positive-probability value of \(Y\). Values assigned to \(h(y)\) when \(P(Y=y)=0\) do not affect \(h(Y)\).

The Conditional-Mass Formula

The conditional distribution at \(y\) is obtained by restricting the joint distribution to outcomes with \(Y=y\), then dividing by the probability of that event. For any positive-probability value \(y\), its masses sum to one:

$$ \sum_x P(X=x\mid Y=y) =\frac{\sum_x P(X=x,Y=y)}{P(Y=y)} =\frac{P(Y=y)}{P(Y=y)} =1. $$

Consequently, the conditional mean is an ordinary expectation under this conditional probability distribution. Since \(E[|g(X)|]<\infty\), the sum defining the conditional mean is absolutely convergent at every \(y\) with positive probability. Indeed,

$$ \sum_x |g(x)|P(X=x\mid Y=y) =\frac{\sum_x |g(x)|P(X=x,Y=y)}{P(Y=y)} \leq \frac{E[|g(X)|]}{P(Y=y)} <\infty. $$

The denominator matters: this is a conditional average, so the joint masses for the selected value of \(Y\) must be rescaled to sum to one. Equivalently, the formula can be written directly in terms of joint probabilities:

$$ E[g(X)\mid Y=y] =\frac{\sum_x g(x)P(X=x,Y=y)}{P(Y=y)},\qquad P(Y=y)>0. $$
Theorem: Under the conditions in the definition, the function \(h\) defined by \(h(y)=E[g(X)\mid Y=y]\) for positive-probability values \(y\) gives a representation \(E[g(X)\mid Y]=h(Y)\). This random variable is integrable. If another function \(k\) also represents the same conditional expectation as \(k(Y)\), then \(k(y)=h(y)\) for every \(y\) with \(P(Y=y)>0\).

Proof. The support of a discrete random variable is countable. For each positive-probability \(y\), the conditional-mass formula defines \(h(y)\), and the preceding absolute-summability bound makes it finite. Assign any finite value to \(h(y)\) at points with \(P(Y=y)=0\). The composition \(h(Y)\) is a function of a discrete random variable, so it is measurable.

To verify integrability, sum over the positive-probability values of \(Y\). The triangle inequality and the conditional-mass formula give

$$ E[|h(Y)|] =\sum_y P(Y=y)|h(y)| \leq \sum_y P(Y=y)\sum_x |g(x)|P(X=x\mid Y=y) =\sum_{x,y}|g(x)|P(X=x,Y=y) =E[|g(X)|]<\infty. $$

This establishes that the pointwise conditional means form an integrable random variable depending only on \(Y\). For uniqueness at positive-probability values, suppose \(h(Y)=k(Y)\) with probability one. If there were a positive-probability value \(y\) with \(h(y)\ne k(y)\), then the two random variables would differ on the entire event \(\{Y=y\}\), an event of positive probability. That contradicts equality with probability one. Thus they agree at every positive-probability value. At zero-probability values, their assigned values have no effect on either random variable. \(\square\)

Worked Examples

Worked Example: A Conditional Mean with Two Possible Values of the Conditioner

Suppose \(Y\) takes values 0 and 1, with \(P(Y=0)=0.6\) and \(P(Y=1)=0.4\). Given \(Y=0\), let \(X=0\) with probability 0.75 and \(X=2\) with probability 0.25. Given \(Y=1\), let \(X=1\) and \(X=3\) each have probability 0.5. Find \(E[X^2\mid Y]\).

At \(Y=0\), the conditional mean of \(X^2\) is

$$ E[X^2\mid Y=0] =0^2(0.75)+2^2(0.25) =0+1 =1. $$

At \(Y=1\), it is

$$ E[X^2\mid Y=1] =1^2(0.5)+3^2(0.5) =0.5+4.5 =5. $$

Therefore \(h(0)=1\) and \(h(1)=5\), so the conditional expectation as a random variable is \(E[X^2\mid Y]=h(Y)\): it equals 1 when \(Y=0\) and 5 when \(Y=1\). These are conditional means, not the values of \(X^2\) itself.

Worked Example: Conditioning an Infinite-Support Variable

Let \(X\) have the geometric distribution on \(\{0,1,2,\ldots\}\) with \(P(X=x)=(1-r)r^x\), where \(0<r<1\). Set \(Y=I(X\geq 2)\), and find \(E[X\mid Y]\). The geometric distribution here counts the number of failures before the first success.

First, \(P(Y=0)=P(X=0)+P(X=1)=(1-r)(1+r)=1-r^2\). Conditional on \(Y=0\), the only possible values of \(X\) are 0 and 1. Their conditional probabilities are

$$ P(X=0\mid Y=0)=\frac{1-r}{1-r^2}=\frac{1}{1+r}, \qquad P(X=1\mid Y=0)=\frac{(1-r)r}{1-r^2}=\frac{r}{1+r}. $$

Thus \(E[X\mid Y=0]=0/(1+r)+r/(1+r)=r/(1+r)\).

For \(Y=1\), the event is \(X\geq 2\), with probability \(r^2\). For \(z=0,1,\ldots\),

$$ P(X-2=z\mid Y=1) =\frac{P(X=z+2)}{P(X\geq 2)} =\frac{(1-r)r^{z+2}}{r^2} =(1-r)r^z. $$

So, conditional on \(Y=1\), \(X\) has the distribution of 2 plus a geometric variable with mean \(r/(1-r)\). Therefore \(E[X\mid Y=1]=2+r/(1-r)\). For \(r=1/2\), the two conditional means are \(1/3\) and 3, respectively. The random variable \(E[X\mid Y]\) takes the first value when \(X<2\), and the second when \(X\geq 2\).

Worked Example: A Function with a Constant Conditional Mean

Let \(X\) be Poisson with parameter 1, and let \(Y\) be independent of \(X\), with \(P(Y=0)=0.3\) and \(P(Y=1)=0.7\). Find \(E[I(X=0)\mid Y]\).

Independence means the conditional distribution of \(X\) given either positive-probability value of \(Y\) is its original Poisson distribution. For either \(y=0\) or \(y=1\),

$$ E[I(X=0)\mid Y=y] =\sum_{x=0}^{\infty} I(x=0)P(X=x\mid Y=y) =P(X=0) =e^{-1} \approx 0.368. $$

The indicator is 1 only at \(x=0\), which is why every other term in the sum is zero. Hence \(E[I(X=0)\mid Y]=e^{-1}\) with probability one. A conditional expectation need not vary with the conditioning variable; independence is one situation in which the conditional mean here remains constant.

Zero-Probability Values and Common Pitfalls

The pointwise formula requires \(P(Y=y)>0\). If \(P(Y=y)=0\), the quotient by \(P(Y=y)\) is undefined, and the distribution of \(X\) conditional on that event is not determined by ordinary event conditioning. No value at such a point can change \(h(Y)\), because the event on which that value would be used has probability zero. For a countable support, the union of all zero-probability points also has probability zero.

  • Using a joint mass without normalizing. The sum \(\sum_x g(x)P(X=x,Y=y)\) is not the conditional mean. Divide it by \(P(Y=y)\) to obtain the conditional distribution and its mean.
  • Confusing a number with a random variable. \(E[g(X)\mid Y=y]\) is a number for a specified \(y\). \(E[g(X)\mid Y]=h(Y)\) is the random variable that selects the relevant number.
  • Assigning a meaningful conditional law at a null point. If \(P(Y=y)=0\), do not apply the positive-probability formula. Any finite assigned value there gives the same random variable with probability one.

This construction is useful because it turns conditioning on a variable into a collection of familiar conditional means on events. Once the conditional distribution is specified, a nonlinear function causes no special difficulty: apply the function to each possible value of \(X\), weight by its conditional probability, and sum. The same procedure works for finite and countably infinite supports, provided the expectation is integrable as stated.

Check Your Understanding

For each question, distinguish a conditional mean at a point from the random variable defined by conditioning on \(Y\).

  1. What condition on \(P(Y=y)\) is needed to use the conditional-mass formula at \(y\)?
  2. If \(E[g(X)\mid Y=0]=2\) and \(E[g(X)\mid Y=1]=7\), how is \(E[g(X)\mid Y]\) specified when \(Y\) takes only these values?
  3. Why may the value assigned to \(h(y)\) be chosen arbitrarily when \(P(Y=y)=0\)?
  4. In the geometric example, what is \(P(Y=0)\), and what is \(E[X\mid Y=0]\) in terms of \(r\)?
  5. If \(X\) and \(Y\) are independent, does that alone imply \(E[g(X)\mid Y]\) is constant for integrable \(g(X)\)? Explain briefly.