Tutorials › Statistical Theory I - Probability and Distribution Theory › Conditional Expectations of Indicators

Conditional Expectation · Tutorial 336 of 994

Conditional Expectations of Indicators

Use indicator variables to express conditional event probabilities precisely and compute them from discrete tables or joint densities.

Intermediate 10 min read

What You'll Learn

  • Define the conditional probability of an event given a random variable as a conditional expectation.
  • Prove the conditional-expectation identity for event indicators.
  • Calculate conditional event probabilities from discrete conditional distributions.
  • Derive conditional event probabilities from a joint density and marginal density.
  • Average conditional probabilities over a conditioning event to obtain an event probability.
  • Distinguish conditioning on a continuous variable from conditioning on a probability-zero event.

From an Event to a Random Variable

An event has a probability, but it can also be represented by a random variable: its indicator records whether it occurred. This representation makes conditional event probabilities part of the general theory of conditional expectation. It also gives a precise way to discuss how the probability of an event changes with an observed variable.

Definition: For an event \(A\), its indicator is the random variable \(\mathbf{1}_A\), equal to \(1\) on \(A\) and \(0\) on \(A^c\). If \(\mathcal{G}\) is a sigma-field, the conditional probability of \(A\) given \(\mathcal{G}\) is the random variable $$ P(A\mid\mathcal{G})=E[\mathbf{1}_A\mid\mathcal{G}]. $$ In particular, \(P(A\mid X)\) denotes \(E[\mathbf{1}_A\mid\sigma(X)]\), where \(\sigma(X)\) is the sigma-field generated by \(X\). This is a random variable, defined up to equality almost surely.

The notation \(P(A\mid X=x)\) is often used for a function of \(x\) that represents \(P(A\mid X)\). For discrete \(X\), its value at each point with positive probability is an ordinary conditional probability. For continuous \(X\), it is typically calculated from a conditional density. Its value at a particular \(x\) can depend on the chosen version at points that have probability zero under the distribution of \(X\).

Why the Indicator Gives Conditional Probability

The key fact is a direct consequence of the averaging characterization of conditional expectation. Conditional expectation preserves the event's probability when averaged over any information in the conditioning sigma-field.

Theorem: Let \(A\) be an event and \(\mathcal{G}\) a sigma-field. Then \(E[\mathbf{1}_A\mid\mathcal{G}]\) is a \(\mathcal{G}\)-measurable random variable \(Q\) such that, for every \(B\in\mathcal{G}\), $$ E[\mathbf{1}_B Q]=P(A\cap B). $$ Equivalently, \(P(A\mid\mathcal{G})=E[\mathbf{1}_A\mid\mathcal{G}]\) is the conditional probability of \(A\) given \(\mathcal{G}\).

Proof. Since \(0\leq \mathbf{1}_A\leq 1\), its conditional expectation exists and is \(\mathcal{G}\)-measurable. By the defining averaging property of conditional expectation, for every \(B\in\mathcal{G}\),

$$ E[\mathbf{1}_B E[\mathbf{1}_A\mid\mathcal{G}]] =E[\mathbf{1}_B\mathbf{1}_A] =P(A\cap B). $$

Thus it has precisely the required averaging property. Uniqueness of conditional expectation up to equality almost surely establishes the claim. \(\square\)

Taking \(B\) to be the whole sample space also gives \(E[P(A\mid\mathcal{G})]=P(A)\). More generally, if \(B\) describes a condition that can be determined from the available information, then

$$ P(A\mid B)=\frac{E[\mathbf{1}_B P(A\mid\mathcal{G})]}{P(B)},\qquad P(B)>0. $$

This formula averages the conditional probability over the event \(B\) before dividing by \(P(B)\). The event \(B\) must belong to \(\mathcal{G}\) for this use of the defining property.

Conditioning on a Discrete Variable

Suppose \(X\) is discrete. At a value \(x\) with \(P(X=x)>0\), the conditional probability of \(A\) given \(X=x\) is

$$ P(A\mid X=x)=\frac{P(A\cap\{X=x\})}{P(X=x)}. $$

These values specify a version of the random variable \(P(A\mid X)\): on the event \(\{X=x\}\), it takes the value \(P(A\mid X=x)\). Values at \(x\) with \(P(X=x)=0\) do not affect the conditional expectation.

Result: For discrete \(X\), if \(P(X=x)>0\), then $$ E[\mathbf{1}_A\mid X=x]=P(A\mid X=x). $$ For any set \(C\) of values of \(X\) with \(P(X\in C)>0\), $$ P(A\mid X\in C) =\frac{\sum_{x\in C}P(A\mid X=x)P(X=x)} {\sum_{x\in C}P(X=x)}. $$

