law #4
In this lesson

Wide tables, equations, and code scroll sideways. Swipe, or Tab to focus them and use the left and right arrow keys.

Random walk

You will learn: Connect independent steps with displacement, drift, spread, and finite-time events.

Start with: Bernoulli distribution · Expectation and variance

A particle starts at position 0 and at each integer time step moves one unit right (with probability p) or one unit left (with probability 1 − p). Where does it end up after t steps?

position by steps−2002040050100150200stepsposition

Dashed outer curves show the expected position ±one pointwise standard deviation; the center line is the expectation. These are not hard path boundaries or a simultaneous confidence band. The dark accent path is walker one. All simulated positions fit the displayed vertical range.

Separate drift, spread, and distance traveled

Position after 200 independent unit steps
QuantityValue
Expected signed position0.00000
Position variance200.00000
Position SD14.14214
Mean simulated position0.70000
Focus walk signed displacement10
Focus walk distance from origin10
Total distance traveled by each walker200

Write position as 2H−T with H binomial(T,p). Exact P(position=0) = 0.0563485; P(position≤0) = 0.528174. Possible positions have the same parity as T and lie in [−T,T]. The event always refers to original position, including when the display subtracts drift.

Inspect the focus walk step by step
Every original position of walker one
StepPosition
00
1-1
20
3-1
4-2
5-3
6-2
7-3
8-4
9-3
10-4
11-3
12-2
13-1
140
151
162
173
184
195
204
215
226
237
248
257
266
277
288
297
306
315
326
335
346
355
364
375
384
395
406
417
428
439
448
457
468
479
4810
499
508
519
528
537
548
559
568
577
586
595
604
613
622
633
644
653
664
673
682
691
700
711
720
73-1
740
75-1
760
771
782
793
804
813
822
831
842
851
860
871
882
893
902
913
924
933
942
953
964
975
986
997
1006
1015
1026
1035
1044
1055
1064
1075
1084
1093
1102
1113
1124
1135
1144
1155
1164
1173
1184
1195
1204
1213
1222
1233
1244
1255
1266
1275
1286
1295
1306
1315
1324
1333
1342
1353
1364
1375
1386
1397
1406
1415
1426
1437
1448
1459
1468
1479
14810
14911
15010
15111
15210
1539
15410
1559
15610
15711
15810
1599
1608
1619
16210
1639
1648
1659
16610
16711
16810
1699
17010
17111
17210
17311
17410
1759
1768
1777
1788
1799
1808
1819
1828
1839
1848
1859
1868
1877
1888
1899
19010
1919
19210
1939
19410
1959
19610
19711
19810
1999
20010

Increasing T appends steps to each existing walker, and increasing walkers adds paths. The pointwise SD grows with √T for fixed p; one path need not stay near its expected position. Absorbing-boundary events require a hitting-time calculation rather than this endpoint distribution.

20 independent walkers with ±1 steps. Expected position is (2p−1)t and SD is 4p(1−p)t\sqrt{4p(1-p)t}. At p=1/2 these reduce to zero and √t; at p=0 or 1 each walk is deterministic.

The √t law

For an unbiased walk (p = 0.5), the expected position is always 0 — steps cancel on average. But the spread grows:

Var(Xt)=t\text{Var}(X_t) = t
Std(Xt)=t\text{Std}(X_t) = \sqrt{t}

For the fair case, the dashed curves show ±√t around zero. They are pointwise one-SD references, not barriers that a path must stay within. At 100 steps the SD is 10; at 10,000 steps it is 100. Spread grows as the square root of time, not linearly.

Bias

With p ≠ 0.5, each step has a net drift of 2p − 1 per step:

E[Xt]=(2p−1) tE[X_t] = (2p-1)\,t

The amber center line shows expected position, with outer curves at ±√(4p(1−p)t) around it. A bias changes both the center and variance. At p=0.9 and t=100, the expected position is 80 and SD is 6. Plotting an unbiased ±√t envelope around zero would describe the wrong experiment.

For any fixed nonzero drift, its magnitude grows linearly in time while the centered SD grows as √t. This is an asymptotic comparison of scales, not a promise that every finite walk will follow the drift.

Diffusion and Brownian motion

The random walk is the discrete ancestor of Brownian motion. For the fair walk, under diffusive scaling that divides position by √n while accelerating time by n, the process converges to a continuous Gaussian process where position after time t is distributed as Normal(0, t). The same √t scaling survives in the limit — it is a fundamental feature of diffusion, not an artifact of the discrete model.

The Central Limit Theorem explains why: the position after t steps is a sum of t independent ±1 variables, and centering and scaling that finite-variance sum gives a normal limit. The exact finite-time position remains on a lattice.

Count right steps to find the endpoint law

Let H be the number of right steps. There are T−H left steps, so S_T=H−(T−H)=2H−T, with H binomial(T,p). At T=4 and p=1/2, the chance of ending at zero is the chance of two right steps: 6/16=0.375. The chance of ending at or below zero is (1+4+6)/16=0.6875.

Ending at position one after four steps is impossible: 2H−4 is even. The point-probability panel retains this parity constraint instead of filling every real-valued location with a normal approximation. The cutoff always concerns the original signed position, even in the centered display.

Displacement is different from distance traveled

The path right, right, left, left travels four units but ends where it started. Its signed displacement and distance from the origin are both zero. At a given time, averaging signed positions can also cancel positive and negative endpoints without saying that walkers traveled little.

Each step has mean 2p−1 and second moment one, hence variance 1−(2p−1)²=4p(1−p). Adding independent steps gives the drift and variance in the table. At p=0 or 1 there is no randomness: position is exactly −T or T and the variance is zero.

Make a prediction

Does knowing the endpoint probability tell you the probability that a walk hit a barrier earlier?

Explore the answer

No. A walk can cross a barrier and later return. A hitting event concerns the whole path, whereas the binomial calculation concerns only its endpoint. Use the gambler’s-ruin experiment for absorbing barriers.

References

Random Services: the simple random walk derives the endpoint distribution and increment moments. Continue to gambler’s ruin for hitting probabilities or binomial counts to inspect the right-step count.

Continue to martingales to distinguish conditional fairness from constant expectation and check bounded stopping rules.

Reset all settings