Simple random walk
The question
A walker tosses a fair coin 100 times, stepping right on heads, left on tails. About how far from the start does it end?
Guess first, then run a thousand walks and see.
- 1 SeeGuess the distance, then run the walks.
- 2 TryLonger walks, and a coin that leans.
- 3 ProveBuild the proof, line by line.
- 4 ApplyEndpoints, diffusion and a roulette wheel.
Before you start · 3 quick checks on a mean, a variance and counting toss sequences, about 3 min
Two ideas before you start
2 ideasA walk adds up coin tosses
Figure: the path of a walk over twelve coin tosses, with a dashed line at its end position. It needs JavaScript.
Sequence A: 7 heads 5 tails S₁₂ = 7 − 5 = 2
Each head moves the walker one step right, drawn as a step up, and each tail one step left, drawn as a step down. After n tosses its position is the number of heads minus the number of tails.
Exact definition
Steps. \(\xi_1, \xi_2, \dots\) are independent, and each equals \(+1\) or \(-1\) with probability \(\tfrac{1}{2}\): a fair coin, heads \(+1\) and tails \(-1\).
The walk. \(S_0 = 0\) and \(S_n = \xi_1 + \dots + \xi_n\) for \(n \ge 1\). The distance from the start after \(n\) steps is \(\lvert S_n\rvert\). The card shows three fixed sequences of 12 tosses, typed in by hand, not drawn at random.
Count the sequences
Figure: bars counting the toss sequences that end at each position, with the count above each bar. It needs JavaScript.
n = 4: 2⁴ = 16 sequences most likely: S₄ = 0, 6/16
All head-and-tail sequences of n tosses are equally likely. Ending at k takes (n + k)/2 heads, so the bar at k counts the sequences with that many heads.
Exact definition
Distribution. \(S_n = k\) exactly when \(h - (n - h) = k\), where \(h\) counts the steps up, so \(h = (n + k)/2\). Each of the \(2^n\) sequences of steps has probability \(2^{-n}\), so
\[P(S_n = k) = \binom{n}{(n + k)/2}/2^n\]when \(n + k\) is even and \(\lvert k\rvert \le n\), and \(P(S_n = k) = 0\) otherwise.
Fine print: names and the model
The walk on this page is also called the symmetric simple random walk on the integers. With a coin that lands heads with probability \(p \ne \tfrac{1}{2}\) it is a biased walk; 2 Try uses one.
\(S_n\) has the parity of \(n\): after an even number of steps the walker stands on an even position, after an odd number on an odd one. Every exact statement on this page assumes independent steps with fixed probabilities.
Guess, then run the walks
- Make your guess first. The walk runner opens when you check it.
- Run walks of 100 steps. The first figure shows the latest paths, the second where all your walks ended.
- Set the band half-width c to the narrowest band from −c to c that you think holds at least 95% of all walks of 100 steps, with your endpoints as evidence, then press Check my band.
How the runner works
Each walk takes 100 steps of \(+1\) or \(-1\), each with probability \(\tfrac{1}{2}\), independently. The walks come from a fixed seed, seed 1, so the same walks come back on every visit. The runner holds 1,000 walks, and moving \(c\) rescores the walks already run. Check my band compares your \(c\) with the exact probabilities, which do not depend on the seed, so on a small set of walks the narrowest band that holds 95% of them can differ from the exact answer.
Longer walks, and a coin that leans
A prediction first, then a quick guess. The explorer opens once you answer the guess.
A coin that leans
Explorer: the exact distribution of the end position
Set the number of steps \(n\) and the chance \(p\) of a step up; the figure and the tiles follow. The mean and SD come from the box after the proof in 3 Prove.
Goals
Why the squared distance averages n
Assumptions. \(n \ge 2\) is an integer, and the steps \(\xi_1, \dots, \xi_n\) are independent, each equal to \(+1\) or \(-1\) with probability \(\tfrac{1}{2}\). The walk is \(S_n = \xi_1 + \dots + \xi_n\).
Conclusion.
\[\begin{aligned} \operatorname{E}[S_n] &= 0, \\ \operatorname{E}[S_n^2] &= \operatorname{Var}(S_n) = n, \\ \operatorname{E}[\lvert S_n\rvert] &\lt \sqrt{n}. \end{aligned}\]So the root-mean-square distance from the start is exactly \(\sqrt{n}\), and the average distance is smaller. For one step the distance is 1 for sure, and the two agree.
Facts the proof uses.
- Linearity: \(\operatorname{E}[X + Y] = \operatorname{E}[X] + \operatorname{E}[Y]\) and \(\operatorname{E}[cX] = c\operatorname{E}[X]\) for random variables with finite means, independent or not.
- If \(X\) and \(Y\) are independent and have finite means, then \(\operatorname{E}[XY] = \operatorname{E}[X]\operatorname{E}[Y]\).
- If \(\operatorname{E}[X^2]\) is finite, then \(\operatorname{Var}(X) = \operatorname{E}[X^2] - (\operatorname{E}[X])^2\), and \(\operatorname{Var}(X) \ge 0\), with equality only when \(X\) is constant with probability 1. The lesson on expectation and variance proves the shortcut.
Each option is one step of the proof. Pick the one that is true for every \(n \ge 2\).
Problems
Counting sequences, the theorem of 3 Prove and the box after it give every answer.
Further reading
- W. Feller, An Introduction to Probability Theory and Its Applications, Vol. 1, 3rd ed. (1968), chapter III on fluctuations in coin tossing and random walks.
- G. Grimmett and D. Stirzaker, Probability and Random Processes, 3rd ed. (2001), chapter 3, sections 3.9 and 3.10 on the simple random walk and counting its paths.
- J. R. Norris, Markov Chains (1997), chapter 1, section 1.6 on recurrence and transience of random walks.