Skip to main content
QuantDXB

Probability and statistics · 14 min read

Random walks and Brownian motion

From coin flips to the engine of continuous-time finance: square-root scaling, rough paths, quadratic variation and the chance of touching a level.

Before you start

  • How sure is an average? (this track)
  • Conditional expectation (this track)

By the end you'll be able to

  • Explain why random movement scales with the square root of time
  • Build Brownian motion as the limit of scaled random walks
  • Explain quadratic variation and why (dW)² = dt
  • Use the reflection principle to find the chance of touching a level

The simplest model of a price that nobody can predict is a coin flip: each period it goes up or down by the same amount. Stack enough flips, make them small and fast, and you get Brownian motion, the random engine inside the Black–Scholes model and most of continuous-time finance. This lesson takes that limit step by step and shows the strange properties that make stochastic calculus different from ordinary calculus.

SymbolMeaning
nnThe number of steps in a walk
SnS_nThe position of a ±1 random walk after nn steps
TTThe time horizon
WtW_tBrownian motion at time tt
Δt\Delta tThe length of one time step, T/nT/n
Φ\PhiThe standard normal cumulative distribution function

The coin-flip walk

Start at zero. Each step, flip a fair coin and move up 1 for heads, down 1 for tails. Write Xi=±1X_i = \pm 1 for the ii-th step and Sn=X1+⋯+XnS_n = X_1 + \dots + X_n for the position.

Each step has mean 0 and variance 1, and the steps are independent, so

E[Sn]=0,Var⁡(Sn)=n,sd⁡(Sn)=n.\mathbb{E}[S_n] = 0, \qquad \operatorname{Var}(S_n) = n, \qquad \operatorname{sd}(S_n) = \sqrt{n}.

After 100 steps the walk is typically about 10 away from where it started, not 100 and not 0. The distance grows like the square root of the number of steps: the same n\sqrt{n} as in the standard error of an average, for the same reason.

The walk is also a martingale: given everything up to now, the expected next position is the current one, E[Sn+1∣S1,…,Sn]=Sn\mathbb{E}[S_{n+1} \mid S_1, \dots, S_n] = S_n. That is the conditional expectation way of saying the price has no predictable direction.

Shrinking the steps

To model a price that moves continuously, squeeze more steps into a fixed time TT. With nn steps each lasting Δt=T/n\Delta t = T/n, how big should each step be? If the steps kept size 1, the variance at TT would be nn and blow up as nn grows. If they shrank like Δt\Delta t, the variance would be n⋅Δt2=T2/nn \cdot \Delta t^2 = T^2/n, which goes to zero: the walk would freeze.

The only choice that keeps the spread at TT finite and non-zero is a step size of Δt\sqrt{\Delta t}:

Var⁡(position at T)=n⋅(Δt )2=n⋅Tn=T.\operatorname{Var}(\text{position at } T) = n \cdot \big(\sqrt{\Delta t}\,\big)^2 = n \cdot \frac{T}{n} = T.

Pick the number of steps below. Each choice keeps the spread at t=1t = 1 near 1, and every path stays mostly inside the dashed envelopes at ±t\pm\sqrt{t} and ±2t\pm 2\sqrt{t}, whatever nn is.

Steps per walk
Step size 1/√n
0.250
Spread at t = 1
–
0 walks; theory 1
Path length
0
Sum of squared steps
0.000
Faint lines are finished walks; the white one is being drawn. More steps make the paths rougher, but the spread at t = 1 stays at 1. The highlighted path's length grows like √n, while its sum of squared steps is always exactly 1.

Key idea. Random movement scales with the square root of time. Over four times as long, a random price moves about twice as far. That is why volatility is quoted per square root of time, and why annual volatility is daily volatility times about 252\sqrt{252}.

Brownian motion

