I'm reading Probability and Statistics with R by Ugarte, Militino, and Arnholt and there's a few questions I have related to variance. They state:
$Var[X] = \sigma^2_X=E[(X-\mu)^2]=E[X^2]-\mu^2$
However, I am not getting this last portion. I am getting:
$E[(X-\mu)^2] = E[X^2-2\mu X +\mu^2] = E[X^2]-2\mu E[X] + \mu^2$
Perhaps my understanding of the definition of $E[X]$ is incorrect but I don't see how they not only managed to get rid of the $-2\mu E[X]$ term altogether but also have a different sign for the $\mu^2$ term. Could someone please explain?
Later in the book they state $Var[aX+b] = a^2Var[X]$. They show a derivation which I understood but they said that in showing this derivation, it is "implicitly" shown that $Var[aX] = a^2Var[X]$ and $Var[b]=0$. However, if $Var[X]=E[(X-\mu)^2]$ then shouldn't $Var[b]=E[(b-μ)^2]=\sum_{x \in X}(b-μ)^2p(x)=(b-\mu)^2$? How would it be $0$?
Maybe I'm not doing these manipulations correctly. Someone please correct me if I am wrong, thanks.
The book must have defined $\mu=E[X]$ earlier.
Therefore,
$$\operatorname{Var}[X]=\operatorname{E}[X^2]-2\mu\operatorname{E}[X]+\mu^2=\operatorname {E}[X^2]-2\mu^2+\mu^2=\operatorname{E}[X^2]-\mu^2.$$
In the second case, we have a constante random variable $X=b$. Therefore, $\operatorname{E}[X]=b=\mu$, then $\operatorname{Var}[b]=0$.