Conditional Expectation & Conditioning

conditional expectation given a random variable

Suppose you want to guess a person's weight (call it X) but I first tell you their height (call it Y). Your best plan is not one fixed number — it depends on what height I tell you. For each possible height value y you would name the average weight among all people of that height. That rule, height in and average weight out, is the conditional expectation of X given Y. It answers: once I know Y, what is my updated best estimate of the average of X?

Concretely, for each value y we compute an ordinary average of X, but restricted to the slice of the world where Y = y. In the discrete case that average is E[X given Y = y] = sum over x of x times P(X = x given Y = y), and in the continuous case it uses the conditional density: E[X given Y = y] = integral of x times f(x given y) dx. This produces a function g, where g(y) is that slice-average. The crucial twist is what we call E[X given Y]: we do NOT plug in a fixed y. Instead we substitute the random Y itself, so E[X given Y] = g(Y) is a NEW random variable — it changes from outcome to outcome because Y does. Before you observe Y, your best estimate is itself random.

This is the bridge from elementary probability to the modern theory. The function g is exactly the regression curve a statistician fits, and E[X given Y] is the best mean-square predictor of X built from Y. The single most common confusion: E[X given Y = y] is a number (a slice-average for a fixed y), while E[X given Y] is a random variable (the same rule with the random Y fed in). Keep those two apart and almost everything else falls into place.

Roll a fair die; let Y = 1 if the result is even, 0 if odd. Then E[X given Y = 1] averages {2,4,6} to get 4, and E[X given Y = 0] averages {1,3,5} to get 3. So E[X given Y] is the random variable that equals 4 on even rolls and 3 on odd rolls — and its own average, (4 + 3)/2 = 3.5, recovers E[X].

E[X given Y] is a random variable: a different slice-average for each value of Y.

E[X given Y = y] is a number; E[X given Y] is a random variable (a function of Y). Conflating the two is the classic beginner error.

Also called
E[X given Y]conditional meanregression function條件均值迴歸函數