I have a biased coin with the probability of flipping heads as $p$. I have a room of $n$ people and they each have this same coin. I ask everybody to flip their coins, and record their results as an $n$-dimensional vector of ones (heads) and zeros (tails) like [1 0 0 1 0 ...]
I do this many times, and I measure the average squared euclidean distance between any two n-dimensional vectors.
The result seems to be that on average, the squared euclidean distance between any of these two vectors is:
$2np(1-p)$
Why is this the case? This looks to me like twice the variance of a binomial distribution, but I have no idea why or how to derive that...
Context: I'm trying to understand a paper on a theoretical model of brain activity http://dx.doi.org/10.1016/j.neuron.2014.07.035 and I simplified the problem to coin flips for ease of explanation. :) I ran some simulations on the coin flip problem and it seems to check out.
Let $X_1,\ldots,X_n,Y_1,\ldots,Y_n$ be i.i.d random variables with Bernoulli distribution with parameter $p$. Then \begin{align*} \mathbb{E} \left[\sum_{i=1}^n (X_i - Y_i)^2\right] &= \sum_{i=1}^n \mathbb{E} \left[ (X_i - Y_i)^2 \right] \\ &= \sum_{i=1}^n \mathbb{E} \left[ X_i^2 - 2X_iY_i + Y_i^2\right] \\ &= \sum_{i=1}^n \left( \mathbb{E} [ X_i^2 ] - \mathbb E [2X_iY_i] + \mathbb E [Y_i^2]\right) \\ &= \sum_{i=1}^n \left( \mathbb{E} [ X_i] - 2 \mathbb E [X_i] \mathbb E [Y_i] + \mathbb E [Y_i]\right) \\ &= \sum_{i=1}^n \left(p - 2 p^2 + p\right) \\ &= 2np(1-p), \end{align*} where we use the linearity of expectation and that $X_i^2 = X_i$ for Bernoulli distributions.