# How do I prove that $\sum \limits_{i=1}^n{p_i\left(x_i-\bar{x}\right)^2} = \frac{1}{2} \sum \limits_{i, j=1}^n {p_ip_j\left(x_i-x_j\right)}^2$?

How can I show if $\displaystyle\bar{x}=\sum_{i=1}^n{x_ip_i}$ , then

$$\sum_{i=1}^n{p_i\left(x_i-\bar{x}\right)^2}=\frac{1}{2}\sum_{i=1}^n\sum_{j=1}^n{p_ip_j\left(x_i-x_j\right)}^2$$

is true?

(This claim is from page 96 of the book, "Cauchy-Schwarz Master Class".)

-
I've tagged this inequality, since this is a part of a longer proof, which includes Jensen in several places. If you can think of better tags, feel free to retag. – Martin Sleziak Dec 14 '11 at 8:28

The first way that comes to mind is to show that both are equal to $\displaystyle \left(\sum_{i=1}^n p_ix_i^2\right)-\bar x^2$ by multiplying out and performing the sums where possible.
This is an instance of a more general identity. Let $X$ be some random variable, and $X_1,X_2$ two independent copies of it. Then $$V[X] = \frac{1}{2}E[(X_1-X_2)^2].$$ This can be seen in many ways. For example, \begin{align*} E[(X_1-X_2)^2] &= E[((X_1-E[X])-(X_2-E[X]))^2] \\ &= E[(X_1-E[X])^2] + E[(X_2-E[x])^2] + 2E[X_1-E[X]]E[X_2-E[X]] \\ &= 2V[X]. \end{align*}