# How to derive this version of variance formula

A probably very easy computational question, but I don't really understand how it's done:

I try to compute the point estimates of a normal distribution as $N \sim (\beta, \sigma)$. Using the method of moments, we get:

$$\frac{1}{n} \sum_{i=1}^{n} X_{i} = \hat{\beta}$$

$$\frac{1}{n} \sum_{i=1}^{n} X_{i}^{2} = \hat{\sigma}^2 + \hat{\beta}^2$$

Solving the two equations for the two parameters, we get:

$$\hat{\beta} = \overline{X}$$

and

$$\hat{\sigma}^2 = \frac{1}{n} \sum_{i=1}^{n} (X_{i} - \overline{X}_n)^2$$

My question is: How do we get to the term of $\hat{\sigma}^2$? If I try to compute it, I get:

$$\hat{\sigma}^2 = \frac{1}{n} \sum_{i=1}^{n} X_{i}^2 - (\frac{1}{n} \sum_{i=1}^{n} X_{i} )^2$$

Can someone show me how to simplify the last term to what is stated above and what "rule" or law" is used there? Since it is used so often, I really wanna understand this.

• I was certain this had been answered several times already but I can't seem to turn one up in spite of trying a host of searches. – Glen_b -Reinstate Monica Jan 14 '17 at 7:10

Let $\overline{X} = \frac{1}{n} \sum_{i=1}^n X_i$. \begin{align*} \sum_{i=1}^n (X_i - \overline{X})^2 &= \sum_{i=1}^n \left( X_i^2 - 2 X_i \overline{X} + \overline{X}^2 \right) \\ &= \sum_{i=1}^n X_i^2 -2 \overline{X}\sum_{i=1}^n X_i + \sum_{i=1}^n \overline{X}^2 \\ &= \sum_{i=1}^n X_i^2 -2 \overline{X}(n \overline{X}) + n \overline{X}^2 \\ &= \left( \sum_{i=1}^n X_i^2 \right) - n \overline{X}^2 \end{align*} Then you have $\frac{1}{n} \sum_{i=1}^n (X_i - \overline{X})^2 = \frac{1}{n} \left( \left( \sum_{i=1}^n X_i^2 \right) - n \overline{X}^2\right) = \frac{1}{n}\left( \sum_{i=1}^n X_i^2 \right)- \overline{X}^2$.