4.9.13Probability Theory & Statistics

Conditional expectation

1,644 words7 min readdifficulty · medium

WHAT is it?

Why two flavours? E[XB]E[X\mid B] conditions on a fixed event → a number. E[XY]E[X\mid Y] packages all the answers "for every possible yy" into one object → a random function of YY.


HOW: deriving the Tower / Law of Total Expectation

This is THE key theorem. Let's build it from scratch.

Derivation from first principles (discrete):

Start with the definition of E[XY=y]E[X\mid Y=y] and take its expectation over YY: E[E[XY]]=yE[XY=y]P(Y=y)E\big[E[X\mid Y]\big] = \sum_y E[X\mid Y=y]\,P(Y=y)

Why this step? E[XY]E[X\mid Y] is a function of YY; the expectation of a function g(Y)g(Y) is yg(y)P(Y=y)\sum_y g(y)P(Y=y).

Substitute the definition E[XY=y]=xxP(X=xY=y)E[X\mid Y=y]=\sum_x x\,P(X=x\mid Y=y): =y(xxP(X=xY=y))P(Y=y)= \sum_y \Big(\sum_x x\,P(X=x\mid Y=y)\Big)P(Y=y)

Why? Just plugging in. Now use P(X=xY=y)P(Y=y)=P(X=x,Y=y)P(X=x\mid Y=y)P(Y=y) = P(X=x, Y=y) (definition of conditional probability): =yxxP(X=x,Y=y)=xxyP(X=x,Y=y)P(X=x)= \sum_y\sum_x x\, P(X=x, Y=y) = \sum_x x \underbrace{\sum_y P(X=x,Y=y)}_{P(X=x)}

Why the inner sum collapses? Summing the joint over all yy marginalises yy away, leaving P(X=x)P(X=x). =xxP(X=x)=E[X]= \sum_x x\, P(X=x) = E[X] \qquad \blacksquare


Two more rules you'll reuse constantly

Figure — Conditional expectation

Worked examples


Common mistakes (steeled)


Recall Feynman: explain to a 12-year-old

You want to guess how tall a random kid in school is. Your first guess is the school average — that's E[X]E[X]. Now someone whispers "they're in 8th grade" — that's the extra info YY. You update to the 8th-grade average — that's E[XY]E[X\mid Y]. The cool trick (Tower Rule): if you take every grade's average and blend them by how many kids are in each grade, you get back the whole-school average. Splitting up and recombining never changes the overall answer.


Flashcards

What kind of object is E[XY]E[X\mid Y] (note: capital YY)?
A random variable — a function g(Y)g(Y) of the random YY.
What kind of object is E[XY=y]E[X\mid Y=y]?
A number, one for each fixed value yy.
State the Tower / Law of Iterated Expectation.
E[E[XY]]=E[X]E[\,E[X\mid Y]\,]=E[X].
First step in deriving the tower (discrete)?
E[E[XY]]=yE[XY=y]P(Y=y)E[E[X\mid Y]]=\sum_y E[X\mid Y=y]\,P(Y=y).
Why does the inner sum yP(X=x,Y=y)\sum_y P(X=x,Y=y) collapse?
Marginalising over yy gives P(X=x)P(X=x).
"Take out what is known" rule?
E[g(Y)XY]=g(Y)E[XY]E[g(Y)X\mid Y]=g(Y)E[X\mid Y].
If XYX\perp Y what is E[XY]E[X\mid Y]?
The constant E[X]E[X].
YU(0,1)Y\sim U(0,1), XY=yU(0,y)X\mid Y=y\sim U(0,y): find E[X]E[X].
E[XY]=Y/2E[X\mid Y]=Y/2, so E[X]=E[Y/2]=1/4E[X]=E[Y/2]=1/4.
Coin: H→one die, T→sum of two dice. Find E[X]E[X].
12(3.5)+12(7)=5.25\tfrac12(3.5)+\tfrac12(7)=5.25.
Common slip when applying tower across groups?
Forgetting to weight conditional means by P(Y=y)P(Y=y).

Connections

Concept Map

updated after learning Y

generalise over all y

feed random Y into g of Y

weighted average over Y

averaging recovers

special case

special case

if X independent of Y

g of Y acts as constant

Plain expectation E X

E X given event B

E X given Y equals y

E X given Y is a random variable

Tower Rule E of E X given Y equals E X

Taking out known g of Y

Independence collapse

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Conditional expectation ka matlab simple hai: pehle aapke paas XX ka best guess hota hai jo E[X]E[X] kehlata hai — yeh aapka guess hai jab aapko kuchh nahi pata. Lekin agar aapko thodi extra information mil jaaye (maan lo aapko YY ka value pata chal gaya), to aap apna guess update karte ho. Yeh updated guess hota hai E[XY=y]E[X\mid Y=y] — jo ek number hai har yy ke liye. Aur jab aap YY ko random rehne dete ho, to E[XY)E[X\mid Y) khud ek random variable ban jaata hai. Yahi sabse important point hai jo students miss karte hain.

Sabse powerful tool hai Tower Rule: E[E[XY]]=E[X]E[\,E[X\mid Y]\,]=E[X]. Iska intuition exam scores se samjho — pehle har class ka average nikaalo, phir un class-averages ka average lo lekin class ke size ke hisaab se weight karke. Final answer wahi aayega jo poore school ka direct average. Matlab "average of averages, weighted by crowd size". Tod-tod ke jodne se overall mean kabhi nahi badalta.

Practical fायda yeh hai ki kai baar XX ka full distribution nikaalna mushkil hota hai (jaise jab summands ki number bhi random ho). Tab hum direct E[X]E[X] nikaalne ki jagah, YY par condition karke chhote-chhote easy expectations nikaalte hain aur tower se jod dete hain. Coin-aur-dice wala example dekho — humne kabhi pura distribution banaya hi nahi, bas 12(3.5)+12(7)=5.25\tfrac12(3.5)+\tfrac12(7)=5.25 kar diya.

Do galtiyaan avoid karo: (1) "known cheez bahar nikaalna" hamesha valid hai — E[g(Y)XY]=g(Y)E[XY]E[g(Y)X\mid Y]=g(Y)E[X\mid Y] — par usko E[X]E[X] se replace karna sirf tabhi jab XX aur YY independent ho. (2) Tower mein conditional means ko P(Y=y)P(Y=y) se weight karna mat bhoolna, warna answer galat aayega.

Go deeper — visual, from zero

Test yourself — Probability Theory & Statistics

Connections