# How to get this equation from the variance formula？

Let $$X_1,...,X_n$$ be an iid (independent and identically distributed) sample with mean $$\mu$$ and variance $$\sigma^2$$.

How to show $$(n-1)S^2 = \sum_{i=1}^n (Xi-\overline X)^2 = \sum_{i=1}^n (Xi-\mu ) ^2 - n(\mu-\overline X) ^2$$

I found that if I treat $$\mu$$ equals $$\overline X$$ , it would do. But I don't think that's right.

• Expand $X_i-\overline X=X_i-\mu+\mu-\overline X$. – Yves Daoust Apr 22 at 10:05
• @YvesDaoust I have to expand the first X_i-$\overline X$as X_i-$\mu$+$\mu$-$\overline X$ and the second X_i-$\overline X$ as X_i-$\mu$-$\mu$+$\overline X$to get there. – gong.y Apr 22 at 10:29
• What ? What do you mean by first and second ? – Yves Daoust Apr 22 at 10:30
• @YvesDaoust (X_i-$\overline X$)^2 has two X_i-$\overline X$ . – gong.y Apr 22 at 10:32

## 1 Answer

Let $$Y_i:=X_i-\mu$$. We have $$\overline Y=\overline X-\mu$$.

Then

$$\sum_i(Y_i-\overline Y)^2=\sum_iY_i^2-2\overline Y\sum_i Y+n\overline Y^2=\sum_iY_i^2-n\overline Y^2.$$