Conditional expectation as the best guess
The question
A game pays (number of heads)² dollars after three fair coin tosses. The first toss lands heads. What is the game worth on average now?
Stage 1 asks you for that number at every point of the game.
- 1 SeeFill in two coin trees, node by node.
- 2 TryScore guesses by their squared error.
- 3 ProveBuild the proof, line by line.
- 4 ApplyAn option, a shop and a stock.
Before you start · 3 quick checks on conditional probability, expectation and covariance, about 3 min
Two ideas before you start
2 ideasAverage over what is still possible
Figure: six bars for the faces 1 to 6 of a fair die, each as tall as its face; the faces outside the known event are faint, and a dashed line marks the average of the faces left. It needs JavaScript.
E[Y] = (1 + 2 + 3 + 4 + 5 + 6) / 6 = 3.5
Y is the roll of a fair die. Knowing that an event happened rules out the outcomes outside it. The conditional expectation averages Y over the outcomes that remain, each with its conditional probability.
Exact definition
Conditional expectation given an event. Let \(Y\) be a random variable with finitely many values and \(A\) an event with \(P(A) \gt 0\). The conditional expectation of \(Y\) given \(A\) is
\[E[Y \mid A] = \sum_{y} y\,P(Y = y \mid A),\]the average of \(Y\) under the conditional probabilities \(P(\cdot \mid A)\) of the lesson on conditional probability. Equivalently, \(E[Y \mid A] = E[Y\,1_{A}]/P(A)\), where \(1_{A}\) is 1 on \(A\) and 0 off \(A\).
Given a random variable, the answer is a random variable
Figure: six bars for the faces of a fair die, with a dashed segment at 3 over the odd faces and at 4 over the even faces. It needs JavaScript.
X = odd: E[Y | X = odd] = (1 + 3 + 5) / 3 = 3
Let X say whether the roll is odd or even. Before the roll, E[Y | X] is not one number: it is 3 on every odd roll and 4 on every even roll. It depends on the outcome only through X.
Exact definition
Conditional expectation given a random variable. Let \(X\) take finitely many values \(x\), each with \(P(X = x) \gt 0\), and let \(Y\) take finitely many values. For each value \(x\), let \(m(x) = E[Y \mid X = x]\), the conditional expectation given the event \(X = x\). The conditional expectation of \(Y\) given \(X\) is the random variable
\[E[Y \mid X] = m(X).\]Its value is \(m(x)\) at every outcome where \(X = x\).
Fine print: what this page assumes
Every random variable on this page takes finitely many values, and every event it conditions on has positive probability, so each conditional expectation is a finite weighted average. Coin tosses are independent, and every toss of the same coin has the same probability of heads.
For a random variable \(X\) with infinitely many values, such as a normal one, the events \(X = x\) can have probability 0, and \(E[Y \mid X]\) is then defined through the information that \(X\) carries rather than one event at a time. The best-guess property proved in stage 3 still holds whenever \(E[Y^{2}]\) is finite, among the guesses \(g(X)\) with \(E[g(X)^{2}]\) finite.
Fill in the coin tree
- Type a number into each of the seven empty nodes: what the game is worth on average, given the tosses so far. Decimals and fractions both work.
- Press Check my tree. A wrong node gets a dashed box and a hint about the two nodes just below it. Check as often as you like.
- There are two trees: a fair coin first, then a coin that lands heads with probability 0.6.
Scoring a guess by its squared error
Stay with the fair-coin game of tree 1, \(Y = N^{2}\). Suppose you must name a guess for \(Y\), and the guess costs you the squared error \((Y - \text{guess})^{2}\). Two questions come first. The explorer below them opens once both are answered.
The explorer opens when you have answered the two questions above.
Explorer: a guess that may use the first toss
Write \(X\) for the first toss. A guess that uses it is a function \(g\): the number \(g(H)\) after heads and \(g(T)\) after tails. Choose both in steps of 0.25. The figure draws the expected squared error given each outcome of the first toss, for every guess from 0 to 9, and the tiles give the exact values for your two guesses.
Goals
Why E[Y | X] beats every other guess
Assumptions. \(X\) takes finitely many values, at least two, and \(P(X = x) \gt 0\) for each of them. \(Y\) takes finitely many values. For each value \(x\) of \(X\), \(m(x) = E[Y \mid X = x]\). A guess is any function \(g\) on the values of \(X\), and \(E[(Y - g(X))^{2}]\) is its expected squared error. For a guess \(g\), write \(d(x) = m(x) - g(x)\), its gap from \(m\).
Conclusion. For every function \(g\),
\[\begin{aligned} &E[(Y - g(X))^{2}] \\ &= E[(Y - m(X))^{2}] + E[d(X)^{2}]. \end{aligned}\]So \(m(X) = E[Y \mid X]\) has the smallest expected squared error of all guesses that use \(X\), and every guess other than \(m\), that is, with \(g(x) \ne m(x)\) for at least one value \(x\) of \(X\), does strictly worse.
For \(g = m\), \(d(x) = 0\) for every \(x\) and the identity is plain. So the proof below takes a guess \(g\) other than \(m\).
Facts the proof uses.
- linearity of expectation, from the lesson on expectation and variance;
- the law of total expectation: for every random variable \(Z\) with finitely many values, \(E[Z] = \sum_{x} P(X = x)\,E[Z \mid X = x]\). It follows from the law of total probability in the lesson on conditional probability;
- given \(X = x\), a function \(k(X)\) is the number \(k(x)\): \(E[k(X)\,Z \mid X = x] = k(x)\,E[Z \mid X = x]\).
Each option is one sentence about the \(X\) and \(Y\) of the theorem. Pick the one that is true for every \(X\) and \(Y\) the theorem covers, read with its words "for every" exactly as written, including any condition on \(g\).
Problems
Each problem states its model and has hints and a full solution. Answers can be typed as decimals or as fractions.
Further reading
- J. K. Blitzstein and J. Hwang, Introduction to Probability, 2nd ed. (CRC Press, 2019), ch. 9, "Conditional expectation," on conditional expectation given an event and given a random variable, and its properties.
- S. Ross, A First Course in Probability, 10th ed. (Pearson, 2019), ch. 7, sections 7.5 and 7.6, on conditional expectation and on its use for prediction.
- D. Williams, Probability with Martingales (Cambridge University Press, 1991), ch. 9, "Conditional expectation," for the general definition and the least-squares view.