Variance decomposition over pairs of elements how can I prove that (if it is correct) ?
$\sum_{u,v \in P \times P} \frac{|u-v|^2}{N^2} = 2 \cdot Var(P)$
where $N$ is the number of elements of $P$. $P$ is a list of numbers.
 A: Note that 
$$ \begin{align}\sum_{u,v \in P \times P} |u-v|^2 &= \sum_{i=1}^N \sum_{j=1}^N (u_i-v_j)^2 \\ &= \sum_{i=1}^N\sum_{j=1}^N \{ (u_i- \bar u)-(v_j- \bar v)\}^2\\&= \sum_{i=1}^N\sum_{j=1}^N\{ (u_i-\bar u)^2+ (v_j-\bar v)^2 -2(u_i-\bar u)(v_j-\bar v)\} \\&= \sum_{i=1}^N\sum_{j=1}^N (u_i-\bar u)^2 + \sum_{i=1}^N\sum_{j=1}^N(v_j-\bar v)^2 -2\sum_{i=1}^N(u_i-\bar u)\sum_{j=1}^N(v_j-\bar v) \\ &= \sum_{j=1}^NNS^2+\sum_{i=1}^NNS^2=2N^2S^2 \end{align}$$
Hence we get $\sum_{u,v \in P \times P} \frac{|u-v|^2}{N^2} = 2.Var(P)$
Just note that since $u,v \in P \times P$ we have $\bar u=\bar v$. Again we know that $\sum_{i=1}^N(u_i-\bar u)=0=\sum_{j=1}^N(v_j-\bar v)$ and $S^2=Var(P)$.
This is a measure of mutual differences and this is known as Gini's Mean Difference.
A: Just write $(u - v)^2 = \left( (u - \mu) - (v - \mu) \right)^2$ and go from there:
$$
\begin{align*}
\frac{1}{N^2} \sum_{\substack{u \in P \\ v \in P}} 
   \left (u - \mu)^2 -2 (u - \mu) (v - \mu) + (v - \mu)^2 \right)
  &= 2 \sigma^2 
      - 2 \frac{1}{N^2} \left(\sum_{u \in P} (u - \mu) \right) \cdot
          \left(\sum_{v \in P} (v - \mu) \right) \\
  &= 2 \sigma^2
\end{align*}
$$
