What is the expectation of $(\langle x, w \rangle - \langle y, w \rangle)^2$, where $x,y,w$ are independent Bernoulli random vectors? I'm stuck on the following problem.
Consider three independent Bernoulli random vectors $x,y,w$ of length $n$, where each entry follows the Bernoulli distribution $B$ with $P(B=0)=P(B=1)=\frac{1}{2}$.
$\langle  x,w \rangle$ denotes the standard scalar product and, in this case, just counts the number of positions i = 1,...,n, where both entries are 1.
Let $X := \langle  x,w \rangle$ and $Y := \langle  y,w \rangle$.
Clearly, $\mathbb{E}(X) = \mathbb{E}(Y) = \frac{n}{4}$.
Now, I'm interested in the random variable $Z := (X-Y)^2$ and in particular in the value of $\mathbb{E}(Z)$ as a function of $n$.
I have trouble evaluating this, because $X$ and $Y$ are not independent. I have tried to condition on $w$ and using the normal approximation of the binomial distribution, but didn't get anywhere.
 A: You can compute it as follows. Note first that $X= \sum_{i=1}^n x_iw_i$, therefore $x_iw_i$'s are Bernoulli$(1/4)$ and you said in the comment that they are independent therefore $X$ is binomial$(n,1/4)$. Same for $Y$. Now you can compute $\mathbb{E}(X^2)$ and $\mathbb{E}(Y^2)$, right?
For $\mathbb{E}(XY)$,
$$
\mathbb{E}(XY) = \mathbb{E}(\sum_{i=1}^{n}x_iw_i\sum_{j=1}^{n}y_iw_i) = \mathbb{E}(\sum_{i=1}^nx_iw_i^2y_i + \sum_{i\neq j} x_iw_i y_jw_j)
$$
$$
=\sum_{i=1}^n\mathbb{E}(x_i)\mathbb{E}(w_i^2)\mathbb{E}(y_i) + \sum_{i\neq j} \mathbb{E}(x_i)\mathbb{E}(w_i) \mathbb{E}(y_j)\mathbb{E}(w_j)
$$
Now plug-in the expectations of the Bernoulli random variable.
A: When $n=1$ the expectation is $\frac14$ as there are $8$ equally likely combinations, two of which give $1$ and the other six give $0$
For $n>1$ each index's contribution is independent of the others, as the expectation of the difference is $0$ and they are identically distributed, and there are $n$ values of the index. So this is like adding variances.
So the overall expectation is $\dfrac n4$.
