# Squared Expected Value calculations

In a book i found the average of the squared expected value of difference between two random variables, but i'm not able to understand what calculations produced this series of equivalences, can you show me ?

$E(Y-\bar{Y})^{2}=E[f(X)+\varepsilon -\bar{f}(X))]^{2}=[f(X) -\bar{f}(X))]^{2}+Var(\varepsilon)$

ps: i know what an expected value is

• What are $Y,\overline Y,X,f,\epsilon$? Ordinarily one might expect the expectation to be a number, no? Here you appear to have it be an expression in random variables. Of course, absent all the definitions, it is hard to say much. – lulu Jun 27 '18 at 13:30

You can write $$E[f(X)+\varepsilon -\bar{f}(X))]^{2}=E\left[(f(X)-\bar{f}(X))^2 + 2\varepsilon(f(X)-\bar{f}(X)) + \varepsilon^2\right]$$ Now, they use that the expectation of $\varepsilon$ equals $0$ and they use that $f(X)$ and $\bar{f}(X)$ are determinstic.