To verify the averaging formula, partition \(A\cap\{X\in C\}\) by the possible values of \(X\). Each term satisfies \(P(A\cap\{X=x\})=P(A\mid X=x)P(X=x)\), so summing and dividing by \(P(X\in C)\) gives the result.

Worked Example: A Discrete Risk Table

Let \(X\) be a three-level score with \(P(X=-1)=0.2\), \(P(X=0)=0.5\), and \(P(X=1)=0.3\). An event \(A\), such as a positive test result, has conditional probabilities \(P(A\mid X=-1)=0.1\), \(P(A\mid X=0)=0.4\), and \(P(A\mid X=1)=0.8\). Find \(P(A)\) and \(P(A\mid X\geq 0)\).

The conditional expectation of the indicator takes the corresponding event probability at each score:

$$ E[\mathbf{1}_A\mid X]= \begin{cases} 0.1,&X=-1,\\ 0.4,&X=0,\\ 0.8,&X=1. \end{cases} $$

Average over all three score values to obtain the event's unconditional probability:

$$ P(A)=0.1(0.2)+0.4(0.5)+0.8(0.3) =0.02+0.20+0.24=0.46. $$

For the condition \(X\geq 0\), the probability of the condition is \(0.5+0.3=0.8\). The probability of both \(A\) and \(X\geq0\) is \(0.4(0.5)+0.8(0.3)=0.44\). Therefore,

$$ P(A\mid X\geq0)=\frac{0.44}{0.8}=0.55. $$

Equivalently, this is the weighted average \([0.4(0.5)+0.8(0.3)]/(0.5+0.3)\). The conditional probabilities are weighted by how often each score occurs within the selected group.

Conditioning on a Continuous Variable

For a continuous variable, \(P(X=x)\) is typically zero, so the discrete ratio cannot be used. Instead, a joint density gives a conditional probability through a ratio of densities. Let \((X,Y)\) have joint density \(f_{X,Y}\) and marginal density \(f_X\). For a Borel set \(D\), at values \(x\) where \(0<f_X(x)<\infty\), define

$$ q_D(x)=\frac{\int_D f_{X,Y}(x,y)\,dy}{f_X(x)}. $$
Result: Under the joint-density conditions above, \(q_D(X)\) is a version of \(P(Y\in D\mid X)\). More generally, for a measurable event \(A\) determined by \((X,Y)\), replace the numerator by $$ \int_{\mathbb{R}}\mathbf{1}_A(x,y)f_{X,Y}(x,y)\,dy. $$ The ratio is defined wherever \(f_X(x)>0\); its values where \(f_X(x)=0\) may be assigned arbitrarily.

Proof. Write \(A_D=\{Y\in D\}\), and let \(C\) be any Borel set of possible values of \(X\). Using the definition of \(q_D\), the marginal density, and integration of the joint density,

$$ \begin{aligned} E[\mathbf{1}_{\{X\in C\}}q_D(X)] &=\int_C q_D(x)f_X(x)\,dx\\ &=\int_C\int_D f_{X,Y}(x,y)\,dy\,dx\\ &=P(X\in C,\ Y\in D). \end{aligned} $$

The integrands are nonnegative, so the exchange of integration is justified by Tonelli's theorem. The last expression is \(E[\mathbf{1}_{\{X\in C\}}\mathbf{1}_{A_D}]\). Since events of the form \(\{X\in C\}\) generate \(\sigma(X)\), this averaging identity identifies \(q_D(X)\) as a version of \(E[\mathbf{1}_{A_D}\mid\sigma(X)]\). The same argument with \(\mathbf{1}_A(x,y)\) in the integrand proves the general event formula. \(\square\)

Worked Example: A Conditional Probability from a Triangular Density

Suppose \((X,Y)\) has joint density \(f_{X,Y}(x,y)=2\) for \(0<y<x<1\), and zero elsewhere. Find \(P(Y<1/2\mid X=x)\), then check that averaging this conditional probability gives \(P(Y<1/2)\).

First find the marginal density of \(X\):

$$ f_X(x)=\int_0^x 2\,dy=2x,\qquad 0<x<1. $$

For \(0<x\leq 1/2\), every possible value \(0<y<x\) is less than \(1/2\), so the numerator in the conditional-density ratio is \(2x\). For \(1/2<x<1\), only \(0<y<1/2\) qualifies, giving numerator \(2(1/2)=1\). Thus a version of the conditional probability is

