How $\frac{1}{n}\sum_{i=1}^n X_i^2 - \bar X^2 = \frac{\sum_{i=1}^n (X_i - \bar X)^2}{n}$ How 
$\frac{1}{n}\sum_{i=1}^n X_i^2 - \bar X^2 = \frac{\sum_{i=1}^n (X_i - \bar X)^2}{n}$ 
i have tried to do that by the following procedure:
$\frac{1}{n}\sum_{i=1}^n X_i^2 - \bar X^2$
=$\frac{1}{n}(\sum_{i=1}^n X_i^2 - n\bar X^2)$
=$\frac{1}{n}(\sum_{i=1}^n X_i^2 - \sum_{i=1}^n\bar X^2)$
=$\frac{1}{n} \sum_{i=1}^n (X_i^2 - \bar X^2)$
Then i have stumbled.

I think it is cleaner to expand the right-hand side. We have
$$(X_i-\bar{X})^2=X_i^2-2X_i\bar{X}+(\bar{X})^2.$$
Sum over all $i$, noting that $2\sum X_i\bar{X}=2n\bar{X}\bar{X}=2n(\bar{X})^2$ and $\sum (\bar{X})^2=n(\bar{X})^2$. 
There is some cancellation. Now divide by $n$ and we get the left-hand side. 
