ProofComplete

Expectation and Variance - Key Proof

We present a complete proof of the Law of Total Expectation, a fundamental result that connects conditional and unconditional expectations.

Law of Total Expectation

Theorem

Let XX and YY be random variables. Then: E[X]=E[E[X∣Y]]E[X] = E[E[X|Y]]

More generally, if {B1,B2,…,Bn}\{B_1, B_2, \ldots, B_n\} is a partition of the sample space: E[X]=βˆ‘i=1nE[X∣Bi]P(Bi)E[X] = \sum_{i=1}^n E[X|B_i] P(B_i)

Proof

We prove the discrete case; the continuous case follows analogously using integrals.

Discrete Case (Partition Formula): Let {B1,…,Bn}\{B_1, \ldots, B_n\} be a partition with P(Bi)>0P(B_i) > 0 for all ii.

By definition of conditional expectation: E[X∣Bi]=βˆ‘xxβ‹…P(X=x∣Bi)E[X|B_i] = \sum_x x \cdot P(X = x | B_i)

Therefore: βˆ‘i=1nE[X∣Bi]P(Bi)=βˆ‘i=1n[βˆ‘xxβ‹…P(X=x∣Bi)]P(Bi)\sum_{i=1}^n E[X|B_i] P(B_i) = \sum_{i=1}^n \left[\sum_x x \cdot P(X = x | B_i)\right] P(B_i)

Rearranging the sums: =βˆ‘xxβˆ‘i=1nP(X=x∣Bi)P(Bi)= \sum_x x \sum_{i=1}^n P(X = x | B_i) P(B_i)

By the law of total probability: βˆ‘i=1nP(X=x∣Bi)P(Bi)=P(X=x)\sum_{i=1}^n P(X = x | B_i) P(B_i) = P(X = x)

Substituting: =βˆ‘xxβ‹…P(X=x)=E[X]= \sum_x x \cdot P(X = x) = E[X] β–‘

General Case (E[E[X∣Y]]E[E[X|Y]]): When conditioning on a random variable YY rather than a partition, we use the fact that E[X∣Y]E[X|Y] is itself a random variable (a function of YY).

For discrete YY taking values y1,y2,…y_1, y_2, \ldots: E[E[X∣Y]]=βˆ‘jE[X∣Y=yj]β‹…P(Y=yj)E[E[X|Y]] = \sum_j E[X|Y = y_j] \cdot P(Y = y_j)

This is precisely the partition formula with Bj={Y=yj}B_j = \{Y = y_j\}.

For continuous YY with density fYf_Y: E[E[X∣Y]]=βˆ«βˆ’βˆžβˆžE[X∣Y=y]β‹…fY(y) dyE[E[X|Y]] = \int_{-\infty}^{\infty} E[X|Y = y] \cdot f_Y(y) \, dy

By the definition of conditional expectation: E[X∣Y=y]=βˆ«βˆ’βˆžβˆžxβ‹…fX∣Y(x∣y) dxE[X|Y = y] = \int_{-\infty}^{\infty} x \cdot f_{X|Y}(x|y) \, dx

Therefore: E[E[X∣Y]]=βˆ«βˆ’βˆžβˆž[βˆ«βˆ’βˆžβˆžxβ‹…fX∣Y(x∣y) dx]fY(y) dyE[E[X|Y]] = \int_{-\infty}^{\infty} \left[\int_{-\infty}^{\infty} x \cdot f_{X|Y}(x|y) \, dx\right] f_Y(y) \, dy

Interchanging the order of integration (by Fubini's theorem): =βˆ«βˆ’βˆžβˆžx[βˆ«βˆ’βˆžβˆžfX∣Y(x∣y)fY(y) dy]dx= \int_{-\infty}^{\infty} x \left[\int_{-\infty}^{\infty} f_{X|Y}(x|y) f_Y(y) \, dy\right] dx

Since fX∣Y(x∣y)fY(y)=fX,Y(x,y)f_{X|Y}(x|y) f_Y(y) = f_{X,Y}(x,y) (joint density): =βˆ«βˆ’βˆžβˆžx[βˆ«βˆ’βˆžβˆžfX,Y(x,y) dy]dx= \int_{-\infty}^{\infty} x \left[\int_{-\infty}^{\infty} f_{X,Y}(x,y) \, dy\right] dx

The inner integral gives the marginal density fX(x)f_X(x): =βˆ«βˆ’βˆžβˆžxβ‹…fX(x) dx=E[X]= \int_{-\infty}^{\infty} x \cdot f_X(x) \, dx = E[X] β–‘

β– 

Applications and Consequences

Example

Computing Expectation via Conditioning: Roll a fair die. If the result is even, toss that many fair coins; if odd, toss one coin. Let XX = number of heads.

Let DD be the die outcome. Partition by whether DD is even or odd: E[X]=E[X∣D even]P(D even)+E[X∣D odd]P(D odd)E[X] = E[X|D \text{ even}]P(D \text{ even}) + E[X|D \text{ odd}]P(D \text{ odd})

When DD is even (D∈{2,4,6}D \in \{2,4,6\}): E[X∣D even]=13(E[X∣D=2]+E[X∣D=4]+E[X∣D=6])E[X|D \text{ even}] = \frac{1}{3}(E[X|D=2] + E[X|D=4] + E[X|D=6]) =13(1+2+3)=2= \frac{1}{3}(1 + 2 + 3) = 2

When DD is odd: E[X∣D odd]=0.5E[X|D \text{ odd}] = 0.5

Therefore: E[X]=2Γ—12+0.5Γ—12=1.25E[X] = 2 \times \frac{1}{2} + 0.5 \times \frac{1}{2} = 1.25

Example

Recursive Calculation: A geometric random variable N∼Geometric(p)N \sim \text{Geometric}(p) can be computed recursively.

On the first trial, either we succeed (probability pp, giving N=1N = 1), or we fail (probability 1βˆ’p1-p, and we're back at the start): E[N]=pβ‹…1+(1βˆ’p)β‹…(1+E[N])E[N] = p \cdot 1 + (1-p) \cdot (1 + E[N])

Solving: E[N]=p+(1βˆ’p)+(1βˆ’p)E[N]E[N] = p + (1-p) + (1-p)E[N] pβ‹…E[N]=1p \cdot E[N] = 1 E[N]=1pE[N] = \frac{1}{p}

Remark

The law of total expectation is an indispensable tool for computing expectations in complex situations. By conditioning on an appropriate random variable or partition, we can break difficult problems into simpler conditional pieces, then reassemble the result.