Lesson · ESL II §2.4 · equations 2.9 to 2.13
Why the best prediction is the conditional mean
This page rebuilds the first page of ESL's statistical decision theory from a four-cell table you can check by hand. You'll see what expected prediction error measures (2.9), how it turns into an integral (2.10), why it can be computed one x at a time (2.11), and why that view forces the best prediction at each x to be the average of Y there (2.12 and 2.13).
- Goal
- Understand each equation: what every symbol refers to, where each step comes from, and why the result follows.
- You'll need
- Weighted averages, squaring, and basic algebra. Conditional probability and the "slope is zero at the bottom" idea are explained where they're used.
- Not covered
- Nearest neighbours (2.14 onward), classification losses, and estimating EPE from a training sample.
How to use it: every number on this page comes from the table in section 1, or from the new table in section 9. Each question comes before its folded answer, so make a guess before you open it.
Contents
1Random pairs and a joint table
ESL sets up a world where each case, say a customer, comes with an input X (the features) and an output Y (the thing to predict). Both are random variables: quantities whose values aren't known until a case is drawn. The book writes the random variable in capitals and one particular value it takes in lowercase. So X means "the input of a case we haven't seen yet", and x means one concrete value, like x = 1. In the book, X ∈ ℝp is a list of p numbers and Y ∈ ℝ is one number. Here we shrink both down so everything fits on one table.
In our running example, X can only be 0 or 1, and Y can only be 1 or 3. The joint distribution Pr(X, Y) gives the probability of every combination, and that's all there is to know about the population:
| y = 1 | y = 3 | |
|---|---|---|
| x = 0 | 0.3 | 0.1 |
| x = 1 | 0.1 | 0.5 |
Read the bottom-right cell as: half of all cases have x = 1 and y = 3. The four cells add to 1, because every case lands in exactly one of them. The table has to be joint, not two separate lists, because the relationship lives in the pairing: when x = 0, Y is usually 1, and when x = 1, Y is usually 3. It also contains noise, since the same x can come with either y. Even a perfect rule will make some mistakes.
The whole population in four cells
Fig. 1.1Adding along a row gives the probability of that x, whatever y turns out to be: Pr(X = 0) = 0.3 + 0.1 = 0.4 and Pr(X = 1) = 0.1 + 0.5 = 0.6. These row totals are called the marginal distribution of X. They'll come back in section 6 as weights.
Predict
What is Pr(Y = 3), the probability that a random case has y = 3, whatever its x?
Answer
Add down the y = 3 column: 0.1 + 0.5 = 0.6. A common slip is to answer 0.5 by reading one cell. That's the probability of y = 3 and x = 1 together, and it leaves out the cases with x = 0.
One boundary to keep in mind for the whole page: this table is the population, every case that could ever occur. In real work you never see it. You see a finite training sample drawn from it. Equations 2.9 to 2.13 describe the ideal you'd reach if you knew the table, and later sections of ESL are about approximating it from data.
2One draw, one square
A prediction rule f sees only x and has to return one number. In our table x is 0 or 1, so a rule is just two numbers, and we'll call them dials: a = f(0), the prediction used whenever x = 0, and b = f(1), used whenever x = 1. Choosing f means setting those two dials. The rule doesn't get to see y, so both cells of a row get the same prediction.
When a case is drawn, the miss is y − f(x), the actual value minus the prediction. A loss function L(Y, f(X)) turns the miss into a penalty, and ESL uses squared error: L = (Y − f(X))2. Squaring does two jobs. It removes the sign, so a miss of −2 costs the same as +2. It also grows faster than the miss: twice the miss costs four times as much. You can draw the penalty as a square whose side is the miss, so its area is the squared error.
The squared error of one draw is a square's area
Fig. 2.1 · interactiveExplain
Why not score a rule by its average miss, y − f(x), instead of the average squared miss?
Answer
Misses above and below the prediction cancel. In row x = 0 with a = 2, the misses are −1 (probability 0.3) and +1 (probability 0.1). A rule that is always wrong could still average to zero error, so the plain miss can't tell good rules from bad ones. Squaring makes every miss count as a positive cost. Absolute error |y − f(x)| fixes the sign too, and section 8 shows it leads to a different best rule.
3EPE is the average square (2.9)
One draw gives one square, but the drawn cell is random. ESL scores a rule by the average square over all draws, the expected prediction error:
EPE(f) = E(Y − f(X))2 (2.9)
The E is an expectation, a probability-weighted average: evaluate the quantity in every possible situation, weight each result by how likely that situation is, and add. For our table the situations are the four cells, so E(g(X, Y)) = Σ g(x, y) · Pr(x, y), summed over the cells. Here g is the squared miss. Each cell's contribution is its probability times its squared miss:
| Cell | Pr | Prediction used | Actual y | Miss | Contribution |
|---|---|---|---|---|---|
| x = 0, y = 1 | 0.3 | a | 1 | 1 − a | 0.3(1 − a)² |
| x = 0, y = 3 | 0.1 | a | 3 | 3 − a | 0.1(3 − a)² |
| x = 1, y = 1 | 0.1 | b | 1 | 1 − b | 0.1(1 − b)² |
| x = 1, y = 3 | 0.5 | b | 3 | 3 − b | 0.5(3 − b)² |
Adding the last column gives EPE as a formula in the two dials. It covers every rule you could pick:
EPE(a, b) = 0.3(1 − a)² + 0.1(3 − a)² + 0.1(1 − b)² + 0.5(3 − b)²
Try the rule "predict the most likely y in each row", a = 1 and b = 3. The misses are 0, 2, −2 and 0, and the squares are 0, 4, 4 and 0, so EPE = 0.3·0 + 0.1·4 + 0.1·4 + 0.5·0 = 0.8.
Predict
Now ignore x and predict 2 every time (a = b = 2). What is EPE, and is it better or worse than 0.8?
Answer
Every miss is ±1, so every square is 1: 0.3·1 + 0.1·1 + 0.1·1 + 0.5·1 = 1. That's worse than 0.8, because predicting 2 throws away what x tells you. Notice that the probabilities add to 1, so when every square is the same size, EPE equals that size.
EPE as four weighted squares
Fig. 3.1 · interactiveEPE(a, b) = sum of the four contributions =
Keep two things apart. EPE takes a whole rule and returns one number, so it compares rules to each other. And it's computed over the population, not over a training set. Training error averages over the cases you happened to observe, while EPE averages over every case weighted by how often it occurs.
4From a sum to an integral (2.10)
Real inputs and outputs are continuous, so there's no finite list of cells to add up. ESL writes the same average as an integral:
EPE(f) = ∫ [y − f(x)]2 Pr(dx, dy) (2.10)
To read it, cut the (x, y) plane into tiny rectangles. Pr(dx, dy) is the probability that a case lands in the tiny rectangle at (x, y). It plays the role of a cell probability. [y − f(x)]2 is that rectangle's squared miss, and ∫ adds the products over the whole plane, just like the sum in section 3. When the distribution has a density p(x, y), Pr(dx, dy) = p(x, y) dx dy. ESL uses the Pr(dx, dy) notation because it also covers discrete tables like ours, where there is no density and the integral becomes the four-cell sum.
So (2.9) and (2.10) are one quantity. (2.9) is the shorthand, and (2.10) unpacks what the E means.
The same average, computed two ways on a continuous population
Fig. 4.1 · interactiveAverage square over all 600 points (2.9): Sum of weighted cells (2.10):
Explain
In (2.10), which factor plays the role of "0.3" in the term 0.3(1 − a)² from section 3, and which factor plays the role of "(1 − a)²"?
Answer
Pr(dx, dy) plays the role of 0.3: it's how likely the case is. [y − f(x)]2 plays the role of (1 − a)²: it's the squared miss for that case, with y = 1 and f(0) = a. The integral sign replaces the + signs between the four terms.
5Splitting a cell's probability (the footnote)
Before you start
Without looking back: what is Pr(X = 1) for the running table, and how do you get it?
Answer
0.6, by adding along the x = 1 row: 0.1 + 0.5. If that wasn't quick, reread the end of section 1, because this section divides by those row totals.
Suppose you're told the case has x = 1. The top row can't happen any more, and the probabilities left in the bottom row, 0.1 and 0.5, add to only 0.6. Dividing them by 0.6 rescales the row so it adds to 1 again, and the result is the distribution of Y once you know x. That's conditional probability:
Pr(y | x) = Pr(x, y) / Pr(x)
The bar "|" reads "given". Doing the division for every cell:
| Row | Pr(y = 1 | x) | Pr(y = 3 | x) | Sum |
|---|---|---|---|
| x = 0 (total 0.4) | 0.3 / 0.4 = 0.75 | 0.1 / 0.4 = 0.25 | 1 |
| x = 1 (total 0.6) | 0.1 / 0.6 ≈ 0.167 | 0.5 / 0.6 ≈ 0.833 | 1 |
Multiply both sides of the definition by Pr(x) and you get the factorization in ESL's footnote:
Pr(x, y) = Pr(y | x) · Pr(x)
Check it on the bottom-right cell: 0.833 × 0.6 = 0.5. In words, the chance of landing in a cell is the chance of landing in its row times the chance of that y within the row. This is just a different way of writing each cell's probability. Nothing has been computed yet, but section 6 uses exactly this split.
Find the mistake
Someone computes "Pr(y = 3 | x = 0)" as 0.1 / 0.6, dividing by the total of the y = 3 column. What did they compute instead, and why is it a different quantity?
Answer
Dividing by the column total gives Pr(x = 0 | y = 3) ≈ 0.167: among cases with y = 3, how many have x = 0. The condition decides which slice you rescale. Given x = 0 you rescale the top row, so the answer is 0.1 / 0.4 = 0.25. Prediction always conditions on x, because x is what you know when you predict.
6Regrouping the sum by x (2.11)
ESL now rewrites EPE as
EPE(f) = EX EY|X([Y − f(X)]2 | X) (2.11)
Read it from the inside out. The inner EY|X(… | X) holds X fixed and averages the squared miss over the Y values that can occur with it, using Pr(y | x) as weights. That gives one number per x. The outer EX averages those numbers over x, using Pr(x) as weights. The value is the same as (2.9). Only the order of adding has changed.
Why regroup at all. The goal is to choose the dials a and b that make EPE smallest. The obstacle is that the direct sum lists all four cells side by side, which hides what each dial is responsible for.
The cue is in the table from section 3: every term contains exactly one dial, and which dial it is depends only on the term's x. So the useful move is to collect the terms by x. Each group should then hold one dial together with every term that dial affects.
The same four terms, grouped two ways
Fig. 6.1 · interactiveHere's the regrouping done step by step for the discrete table. The right-hand column of each step carries the "most likely y" rule, a = 1 and b = 3, along to show that the number doesn't change.
- Start from the direct sum (2.10). One term per cell, squared miss times cell probability.
EPE = Σx Σy [y − f(x)]² · Pr(x, y)
For our rule, that's the 0.8 from section 3. - Split each cell probability with the footnote. Section 5 showed Pr(x, y) = Pr(y | x) · Pr(x). Substituting changes how each term is written, not its value.
EPE = Σx Σy [y − f(x)]² · Pr(y | x) · Pr(x)
- Pull Pr(x) out of the inner sum. The inner sum runs over y with x held fixed, so Pr(x) is the same number in every one of its terms, and a common factor can move outside a sum (0.4·1.5 + 0.4·2 = 0.4·(1.5 + 2)).
EPE = Σx Pr(x) · [ Σy [y − f(x)]² · Pr(y | x) ]
- Recognize the bracket as an expectation over Y given x. It's a weighted average of the squared miss with weights Pr(y | x), which add to 1 within the row, so it's EY|X([Y − f(X)]² | X = x). For our rule: row 0 gives 0.75·0 + 0.25·4 = 1, and row 1 gives 0.167·4 + 0.833·0 ≈ 0.667.
- Recognize the outer sum as an expectation over X. What's left is a weighted average of the row results with weights Pr(x), which is EX of the bracket. That's (2.11). For our rule: 0.4·1 + 0.6·0.667 = 0.8, the same value as step 1.
The general fact behind these steps is the law of total expectation, also called the tower rule or Adam's law: E(Z) = EX(E(Z | X)). The overall average equals the average of the per-group averages, each weighted by how common its group is. For continuous variables the same steps use the density: p(x, y) = p(y | x) p(x), and the integral is evaluated over y first, inside an integral over x. Changing the order of integration like that is allowed here because the squared miss is never negative (Tonelli's theorem).
Inner averages per strip, then a weighted outer average
Fig. 6.2 · interactive(2.9) average over all dots: (2.11) Σ w × strip average:
Find the mistake
Someone writes EPE = Σx Σy [y − f(x)]² · Pr(y | x), leaving Pr(x) out. What does that compute for a = 1, b = 3, and what's wrong with it?
Answer
It adds the row results without weights: 1 + 0.667 ≈ 1.667. That isn't an average, and it treats both rows as equally important even though row 1 occurs 60% of the time. Halving it to 0.833 still gives each row equal weight. Only the Pr(x) weights bring back the correct 0.8.
7Minimizing one row at a time (2.12)
Group the EPE formula from section 3 by row, as section 6 suggested:
EPE(a, b) = [0.3(1 − a)² + 0.1(3 − a)²] + [0.1(1 − b)² + 0.5(3 − b)²] = A(a) + B(b)
A contains only dial a and B contains only dial b. Think of them as two bills paid separately: turning a changes A and leaves B exactly where it was. Here's A at a few values:
| a | 0.3(1 − a)² | 0.1(3 − a)² | A(a) | B |
|---|---|---|---|---|
| 1 | 0.3·0 = 0 | 0.1·4 = 0.4 | 0.4 | unchanged |
| 1.5 | 0.3·0.25 = 0.075 | 0.1·2.25 = 0.225 | 0.3 | unchanged |
| 2 | 0.3·1 = 0.3 | 0.1·1 = 0.1 | 0.4 | unchanged |
The middle row, 0.3·0.25 + 0.1·2.25 = 0.3, is the smallest of the three. Since no term contains both dials, there's no trade-off to manage: the smallest possible total is the smallest A plus the smallest B. You can find the best a using only row 0 and the best b using only row 1.
Now connect this to (2.11). Each bill is that row's weight times its inner average: A(a) = 0.4 × [0.75(1 − a)² + 0.25(3 − a)²], since 0.4 × 0.75 = 0.3 and 0.4 × 0.25 = 0.1. The weight 0.4 is positive and doesn't contain a, so it scales the bill without moving its lowest point. So minimizing the bill means minimizing the inner average alone. ESL writes that for every x at once:
f(x) = argminc EY|X([Y − c]2 | X = x) (2.12)
Predict
Start from a = 1.5, b = 3. Move only a to 2. By how much does EPE change, and which bill changed?
Answer
Only A changes, from 0.3 to 0.4 (the table above), so EPE rises by 0.1. B doesn't contain a, so it stays at 0.1(1 − 3)² + 0.5·0 = 0.4. If you expected both bills to move, look at which dial each term contains.
argminc means "the value of c that makes the expression smallest", so the answer is the location of the minimum, not the minimum value itself. The c stands for the one number you'll predict at this x. It's a plain constant here because x is fixed. "Minimize pointwise" means solving this small problem separately at each x.
Two separate bills, and what happens when the dials are tied
Fig. 7.1 · interactiveA(a) = B(b) = EPE = A + B =
That last observation is the boundary of the whole argument. Pointwise minimization works only because f may take any value at each x. Tie the dials, so the rule must predict one constant c everywhere, and every term contains c. Moving c toward 1 helps the y = 1 cells and hurts the y = 3 cells, so you're forced into a compromise. Setting the slope of the total to zero (section 8 explains this move) gives 0.3(1 − c) + 0.1(3 − c) + 0.1(1 − c) + 0.5(3 − c) = 0, that is, 2.2 − c = 0, so c = 2.2, and EPE(2.2) = 0.96. With free dials, best EPE = 0.633. A straight line f(x) = β0 + β1x also ties the predictions at different x together through two shared numbers. That's why (2.13) is called the ideal: it's the answer when nothing ties the predictions together, and linear regression and nearest neighbours are two ways of approximating it from data.
8The best prediction is the row mean (2.13)
We still need the actual minimizer of each row's U-shaped bill. At the bottom of a U the curve is flat, so its slope (derivative) is zero. On the left the slope is negative, and on the right it's positive.
Why use the slope. The goal is the exact c at the bottom. Trying values in a table, as in section 7, only brackets it. The cue is that the bill is a sum of squares in c, so its derivative is a simple linear expression. Setting the derivative to zero should give an equation with exactly one solution.
The derivative of k(y − c)² with respect to c is −2k(y − c). For row 0, setting the slope of A to zero and dividing by −2 gives
0.3(1 − a) + 0.1(3 − a) = 0 → 0.3 − 0.3a + 0.3 − 0.1a = 0 → 0.6 = 0.4a, so a = 1.5
and for row 1, 0.1(1 − b) + 0.5(3 − b) = 0 gives 1.6 = 0.6b, so b ≈ 2.667. Look at what the answers are: 1.5 = (0.3·1 + 0.1·3) / 0.4 is the average y in row 0, weighted by Pr(y | x = 0), and 2.667 is the same thing for row 1. The best prediction in each row is that row's mean. In general, with weights Pr(y | x):
d/dc E([Y − c]2 | X = x) = −2 (E(Y | X = x) − c) = 0 ⇒ f(x) = E(Y | X = x) (2.13)
ESL calls E(Y | X = x) the regression function: at every x, the best guess under squared error is the conditional mean.
A second route needs no calculus and shows what's left over. Write μ for the row mean E(Y | x) and split each miss into two pieces, Y − c = (Y − μ) + (μ − c). Squaring gives (Y − μ)² + 2(Y − μ)(μ − c) + (μ − c)². Now average over the row. The middle term averages to zero, because the deviations Y − μ from a mean average to zero and (μ − c) is a constant. What's left is
E[(Y − c)² | x] = Var(Y | x) + (μ − c)²
That's the row's spread plus a penalty for missing the mean. For row 0 the spread is 0.75·(1 − 1.5)² + 0.25·(3 − 1.5)² = 0.75, so row 0's inner average is 0.75 + (1.5 − c)². The second part is a square, so it's never negative, and it's zero only at c = 1.5. The first part doesn't depend on c: it's noise that no prediction can remove. Weighting both rows' leftover spreads by Pr(x) gives the 0.633 floor from section 7.
Try it
Change only row 0 so that y = 1 and y = 3 are equally likely given x = 0. What is the best a, and what is row 0's leftover inner average at that a?
Answer
The row mean is 0.5·1 + 0.5·3 = 2, so a = 2. Both misses are then ±1, so the inner average is 0.5·1 + 0.5·1 = 1, which is the spread of that row. Picking the more likely value doesn't help here, because neither value is more likely, and any c other than 2 adds (2 − c)² on top.
The answer depends on the loss. With absolute error |Y − c|, the same pointwise argument gives the conditional median instead of the mean (ESL eq. 2.18, a page later). In row 0, the median is 1, because 75% of the row's probability sits at y = 1. Squared error pulls the prediction toward the rarer 3, because a miss of 2 costs 4 under squaring.
Choose a move
A third row has Y ∈ {0, 2, 10} with conditional probabilities 0.5, 0.3, 0.2. You need the single prediction for this row that minimizes the expected squared error. Which quantity do you compute, and why don't you need any other row?
Answer
Compute the row's conditional mean: 0.5·0 + 0.3·2 + 0.2·10 = 2.6. Other rows don't matter, because after grouping by x (2.11), this row's prediction appears only in this row's term, and the row's weight Pr(x) can't move the minimizer (2.12). The most likely value, 0, is a tempting wrong answer: its expected squared error is 0.3·4 + 0.2·100 = 21.2, against 14.44 at the mean, because the rare 10 costs 100 when you predict 0.
9Your turn: the whole procedure on a new table
Here's a new population. X is still 0 or 1, but Y is now 0 or 4:
| y = 0 | y = 4 | |
|---|---|---|
| x = 0 | 0.2 | 0.2 |
| x = 1 | 0.1 | 0.5 |
The first step is done for you: add the top row, 0.2 + 0.2, so Pr(X = 0) = 0.4. Each step after that leaves more for you to do.
Step 1 · one missing value
What is Pr(X = 1)?
Answer
Add the bottom row, 0.1 + 0.5, so Pr(X = 1) = 0.6. As a check, the two row totals add to 1 (section 1).
Step 2 · the best prediction in each row
Row 0's conditional probabilities are 0.2 / 0.4 = 0.5 and 0.5. Find the best a. Then find row 1's conditional probabilities yourself, and from them the best b.
Answer
The row-0 mean = 2 (0.5·0 + 0.5·4), so a = 2. For row 1, divide by 0.6: 0.1 / 0.6 ≈ 0.167 and 0.5 / 0.6 ≈ 0.833, so the row-1 mean ≈ 3.333 (0.833·4), and b ≈ 3.333. These are (2.13) applied one row at a time (sections 5 and 8).
Step 3 · the whole procedure
What is the smallest EPE any rule can reach on this table? Use the two-stage form (2.11): an inner average per row at its best prediction, then the outer weights.
Answer
Row 0 at a = 2: both misses are ±2, so the inner average is 0.5·4 + 0.5·4 = 4. Row 1 at b ≈ 3.333: 0.167·3.333² + 0.833·0.667² ≈ 1.852 + 0.370 = 2.222. The outer average is 0.4·4 + 0.6·2.222, so best EPE ≈ 2.933. This is all leftover spread: no rule can go lower (section 8).
Step 4 · tie the dials
Now force one constant c for both rows. Which c is best, what EPE does it give, and why is it worse than step 3?
Answer
With one dial, the best value is the overall mean of Y: Pr(y = 4) = 0.2 + 0.5 = 0.7, so constant c = 2.8. Its EPE is 0.3·2.8² + 0.7·1.2² = 2.352 + 1.008, so constant EPE = 3.36. That's worse than 2.933, because one number has to serve two rows with different means (section 7).
10Check yourself without looking back
Try these from memory before opening the answers. Each answer names the section that teaches it.
Question 1
A row has Y = 2 with probability 0.25 and Y = 6 with probability 0.75, given its x. What should the rule predict there under squared error?
Answer
The conditional mean, 0.25·2 + 0.75·6 = 5. It's not 6, the more likely value, because squared error punishes the miss on the 2s heavily (section 8).
Question 2
Does EPE average over the training set? If not, over what?
Answer
No. It averages over the whole population, every (x, y) weighted by its true probability. A training set is one finite sample from that population (sections 1 and 3).
Question 3
Grouping the terms by y gives the same EPE. Why doesn't ESL group by y?
Answer
Each y-group contains predictions for several x values, so every dial appears in every group and nothing can be minimized on its own. Grouping by x puts each dial with exactly the terms it affects, and it matches prediction time, when x is known and y isn't (section 6).
Question 4
In Pr(x, y) = Pr(y | x) · Pr(x), which factor adds to 1 across a row, and which adds to 1 across rows?
Answer
Pr(y | x) adds to 1 within each row, because it's the row rescaled. Pr(x) adds to 1 across the rows, because it's the row totals (section 5).
Question 5
Why can the weight Pr(x) be dropped when finding the best prediction at x in (2.12)?
Answer
It's a positive number that doesn't contain the prediction c, so it scales that row's bill without moving the bill's lowest point (section 7).
Question 6
Your rule must be a straight line in x. Can you still minimize EPE separately at each x?
Answer
No. The line's two numbers, intercept and slope, set the prediction at every x, so the rows are tied together and you have to trade them off. Pointwise minimization needs a free prediction at each x (section 7).
Question 7
In (2.10), what does Pr(dx, dy) stand for, and what does it become for a four-cell table?
Answer
It's the probability of a tiny rectangle around (x, y), which equals p(x, y) dx dy when a density exists. For a table, it becomes the cell probabilities, and the integral becomes a four-term sum (section 4).
Question 8
Even the true regression function has EPE above zero in figure 4.1. Where does the leftover come from?
Answer
From the spread of Y at each fixed x, Var(Y | x). The mean only removes the (mean − c)² part, and no rule that sees only x can remove the spread (sections 4 and 8).
11Review cards
Revisit these after a day, a week, and a month. Each one makes sense without this page open.
What does EPE(f) = E(Y − f(X))² measure?
The average squared miss of the rule f over the whole population of (X, Y) pairs, each weighted by its probability.
How does (2.10) relate to (2.9)?
It's the same quantity with the expectation written out as an integral: squared miss times Pr(dx, dy), added over the whole (x, y) plane.
What is Pr(y | x) for a discrete joint table?
The cell probability divided by its row total, Pr(x, y) / Pr(x), so each row adds to 1.
What does the footnote's factorization Pr(X, Y) = Pr(Y | X) Pr(X) let you do with the EPE integral?
Split it into an inner average over Y at fixed x, inside an outer average over x. That's (2.11).
What is the law of total expectation?
E(Z) = E_X(E(Z | X)): the overall average equals the average of the per-group averages, each weighted by how common its group is.
Why can EPE be minimized pointwise (one x at a time)?
After grouping by x, each prediction f(x) appears only in its own x's term, and that term's weight Pr(x) can't move its minimizer.
What does argmin_c mean in (2.12)?
The value of c that makes the expression smallest, the location of the minimum rather than the minimum value.
Under squared error, what is the best prediction at X = x?
The conditional mean E(Y | X = x), which ESL calls the regression function.
Under absolute error, what is the best prediction at X = x?
The conditional median of Y given X = x.
When does pointwise minimization break?
When the rule's predictions at different x share parameters, as in a constant or a straight line, so changing one prediction changes others.
What part of the expected squared error can no rule remove?
The spread of Y at each fixed x, Var(Y | X = x), weighted by Pr(x).
What does EPE(f) = E(Y − f(X))² measure?::The average squared miss of rule f over the whole population of (X, Y) pairs, each weighted by its probability. How does ESL eq. 2.10 relate to 2.9?::Same quantity; the expectation written as an integral of squared miss times Pr(dx, dy) over the (x, y) plane. What is Pr(y | x) for a discrete joint table?::The cell probability divided by its row total, Pr(x, y) / Pr(x), so each row adds to 1. What does the factorization Pr(X, Y) = Pr(Y | X) Pr(X) let you do with the EPE integral?::Split it into an inner average over Y at fixed x inside an outer average over x (ESL eq. 2.11). What is the law of total expectation?::E(Z) = E_X(E(Z | X)): the overall average equals the weighted average of per-group averages. Why can EPE be minimized pointwise?::After grouping by x, each prediction f(x) appears only in its own term, and the weight Pr(x) cannot move that term's minimizer. What does argmin_c mean in ESL eq. 2.12?::The value of c that makes the expression smallest (the location of the minimum, not the minimum value). Under squared error, what is the best prediction at X = x?::The conditional mean E(Y | X = x), the regression function. Under absolute error, what is the best prediction at X = x?::The conditional median of Y given X = x. When does pointwise minimization break?::When predictions at different x share parameters (a constant or a straight line), so they cannot be set independently. What part of expected squared error can no rule remove?::The spread Var(Y | X = x) at each x, weighted by Pr(x).
Checked on 2026-10-21 with Python 3.13 (standard library only) by verify_lesson.py: 34 checks passed.
Sources
- Hastie, Tibshirani and Friedman, The Elements of Statistical Learning, 2nd edition (2009; corrected 12th printing, 2017), section 2.4, equations 2.9 to 2.13, the footnote on conditioning, and eq. 2.18 for the median under absolute error.
- Law of total expectation (Wikipedia): the statement E(X) = E(E(X | Y)) and its other names (tower rule, Adam's law, law of iterated expectations).
- Fubini's theorem (Wikipedia), section on Tonelli's theorem: for a non-negative integrand, the order of integration can be swapped.
- Every worked number was recomputed by
verify_lesson.pynext to this page, which also checks that the row means minimize EPE over a grid of dial values and that the two-stage average equals the direct sum.