Q: Proving a Sum Identity for Variance Estimator I'm trying to prove the following identity:
for a set of numbers: $$ x_1, ... ,x_n $$
$$\frac{1}{n(n-1)} \sum_{i=1}^n (x_i- \bar x)^2 = \bar x^2 - \frac{1}{n(n-1)} \sum_{i \neq j} x_ix_j $$
but I cant manage to prove it.
I found this identity:
$$ \frac{1}{n(n-1)} \sum_{i=1}^n (x_i- \bar x)^2 = \frac{1}{n(n-1)}((\sum_{i=1}^n x_i^2 ) - n\bar x) $$
but couldnt advance more.
Thanks!

A: Try these to warm up:
What is $\sum x_i$?  Write it out more explicitly using "..."
What is $(\sum x_i)^2$?  Write it out the same way.
Can you split that last sum into the terms $x_ix_j$ where $i=j$ and terms where $i \neq j$?
Can you expand out $\sum (x_i - \bar x)^2$?

A: Note that
$$
\sum_{i=1}^n (x_i-\bar{x})^2=\sum_{i=1}^nx_i^2-n\bar{x}^2,
$$
and
$$
n^2\bar{x}^2=\left(\sum_{i=1}^nx_i\right)^2=\sum_{i=1}^nx_i^2+\sum_{i\ne j}x_ix_j.
$$