$$ P(Y<1/2\mid X=x)= \begin{cases} 1,&0<x\leq 1/2,\\[2pt] \dfrac{1}{2x},&1/2<x<1. \end{cases} $$

Now average against \(f_X(x)=2x\):

$$ \begin{aligned} P(Y<1/2) &=\int_0^{1/2}1(2x)\,dx +\int_{1/2}^1\frac{1}{2x}(2x)\,dx\\ &=\left[x^2\right]_0^{1/2} +\left[x\right]_{1/2}^1 =\frac14+\frac12=\frac34. \end{aligned} $$

The result also follows directly by integrating the joint density over \(0<y<\min(x,1/2)\): \(\int_0^{1/2}2x\,dx+\int_{1/2}^1 1\,dx=3/4\). Both calculations agree.

Using Conditional Probabilities to Answer a Group Question

A conditional probability given \(X\) varies with \(X\); a conditional probability given a group such as \(X>c\) is a single average over that group. The indicator identity makes the connection explicit: if \(P(X\in C)>0\), then

$$ P(A\mid X\in C) =\frac{E[\mathbf{1}_{\{X\in C\}}P(A\mid X)]}{P(X\in C)}. $$

This follows because \(\{X\in C\}\in\sigma(X)\), so the averaging characterization gives \(E[\mathbf{1}_{\{X\in C\}}P(A\mid X)]=P(A\cap\{X\in C\})\). Dividing by the group probability produces the ordinary conditional probability.

Worked Example: Averaging a Probability Over a Continuous Group

Let \(X\sim\operatorname{Uniform}(0,2)\). Given \(X=x\), suppose an event \(A\) occurs when an independent \(U\sim\operatorname{Uniform}(0,1)\) satisfies \(U\leq x/2\). Find \(P(A\mid X>1)\).

For fixed \(x\in(0,2)\), the interval of \(U\)-values satisfying \(U\leq x/2\) has length \(x/2\). Therefore \(P(A\mid X=x)=x/2\). Since \(X\) has density \(1/2\) on \((0,2)\),

$$ P(A\mid X>1) =\frac{\int_1^2 (x/2)(1/2)\,dx}{P(X>1)} =\frac{\frac14\left[\frac{x^2}{2}\right]_1^2}{1/2} =\frac{3/8}{1/2} =\frac34. $$

The numerator is \(P(A\cap\{X>1\})\), and \(P(X>1)=(2-1)/2=1/2\). As a check, conditional on \(X>1\), \(X\) is uniform on \((1,2)\), so the average of \(X/2\) is \(((1+2)/2)/2=3/4\), the same answer.

Common Pitfall and Why the Identity Matters

A common mistake is to treat \(P(A\mid X=x)\) for a continuous \(X\) as the ratio \(P(A\cap\{X=x\})/P(X=x)\). Both numerator and denominator are generally zero, so this ratio is undefined. The conditional probability is instead a version obtained from a conditional density or another conditional law; its values are meaningful almost everywhere with respect to the distribution of \(X\), not as a ratio of probabilities of point events.

The indicator formulation is useful because it unifies event probabilities with conditional expectations. It lets a statistician represent a changing event probability as a random variable, recover an overall probability by averaging, and compute a group-specific probability by averaging only over the relevant values of the conditioning variable. These operations rely on the same identity, whether the conditioning variable is discrete or continuous.

Key takeaway: The conditional probability of an event given available information is the conditional expectation of its indicator. For discrete conditioning, use conditional probability ratios at positive-mass points; for continuous conditioning, use conditional-density ratios and interpret the result as a version defined almost surely.

Check Your Understanding

Use the indicator identity and the conditioning formulas to answer these questions.

  1. Why is \(E[\mathbf{1}_A\mid\mathcal{G}]\) between zero and one almost surely, and what averaging property identifies it?
  2. If \(P(X=0)=0.4\), \(P(X=1)=0.6\), \(P(A\mid X=0)=0.2\), and \(P(A\mid X=1)=0.7\), calculate \(P(A)\).
  3. For a continuous \(X\), why is \(P(A\mid X=x)\) generally not computed by dividing \(P(A\cap\{X=x\})\) by \(P(X=x)\)?
  4. State the joint-density ratio for \(P(Y\in D\mid X=x)\), and identify the marginal-density condition needed to use it.
  5. Explain how \(P(A\mid X\in C)\) can be obtained by averaging \(P(A\mid X)\) over the group \(X\in C\).