Hexa Scholar

Conditional expectation as the best guess

A wooden branching tree on a navy base with a gold beam at every fork and stacks of gold coins of different heights hanging from its eight lowest tips.
A tree of forks, with coins hanging from its eight tips.

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. 1 SeeFill in two coin trees, node by node.
  2. 2 TryScore guesses by their squared error.
  3. 3 ProveBuild the proof, line by line.
  4. 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 ideas

Average 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.

You know

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 =

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.

1 See

Fill in the coin tree

The root is at the top and the eight outcomes are at the bottom, each with its payoff in dollars. A node shows your entry, or ? while it is empty. After a check, a node checked right has a thick box and the word right next to its name; a node checked wrong has a dashed box and the word wrong.
After two tosses
After one toss
Before any toss
2 Try

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.

3 Prove

Why E[Y | X] beats every other guess

Theorem

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\).

What else follows
    4 Apply

    Problems

    Each problem states its model and has hints and a full solution. Answers can be typed as decimals or as fractions.

    Key point To find \(E[Y \mid \text{what you know}]\), average \(Y\) over the outcomes still possible, each with its conditional probability; in a tree, work up from the payoffs one node at a time. Averaging the conditional expectations over what you might learn gives back \(E[Y]\). Each answer describes the model, and holds for the real situation only as far as the model's probabilities do.
    Level Intermediate Prerequisites conditional probability (the lesson on conditional probability), expectation (the lesson on expectation and variance), covariance (the lesson on covariance and correlation) Time ~35 min

    Further reading