Hi, I have quite a simple question but I can't for the life of me figure it out.
If you are given the sample variance as
$ S^2 = \frac{1}{n-1}\sum\limits_{i=1}^{n}(X_i - \bar{X})^2 $
How can you write the following?
$ S^2 = \frac{1}{n-1}[\sum\limits_{i=1}^{n}(X_i - \mu)^2 - n(\mu - \bar{X})^2] $
All texts that cover this just skip the details but I can't work it out myself. I get stuck after expanding like so
$ S^2 = \frac{1}{n-1}\sum\limits_{i=1}^{n}(X_i^2 -2X_i\bar{X} + \bar{X}^2) $
What am I missing?

