I have the following equation in a statistics textbook and cannot see how the right side comes into being.
$$\frac{1}{n} \sum_{i=1}^n x^2_i - \left(\frac{1}{n} \sum_{i=1}^n x_i\right)^2 = \frac{1}{n} \sum_{i=1}^n (x_i-\bar{x_n})^2 $$
I have the following equation in a statistics textbook and cannot see how the right side comes into being.
$$\frac{1}{n} \sum_{i=1}^n x^2_i - \left(\frac{1}{n} \sum_{i=1}^n x_i\right)^2 = \frac{1}{n} \sum_{i=1}^n (x_i-\bar{x_n})^2 $$
$\frac{1}{n} \sum_{i=1}^n x^2_i - (\frac{1}{n} \sum_{i=1}^n x_i)^2= \frac{1}{n} \sum_{i=1}^n (x_i-\bar{x})^2$ (you had dropped the $^2$ at the end)
This is the definition of variance. Usually you start with the equation on the right and show that it is equivalent to what is on the left.
$\frac{1}{n} \sum_{i=1}^n x_i = \bar{x}$
$\frac{1}{n}\sum_{i=1}^n (x_i-\bar{x})^2= \frac{1}{n}\sum_{i=1}^n (x_i^2 -2x_i\bar{x}+\bar{x}^2)$
$\frac{1}{n}\sum_{i=1}^n (x_i^2) - (2\bar{x})\frac{1}{n}\sum_{i=1}^n(x_i) + \bar{x}^2$
$\frac{1}{n}\sum_{i=1}^n (x_i^2) - \bar{x}^2$
I think it should be like:
$1/n \sum {x_i}^2 - (1/n\sum {x_i})^2 = 1/n \sum {x_i}^2 - \bar{x}^2 =1/n \sum ({x_i}^2 - \bar{x}^2$)