I am following a derivation of the sample variance but they have skipped over some steps. Can anyone explain them? $X_1,...,X_n$ are a random sample.
$$E(S^2)=\frac{1}{n-1}E\left[\sum_{i=1}^n(X_i - \bar{X})^2\right]=\frac{1}{n-1}E\left[\sum[(X_i-\mu)-(\bar{X}-\mu)\right]^2=\cdots $$ $$\cdots =\frac{1}{n-1}E\left[\sum_{i=1}^n[(X_i - \mu)^2-2(X_i-\mu)(\bar{X}-\mu)+(\bar{X}-\mu)^2]\right]$$ I understand the above steps but I cannot follow the next few steps.
$$=\frac{1}{n-1}E\sum_{i=1}^n[(X_i-\mu)^2-2n(\bar{X}-\mu)(\bar{X}-\mu)+n(\bar{X}-\mu)]$$
How does one get the factor of n in for the second term? Then from here I understand the rest of the derivation. It also states that this works for both discrete and continuous distributions with a finite variance. So does that mean if this was to be shown for a continuous distribution then you would follow the same steps but with an integral? Or you would just end up with the same answer?
As discussed in the comments, there appear to be some problems with the formula as written. In particular, it seems that some of the terms which appear to be inside the summation should be outside of it. And there appears to be at least one typo. But, the algebra behind the formulas is clear enough...it's just a matter of writing everything out.
To do a portion of the sum:
$$\sum -2(X_i-\mu)(\bar X-\mu)=\sum \left( -2X_i(\bar X-\mu)+2\mu(\bar X-\mu)\right)=\cdots$$ $$\cdots =-2n\bar X(\bar X-\mu)+2\mu n(\bar X - \mu)=-2n\bar X^2+4n\bar X\mu-2\mu^2n=-2n(\bar X-\mu)^2$$
To stress: that term must now be outside of the sum.
And, as mentioned in the comments, we easily see that $$\sum (\bar X-\mu)^2=n(\bar X-\mu)^2$$ but the formula appears to have lost the square and, again, that term would now be outside the sum.