As n→∞n \to \infty the scaled walk converges to Brownian motion WtW_t (this is Donsker's theorem). By the central limit theorem its position at any time is normal, and it is defined by four properties:

  1. W0=0W_0 = 0.
  2. Increments are normal: Wt−Ws∼N(0, t−s)W_t - W_s \sim \mathcal{N}(0,\, t - s) for s<ts < t.
  3. Increments over non-overlapping intervals are independent.
  4. Paths are continuous.

In the Monte Carlo lesson the stock price was ST=S0exp⁡((r−12σ2)T+σWT)S_T = S_0 \exp\big((r - \tfrac{1}{2}\sigma^2)T + \sigma W_T\big), with WT=T ZW_T = \sqrt{T}\,Z: exactly this object, scaled by volatility.

Rough paths and quadratic variation

Look at the readouts as you raise the number of steps. Each step has size 1/n1/\sqrt{n}, so:

  • The path length, the total distance travelled up and down, is n⋅1n=nn \cdot \tfrac{1}{\sqrt{n}} = \sqrt{n}. It grows without limit. A Brownian path has infinite length over any time interval and has no slope anywhere.
  • The sum of squared steps is n⋅1n=1n \cdot \tfrac{1}{n} = 1, whatever nn is. For Brownian motion this sum over [0,T][0, T] is called the quadratic variation, and it equals TT.

For any smooth curve the sum of squared changes goes to zero as the steps shrink, because each change is roughly proportional to Δt\Delta t and squaring makes it negligible. For Brownian motion each change is of size Δt\sqrt{\Delta t}, so its square is of size Δt\Delta t, and adding them up gives the elapsed time. Informally, (dWt)2=dt(dW_t)^2 = dt.

That one line is why stochastic calculus has an extra term. Expanding a function of WtW_t to second order, the (dWt)2(dW_t)^2 term doesn't vanish as it would for a smooth input; it becomes dtdt. This is the origin of Itô's lemma, and of the −12σ2-\tfrac{1}{2}\sigma^2 in the stock price formula.

Key idea. Over a short time Δt\Delta t, a Brownian increment is of size Δt\sqrt{\Delta t}, far bigger than Δt\Delta t. Its square adds up to time itself, and ignoring that gives wrong answers in finance.

Will it touch the level?

A question traders ask all the time: what is the chance the price touches a level before a deadline, not just ends beyond it? Barrier options and stop-losses depend on it.

For Brownian motion there is a neat answer, the reflection principle. Take any path that touches level a>0a > 0 and ends below it. Reflect the part after the first touch in the line at aa: you get a path that ends above aa, equally likely because up and down moves are symmetric. So paths that touch and end below are exactly as common as paths that end above, and

P(max⁡0≤t≤TWt≥a)=2 P(WT≥a)=2(1−Φ(a/T)).\mathbb{P}\Big(\max_{0 \le t \le T} W_t \ge a\Big) = 2\,\mathbb{P}(W_T \ge a) = 2\Big(1 - \Phi\big(a/\sqrt{T}\big)\Big).

For a=1a = 1 and T=1T = 1: the chance of ending above 1 is 15.9%, and the chance of touching 1 at some point is twice that, 31.7%.

In code

python
import numpy as np

rng = np.random.default_rng(2)
paths, steps, T = 20_000, 1_000, 1.0
dt = T / steps

# Brownian motion: cumulative sums of independent N(0, dt) increments.
increments = rng.normal(0.0, np.sqrt(dt), size=(paths, steps))
w = np.cumsum(increments, axis=1)

# The spread grows like the square root of time.
for t in (0.25, 0.5, 1.0):
    print(f"sd of W({t}) = {w[:, int(t * steps) - 1].std():.3f}   theory {np.sqrt(t):.3f}")

# Quadratic variation settles at T; total variation keeps growing as the grid gets finer.
print(f"quadratic variation {np.sum(increments[0] ** 2):.3f}")
print(f"total variation     {np.sum(np.abs(increments[0])):.1f}")

# Reflection principle: P(max W >= 1) = 2 P(W(1) >= 1) = 0.317.
print(f"hit 1 before T: {np.mean(w.max(axis=1) >= 1):.3f}   end above 1: {np.mean(w[:, -1] >= 1):.3f}")

It prints standard deviations of 0.502, 0.709 and 1.005 against the theoretical 0.5, 0.707 and 1, a quadratic variation of 1.026 for one path (with normal steps it is random, but close to 1), and a total variation of 25.6, which would grow without bound on finer grids.

The last line prints 0.308 for touching and 0.162 for ending above. The touching rate is a little below the theoretical 0.317 because the simulation only checks the path at 1,000 points: a path can cross the level and come back between two checks. Simulated barrier prices have the same bias, and correcting it is a standard exercise.

Where this shows up in quant work

  • Volatility scaling. Risk over a horizon scales with its square root: a 1% daily volatility is about 16% a year. Risk reports, position limits and option prices all rely on this.
  • Option pricing. Brownian motion drives the Black–Scholes model, and the −12σ2-\tfrac{1}{2}\sigma^2 term comes from quadratic variation.
  • Barriers and stops. The reflection principle prices barrier options and estimates how often a stop-loss will trigger.
  • Testing for randomness. If returns are a random walk, the variance of kk-day returns is kk times the variance of daily returns. The variance ratio test checks exactly that; a ratio far from 1 suggests trends or mean reversion.

Exercises

  • A stock has 25% annual volatility. Using the square-root rule, what is its typical move over one trading day (252 days a year)? Over one week (5 days)?
  • In the Python code, change steps to 100 and to 10,000. How does the touching rate change, and why?
  • Use the reflection principle to find the probability that Brownian motion touches −1-1 or +1+1 before T=1T = 1 is at most what? (Hint: add the two one-sided probabilities. Why is that only an upper bound?)

Key takeaways

  • A random walk's spread grows like n\sqrt{n}; scaling steps by Δt\sqrt{\Delta t} keeps the spread over a fixed time finite, and the limit is Brownian motion.
  • Brownian increments are independent and normal with variance equal to elapsed time.
  • Brownian paths have infinite length but quadratic variation equal to elapsed time: (dW)2=dt(dW)^2 = dt, the root of Itô calculus.
  • The chance of touching a level is twice the chance of ending beyond it (reflection principle).