I have a problem that follows like this: Let a particle start at the origin $X = 0$, and make a sequence of steps, each of length $d$, moving right with probability $p$, and left with $1-p$. Derivate the equations for the mean position $\langle X\rangle$ and the mean squared position $\langle X^2\rangle$ after $N$ steps.
The solutions are: $\langle X\rangle = N d (2 p - 1)$;
$\langle X^2\rangle = (N d)^2 (2 p - 1)^2 + 4 N d^2 p (1 - p)$
I was able to calculate $\langle X\rangle$ by taking the difference of the expected values of going to the right or to the left:
$\langle X\rangle = E[R-L] = E[R] - E[L]$; using the mean value of a Binomial random variable:
$\langle X\rangle = N d p - N d (1-p)$;
$\langle X\rangle = N d (2p-1)$
I performed a similar calculation for $\langle X^2\rangle$:
$\langle X^2\rangle = E[(R-L)^2] = E[R^2] - 2 E[R] E[L] + E[L^2]$
After solving for the expected value of $E[x^2]$ I got that $E[R^2] = d^2 n (n-1) p^2 + n p d^2$, and $E[L^2] = d^2 n (n-1) (1-p)^2 + n (1-p) d^2$.
Substituting these values in the previous equation I found that $\langle X^2\rangle = (Nd)^2 (2 p-1)^2 + 2 Nd^2 p (1-2 p)$, which is the wrong solution.
Could anyone please help me out figure where I'm getting the problem wrong? Thanks a lot in advance!
EDIT: I haven't managed to solve this using the approach above yet, but one possible solution is to use the fact that the variance of the entire population of steps $X$ should be equal to $N$ times the variance of a single step:
$Var(X) = NVar(x_1)$
$\langle X^2\rangle - \langle X\rangle^2 = N(\langle x_1^2\rangle - \langle x_1\rangle^2)$
$\langle X^2\rangle = \langle X\rangle^2 + N(\langle x_1^2\rangle - \langle x_1\rangle^2)$
$\langle X^2\rangle = (Nd(2p-1))^2 + N((d^2p +(-d)^2(1-p)) - (dp-d(1-p))^2)$
And simplifying this equation gives us:
$\langle X^2\rangle = (Nd)^2(2p-1)^2 + 4Nd^2p(1-p)$
Which is the correct solution. Although this works, I'd really appreciate if someone could give me an input on how to solve this by calculating the expected value of the Binomial distributions for $X^2$.