Expected value of square of distance after $n$ moves I have this question and not too sure where to proceed.
A point starts from the origin and on any move is equally likely to go one unit up, down, left or right, independently of previous moves. Let $X_1, X_2, X_3$ and $X_4$ be random variables giving the number of moves up, down, left and right in a sequence of $n$ moves.
If $D$ is the distance from the origin after $n$ moves, show that $\mathsf{E}(D^2)=n$.
I know that$ D^2=(X1 - X2)^2 + (X3- X4)^2$ and that each of $X1, X2$ will have a probability of $0.25$ but am not sure how to find the expected value of this.
 A: It is easy to know that
$$
X_1 + X_2 + X_3 + X_4 = n
$$
and thus
$$
\mathsf{E}((X_1 + X_2 + X_3 + X_4)^2) = \sum_{i=1}^4 \mathsf{E}(X_i^2) + \sum_{i \neq j} \mathsf{E}(X_iX_j) = n^2 \tag{$\spadesuit$}
$$
Since each $X_i \sim \mathsf{Binomial}(n, 1/4)$, we have $\mathsf{E}(X_i^2)=\frac{3}{16}n + \frac{1}{16}n^2$. Moreover, by symmetry, we have
$$
\mathsf{E}(X_1X_2) = \mathsf{E}(X_1X_3) =\cdots = \mathsf{E}(X_3X_4)
$$
Therefore, by $(\spadesuit)$, we obtain
$$
\mathsf{E}(X_1X_2) = \mathsf{E}(X_1X_3) =\cdots = \mathsf{E}(X_3X_4) = \frac{n^2 - \frac{3}{4}n - \frac{1}{4}n^2}{12} = \frac{1}{16}(n^2 - n)
$$
Finally, we have
$$
\mathsf{E}(D^2) = \sum_{i=1}^4\mathsf{E}(X_i^2) - 2\mathsf{E}(X_1X_2) - 2\mathsf{E}(X_3X_4) = \frac{3}{4}n + \frac{1}{4}n^2 - \frac{1}{4}(n^2 - n) = n
$$
A: Alternative way is to express each of $X_i$ as the sum of indicator r.v.: let $U_i, D_i, L_i, R_i$ equal to $1$ if at the $i$th step particle moves up, down, left and right correspondingly. For all $i$ 
$$U_i+ D_i+ L_i+ R_i = 1, \ U_iD_i=0, \ L_iR_i=0$$
$$X_1=\sum_{i=1}^n U_i, \ X_2=\sum_{i=1}^n D_i, \ X_3=\sum_{i=1}^n L_i, \ X_4=\sum_{i=1}^n R_i.$$
Calculate the expected value of $D^2$:
$$\mathbb ED^2=\mathbb E\left(\sum_{i=1}^n (U_i-D_i)\right)^2+\mathbb E\left(\sum_{i=1}^n (L_i-R_i)\right)^2=2\mathbb E\left(\sum_{i=1}^n (U_i-D_i)\right)^2.$$
Use $\mathbb EX^2=\text{Var} X + (\mathbb EX)^2$:
$$\mathbb ED^2=2 \text{Var}\left(\sum_{i=1}^n (U_i-D_i)\right)+2\left(\mathbb E\sum_{i=1}^n (L_i-R_i)\right)^2=$$
$$\mathbb ED^2=2\left(\sum_{i=1}^n \text{Var}(U_i-D_i)\right)+2\biggl(\sum_{i=1}^n \underbrace{\mathbb E(L_i-R_i)}_{0}\biggr)^2=2n \text{Var}(U_1-D_1)=2n \mathbb E(U_1^2+D_1^2-2\underbrace{U_1D_1}_0)=4n \mathbb EU_1^2=4n \mathbb EU_1=4n\cdot 0.25=n.$$
