Foundations to Frontier
Tests
A. Mathematical Foundations › A4 Probability Theory › Stochastic processes

Random Walks

The simplest stochastic process: add up independent steps. A random walk drifts like n(2p − 1) but spreads like √n, which is diffusion. The reflection principle gives exact first-passage probabilities, gambler's ruin gives hitting probabilities, and Pólya's theorem says walks always return home in 1-D and 2-D but not in 3-D. You will see the √t law in gyro heading drift (angle random walk and Allan deviation), and why random walks underlie exploration, MCMC and Brownian motion.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

The wandering ant

An ant on a long stick flips a coin each second: heads, one step right; tails, one step left. Where is it after 100 seconds? On average, right where it started, because left and right cancel. But it’s usually about 10 steps away in one direction or the other. After 10,000 seconds it’s typically about 100 steps away. The distance grows like the square root of the time.

That’s a random walk. It describes a wandering robot, a drifting compass, a stock price, and molecules spreading in air.

Random walks spread like √n
after n = 400: mean drift n(2p − 1) = 0.0 · RMS position 20.9 (theory √(drift² + 4np(1−p)) = 20.0) · walks that revisited 0: 96%
25 of 200 walks shown. Orange: the drift n(2p − 1). Dashed: drift ± 2 standard deviations, 2√(4np(1 − p)). With p = 1/2 there is no drift and the spread grows like √n. Any bias eventually dominates, since drift ∝ n beats noise ∝ √n.
Why engineers care

A gyroscope’s tiny random errors add up, so a robot’s heading drifts like a random walk and grows with √time. Knowing that law tells you how long you can navigate without GPS or a star tracker before the error is too big. Random walks also model exploration, search and the noise inside learning algorithms.

📝 Quick check (Level 0)
0/3 answered
  1. 1. After 100 fair coin-flip steps the ant is typically about how far from the start?
  2. 2. To wander twice as far you need about…
  3. 3. The ant's average position (over many ants) is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Definition and moments

Sn=X1+⋯+XnS_n = X_1 + \cdots + X_n with iid steps XiX_i. The simple random walk has Xi=+1X_i = +1 with probability pp and −1-1 otherwise.

ESn=n(2p−1),Var⁡Sn=4np(1−p)\mathbb ES_n = n(2p - 1), \qquad \operatorname{Var}S_n = 4np(1 - p)
  • Symmetric walk (p=1/2p = 1/2): ESn=0\mathbb ES_n = 0 and ESn2=n\sqrt{\mathbb ES_n^2} = \sqrt n.
  • Drift beats noise: the drift grows like nn and the spread like n\sqrt n.
  • Distribution: P(Sn=k)=(n(n+k)/2)2−nP(S_n = k) = \binom{n}{(n+k)/2}2^{-n} (symmetric case) for n+kn + k even. By the CLT, Sn/n≈N(0,1)S_n/\sqrt n\approx\mathcal N(0,1).

A random walk is a Markov chain on the integers (A4.4-1): the next position depends only on the current one.

📝 Quick check (Level 1)
0/3 answered
  1. 1. E S₁₀₀ for p = 0.6?
  2. 2. Var S_n for the symmetric walk?
  3. 3. P(S₂ = 0) for the symmetric walk?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

The reflection principle

For the symmetric walk and a level a>0a > 0,

P(max⁡m≤nSm≥a)=2P(Sn≥a)−P(Sn=a)P\Big(\max_{m\le n}S_m\ge a\Big) = 2P(S_n\ge a) - P(S_n = a)

Why: reflect any path after it first touches aa. Paths that hit aa and end below it pair up one-to-one with paths that end above it. Reaching a level at some point is about twice as likely as being above it at the end.

Gambler’s ruin

Start at kk and stop at 00 or NN. With r=(1−p)/pr = (1 - p)/p,

