# Mathematical properties/steps involved in expansion of expected value equation

Recently I have been reading through the Lecture-One course material that can be found at this link.

Anyways, in section-2 the author shows the following step in his derivation of an optimal guess by minimizing the function MSE(a): where Y is a random variable and a is the prediction we are to make.

My question is: What is the properties/steps the author takes from making this jump. Specially, how is this step true?

The rest of the derivation is straightforward but I am finding this step hard to see and through all the literature I am parsing through, I am not finding anything that exactly works.

Thanks, MS

• It's explained in equation (19) and the following paragraph. – Mark L. Stone May 15 '17 at 19:41
• This is the Pythagorean Theorem. It becomes perfectly obvious when you consider the random variable $X=Y-a$, for then it merely asserts $$E(X^2)=E(X)^2+\operatorname{Var}(X).$$Subtract $E(X)^2$ from both sides to recognize the very definition of variance. – whuber May 15 '17 at 20:05

$$E[(Y-a)^2] = E[(Y-E(Y) +E(Y)-a)^2] \\ =E[(Y-E(Y))^2] +2E[(Y-E(Y))(E(Y)-a)] + [E(Y)-a]^2\\ = Var(Y) + 2[E(Y)-E(Y)][E(Y)-a] + [E(Y)-a]^2\\ = Var[Y-a] + (E[Y-a])^2$$
• The key step is the middle term $E(Y)-E(Y) = 0$. Generally, people do not recognize it. – user158565 May 16 '17 at 16:49