Simple random walk on the integer line (source code)

= Simple random walk on the integer line

If the independent increments are $+1$ with probability $p$ and $-1$ with probability $q=1-p$, then
$$
S_n=2B_n-n,
\qquad B_n\sim\operatorname{Binomial}(n,p).
$$
Thus $\mathbb ES_n=n(p-q)$ and $\operatorname{var}(S_n)=4npq$.