P(hit N first)={k/Np=121−rk1−rNp≠12,E[duration]=k(N−k)  (p=12)P(\text{hit }N\text{ first}) = \begin{cases}k/N & p = \tfrac12\\ \dfrac{1 - r^k}{1 - r^N} & p\ne\tfrac12\end{cases}, \qquad \mathbb E[\text{duration}] = k(N - k)\ \ (p = \tfrac12)

A small disadvantage (p=0.45p = 0.45) cuts the chance of going from 5 to 10 from 50% to 27%. Derive these by first-step analysis: hk=phk+1+(1−p)hk−1h_k = ph_{k+1} + (1 - p)h_{k-1}.

Recurrence: Pólya’s theorem

The simple random walk on Zd\mathbb Z^d returns to the origin with probability 1 for d=1,2d = 1, 2 (recurrent). For d≥3d\ge3 it doesn’t: the return probability in 3-D is about 0.3405 (transient). Reason: P(S2n=0)∼c n−d/2P(S_{2n} = 0)\sim c\,n^{-d/2}, whose sum diverges exactly when d≤2d\le2. In Kakutani’s phrase, a drunk man will find his way home, but a drunk bird may get lost forever.

🐍 Exercise 1: moments, √n spreading and the reflection principle
Simulate biased and symmetric walks. Check the mean and variance, that the RMS displacement is √n, and that the simulated P(max ≥ a) matches the reflection-principle formula exactly.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The reflection principle says P(max ≥ a) is about…
  2. 2. Fair gambler's ruin, start 3, target 10. P(reach 10 first)?
  3. 3. The 3-D simple random walk is…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Proof of the reflection principle

Fix a>0a > 0 and b<ab<a. Let τ\tau be the first time S=aS = a.

  1. The bijection. Map each path with τ≤n\tau\le n and Sn=bS_n = b to the path that agrees until τ\tau and is mirrored in aa afterwards. It ends at 2a−b>a2a - b > a. Every path ending at 2a−b2a - b must have hit aa, so this is a bijection.
  2. Equal probabilities. All paths have probability 2−n2^{-n}, so P(τ≤n,Sn=b)=P(Sn=2a−b)P(\tau\le n, S_n = b) = P(S_n = 2a - b).
  3. Sum up. Sum over b<ab<a and add the paths that end at or above aa: P(max⁡≥a)=P(Sn≥a)+P(Sn>a)P(\max\ge a) = P(S_n\ge a) + P(S_n > a). That’s the formula. ∎

Proof of Pólya in 1-D

The expected number of returns is ∑nP(S2n=0)=∑n(2nn)4−n\sum_nP(S_{2n} = 0) = \sum_n\binom{2n}n4^{-n}. Stirling’s formula gives (2nn)4−n∼1/πn\binom{2n}n4^{-n}\sim1/\sqrt{\pi n}, so the sum diverges. If ff is the probability of ever returning, the number of returns is geometric with mean f/(1−f)f/(1 - f). That mean is infinite, so f=1f = 1. ∎

From walks to Brownian motion

Rescale time by nn and space by n\sqrt n: W(n)(t)=S⌊nt⌋/nW^{(n)}(t) = S_{\lfloor nt\rfloor}/\sqrt n. Donsker’s invariance principle says W(n)W^{(n)} converges in distribution, as a whole random function, to Brownian motion (A4.4-4). The reflection principle carries over: P(max⁡s≤tBs≥a)=2P(Bt≥a)P(\max_{s\le t}B_s\ge a) = 2P(B_t\ge a).

Exercise 3.1: Derive the fair gambler’s-ruin probability by first-step analysis

hk=12hk+1+12hk−1h_k = \frac12h_{k+1} + \frac12h_{k-1} means hh is linear in kk. With h0=0h_0 = 0 and hN=1h_N = 1, hk=k/Nh_k = k/N.

📝 Quick check (Level 3)
0/3 answered
  1. 1. P(S₂ₙ = 0) for the 1-D walk decays like…
  2. 2. Rescaled walks S_{nt}/√n converge to…
  3. 3. The reflection bijection maps paths ending at b < a to paths ending at…

Level 4: Expert

★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.

Gyro drift: angle random walk and Allan deviation

A MEMS gyro’s output contains white rate noise. Integrating it to get heading gives a random walk. The heading error’s standard deviation grows like NtN\sqrt t, where NN is the angle random walk (ARW) coefficient, quoted in deg/h\text{deg}/\sqrt{\text{h}} on datasheets. The Allan deviation (Allan, 1966; IEEE Std 952), the standard tool for characterizing inertial sensors, separates noise types by their slope on a log-log plot: white rate noise gives slope −1/2-1/2, and its value at τ=1\tau = 1 s reads off NN. Bias instability and rate random walk show up as flat and +1/2+1/2 segments. This √t law sets how long a rover, drone or spacecraft can dead-reckon before it needs an absolute fix.

🐍 Exercise 2 (research): angle random walk and Allan deviation
Integrate white gyro noise (0.01 rad/s at 100 Hz) for 1000 simulated vehicles. Check that the heading sd = N√t with N = σ/√f, compute the Allan deviation of the rate signal, and verify its slope of −1/2 and that σ_A(1 s) = N.

Random walks in AI, robotics and aerospace

  • Inertial navigation error budgets. ARW, bias instability and rate random walk are all random-walk models. Allan-variance analysis sets Kalman-filter process noise for IMUs (El-Sheimy, Hou and Niu, 2008).
  • Exploration. Random-walk exploration covers a 2-D area slowly, with cover time on the order of nlog⁡2nn\log^2n for an nn-cell grid. That’s why ε-greedy struggles in large state spaces and systematic or curiosity-driven exploration helps.
  • Random-walk Metropolis proposals (A4.4-1). In dd dimensions the optimal step scales like d−1/2d^{-1/2}, with acceptance rate about 0.234 (Roberts, Gelman and Gilks, 1997).
  • Graph learning. DeepWalk and node2vec embed graph nodes using random-walk co-occurrences (Perozzi et al., 2014). Spectral clustering’s link to random walks explains its cuts.
  • Process noise in filters. “Constant velocity plus random-walk acceleration” is the default motion model in tracking (Bar-Shalom, Li and Kirubarajan, 2001).

References

  1. W. Feller (1968). An Introduction to Probability Theory and Its Applications, Vol. I, 3rd ed., Ch. III and XIV. Wiley.
  2. G. Pólya (1921). “Über eine Aufgabe der Wahrscheinlichkeitsrechnung betreffend die Irrfahrt im Straßennetz.” Mathematische Annalen, 84.
  3. G. Lawler, V. Limic (2010). Random Walk: A Modern Introduction. Cambridge University Press.
  4. M. Donsker (1951). “An invariance principle for certain probability limit theorems.” Memoirs of the AMS, 6.
  5. D. Allan (1966). “Statistics of atomic frequency standards.” Proceedings of the IEEE, 54(2).
  6. IEEE Std 952-1997 (R2008). IEEE Standard Specification Format Guide and Test Procedure for Single-Axis Interferometric Fiber Optic Gyros.
  7. N. El-Sheimy, H. Hou, X. Niu (2008). “Analysis and modeling of inertial sensors using Allan variance.” IEEE Transactions on Instrumentation and Measurement, 57(1).
  8. G. Roberts, A. Gelman, W. Gilks (1997). “Weak convergence and optimal scaling of random walk Metropolis algorithms.” Annals of Applied Probability, 7(1).
  9. B. Perozzi, R. Al-Rfou, S. Skiena (2014). “DeepWalk: online learning of social representations.” KDD.
  10. Y. Bar-Shalom, X. R. Li, T. Kirubarajan (2001). Estimation with Applications to Tracking and Navigation. Wiley.