4

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.

zyx
  • 35,436
time
  • 1,595

4 Answers4

5

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.

André Nicolas
  • 507,029
4

Expand the square and use that $\sum\limits_{k=1}^nX_k=n\bar{X}$: $$ \begin{align} \frac1n\sum_{k=1}^n(X_k-\bar{X})^2 &=\frac1n\sum_{k=1}^n(X_k^2-2X_k\bar{X}+\bar{X}^2)\\ &=\frac1n\left(\sum_{k=1}^nX_k^2-2n\bar{X}\bar{X}+n\bar{X}^2\right)\\ &=\frac1n\sum_{k=1}^nX_k^2-\bar{X}^2\\ \end{align} $$

robjohn
  • 345,667
2

\begin{align} \sum_{i=1}^n (X_i-\bar X)^2 & = \sum_{i=1}^n (X_i^2-2X_i\bar X + (\bar X)^2) \\[10pt] & = \left(\sum_{i=1}^n (X_i^2)\right) - \left( \sum_{i=1}^n 2X_i \bar X \right) + \left(\sum_{i=1}^n ((\bar X)^2) \right). \end{align}

In the second term, the factor $2\bar X$ does not change as $i$ goes from $1$ to $n$, so it can be pulled out, getting $$ 2\bar X\sum_{i=1}^n X_i. $$ Then we can say that $\displaystyle\sum_{i=1}^n X_i = n\bar X$. The second term is then $2n(\bar X)^2$.

In the third term, the sum is $(\bar X)^2 +\cdots+(\bar X)^2$. This is just $n(\bar X)^2$.

Now we have $$ \left(\sum_{i=1}^n (X_i^2)\right) - 2n(\bar X)^2 + n(\bar X)^2. $$ The last two terms can be collected into one term.

2

Since you tagged it under statistics, note that the LHS is simply $E[X^2] - E[X]^2$, and the RHS is $E[(X-\bar{X})^2]$. Both of these are ways to write Variance of $X$, hence they are equal.

Calvin Lin
  • 68,864
  • This is a good way to think about it. For added clarity, we are applying the identity $\mbox{Var}(X) = E[X^2] - (E[X])^2$ to the distribution that puts probability $\frac 1 n$ on each point in the set ${x_1, x_2, ..., x_n}$, i.e. we are applying the formula we know to the empirical distribution of the data. Another spot where this is a useful idea is in deriving sums of squares formulas with iterated variance. – guy Jun 12 '13 at 15:43
  • @Calvin Lin How $\frac{1}{n}\sum_{i=1}^n (x_i - \bar X)^2=E(X-\mu)^2$? That is, How $\bar X=\mu$? Is that for $E(\bar X)=\mu$? kindly explain. – time Jun 13 '13 at 02:03
  • @tree That is the definition. $\bar{X} = E[X] = \mu$ (just different notations that people use). Note that it is $ E[ (X-\mu)^2]$, and not $\left[ E[X-\mu] \right]^2$. The formula follows by definition of expected value. – Calvin Lin Jun 13 '13 at 02:08
  • @CalvinLin Isn't $\mu=$ population mean and $\bar X =$ sample mean? if so $E(X)=\mu$,no doubt. but $E(X)=\bar X$? – time Jun 13 '13 at 02:12
  • Ah, my bad. I often do not distinguish between the two (because I do not care about population vs sample). Let me edit it slightly to remove talking about $\mu$. – Calvin Lin Jun 13 '13 at 02:15