Stochastic Calculus, Visualized
Brownian Motion, Itô's Lemma, and Why dW² = dt
A 49-minute, 15-chapter explainer in five parts that builds stochastic calculus from a coin flip. Brownian motion comes first: the √Δt scaling, self-similarity, nowhere differentiability, infinite length and the one rule (dW)² = dt. Then the Itô integral: fair games, the left-endpoint rule, the "missing half" of ∫W dW = ½W² − ½t, and the Itô isometry. Then Itô's lemma, derived from Taylor's theorem and shown at work in volatility drag. Then equations of noise: SDEs, Euler–Maruyama, Ornstein–Uhlenbeck, Fokker–Planck, and Kolmogorov/Feynman–Kac. Last come two payoffs: Black–Scholes and Girsanov's theorem.
The emphasis is on the mathematics: every result is derived on screen, one
line at a time. Every path, histogram and number on screen is a seeded
simulation: one Brownian path at 4,194,304 steps that the whole video keeps
coming back to, 40,000 Itô integrals, 10,000 players of a coin game, 3,000
particles in a double well beside a numerical Fokker–Planck solve, Brownian
walkers solving Laplace's equation in a disk, 5,000 simulated years of delta
hedging, and 2,000 reweighted paths. Each is asserted against the theory it
illustrates (see Simulations). Schematics are labeled
schematic; the one enlarged illustrative step is labeled one step, enlarged.
Contents
- 1A calculus for randomness3 min
- 2From coin flips to Brownian motion4 min
- 3Continuous everywhere, smooth nowhere3 min
- 4The one rule: dW² = dt4 min
- 5Integrating against noise3 min
- 6Where the missing half comes from5 min
- 7Fair games and the Itô isometry3 min
- 8Itô's lemma: the chain rule, corrected6 min
- 9Growth, noise, and volatility drag5 min
- 10Stochastic differential equations4 min
- 11From paths to densities: Fokker–Planck4 min
- 12Backwards: averages over paths solve PDEs4 min
- 13Black–Scholes: hedging the noise away4 min
- 14Changing the odds: Girsanov's theorem3 min
- 15Recap1 min
Also on this page: Lecture · Notes and sources · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film.
1A calculus for randomness3 min
In 1827, the botanist Robert Brown put grains of pollen in water, and looked at the tiny particles they released under his microscope. The particles never stopped moving. Each one jittered, darting this way and that, for no visible reason.
And the jitter isn't a vibration around some home position. The particle wanders. Watch its trail: it never settles, and it never retraces a smooth curve.
In 1905, Einstein explained it. The particle is being hit from every side by water molecules, and at any instant the kicks never quite cancel. The leftover push points somewhere new every moment.
Release a crowd of such particles from one point, and they spread out like a drop of ink. Einstein's key prediction was how fast: the average squared distance grows in proportion to time, so the width of the cloud grows like the square root of time. A few years later, Jean Perrin measured exactly that, and used it to count molecules.
Now follow just one coordinate of one particle as time goes by, and you get a graph like this. This is Brownian motion: the mathematician's idealized version of that jitter. Louis Bachelier used it in 1900 to model prices on the Paris stock exchange, and Norbert Wiener made it rigorous in the 1920s. Today it's the basic model of noise in physics, biology, engineering, and finance.
And it breaks ordinary calculus. Here's a simple test. In ordinary calculus, the integral of s d s, from zero to x, is x squared over two. So for our path, the integral of W d W, from time zero to time one, ought to be W at time one, squared, over two.
Let's just compute it, the way integrals are defined: chop time into steps, multiply W by its change over each step, and add up. We'll use more than four million steps. Our path ends at 1.2528, so half its square is 0.7847. But the sum comes out to 0.2847. We're off by 0.5000.
Maybe that path was special. So here are five more, each with sixty-five thousand steps. The gaps: 0.498, 0.501, 0.503, 0.499, 0.495. Every time, almost exactly one half.
That missing half isn't rounding error, and it isn't bad luck. The true answer is one half W squared, minus one half. And that extra term is the first sign of a different kind of calculus: stochastic calculus, created by Kiyosi Itô in the 1940s.
Here's the plan. First, Brownian motion itself, and the one strange fact that drives everything else: d W squared equals d t. Then the Itô integral, and where the missing half comes from. Then Itô's lemma: the chain rule, corrected for randomness. Then the equations of noise, and a surprising bridge between random paths and the partial differential equations of physics. And finally two payoffs: how Black and Scholes priced options by hedging the noise away, and how Girsanov's theorem changes the odds.
What it establishes: Brown's jittering particles; Einstein's ⟨r²⟩ ∝ t. Brownian motion as the model of noise. The puzzle: Σ W ΔW on our path is 0.2847, but ½W₁² is 0.7847. The gap is 0.5000, and it stays ½ on five more paths. The plan.; Simulated on screen: A 2D particle with a trail; 2,000 particles spreading (mean squared displacement asserted linear); the hero path's left sum at 2²² steps; five more paths at 2¹⁶ steps.
2From coin flips to Brownian motion4 min
Brownian motion is the limit of the simplest random process there is. Flip a fair coin. Heads, take a step up; tails, a step down. Do it again, and again, and you trace out a random walk.
To get something in continuous time, we'll squeeze n steps into one unit of time. Each step takes a time delta t, equal to one over n. But how tall should each step be? Call the step size delta x.
There's only one choice that works, and here's why. At time t, the walker's position is delta x times a sum of plus and minus ones, one for each step taken. The coin flips are independent, so their variances add: the number of steps, t over delta t, times the variance of each step, delta x squared. That's t, times delta x squared over delta t.
So everything depends on that ratio. Make the steps as small as the time steps, and the variance dies away: the walk freezes. Make them bigger, like the fourth root, and the variance blows up. Only steps of size square root of delta t keep it finite: space has to scale like the square root of time. That square root is the seed of everything in this video.
Here's that argument as a picture. Three panels, the same coin flips in each; only the step height differs. Now let n grow. Sixty-four steps. Two hundred and fifty-six. A thousand. Four thousand. With steps as small as delta t, the walk flattens to nothing. With the fourth root, it runs off the chart. But with the square root, the picture keeps the same overall size and just gets finer and finer, rougher and rougher.
And what does the endpoint look like? At time one, it's a sum of n independent coin flips, divided by root n. The central limit theorem says that as n grows, that becomes a bell curve: a normal distribution with mean zero and variance one. Run many walks, and pile up where they end.
Two hundred walks. Two thousand. Twenty thousand. And the bell curve emerges. Take the limit at every time, not just at the end, and you get Brownian motion, written W of t. Here are two hundred of its paths. At each time t, W of t is a bell curve with mean zero and variance t. So the spread of the paths grows like the square root of t: about two thirds stay within one root t, and ninety-five percent within two. The same square root law that Einstein found for the spreading cloud.
Let's pin down exactly what we've built. Brownian motion starts at zero. What it does over one stretch of time is independent of what it did over any earlier stretch, just like fresh coin flips. Each increment, from time s to time t, is a bell curve with mean zero and variance t minus s: the elapsed time. And its paths are continuous: no jumps.
Norbert Wiener proved in 1923 that a process with exactly these properties exists, and Monroe Donsker proved that rescaled random walks converge to it, whatever the step distribution, as long as it has mean zero and finite variance. So Brownian motion is universal: it's what any accumulation of many small, independent kicks looks like from far away.
What it establishes: Var X_t = t·(Δx)²/Δt, so only Δx = √Δt gives a limit. The same coin flips scaled by Δt, √Δt, Δt^¼. CLT. W_t ~ N(0, t). The four defining properties; Wiener, Donsker.; Simulated on screen: Walks at n = 16…4,096; 20,000 walks of 64 flips; 200 Brownian paths with N(0, t) snapshots (68.3% / 95.5% inside ±√t / ±2√t).
3Continuous everywhere, smooth nowhere3 min
Brownian paths are continuous, but they're strange in another way. Here's an ordinary smooth curve. Let's zoom in on one point, by the same factor in both directions. Four times, sixteen, sixty-four, two hundred and fifty-six. The curve straightens out, until it's indistinguishable from a line: its tangent line. That's what having a derivative means: up close, the curve is a line.
Now do the same to our Brownian path, zooming four times in both directions, again and again. Instead of straightening out, it gets steeper and wilder: the wiggles shoot off the top and bottom of the window. There is no tangent line to find.
Here's the zoom that does work. Every time you stretch time by four, stretch space by only two: the square root of four. Now every level looks like the one before: just as rough, just as wild, statistically the same picture. These are all one path, simulated at four million points, and we could keep going forever.
In symbols: Brownian motion with time sped up by a factor c has the same distribution as the original, scaled up by root c. It's a fractal. And that same square root again: zooming in never reveals anything smooth.
This kills the derivative for good. A derivative is the limit of secant slopes: the change in W over a short time h, divided by h. But that change is a bell curve with variance h, so the slope is a bell curve with variance one over h. Its typical size is one over root h, and as h shrinks, it blows up.
On our path, at the point we zoomed into: each time h shrinks by four, the slope roughly doubles, from about four, to eight, to over two hundred, right along with one over root h. Brownian motion is continuous everywhere, and differentiable nowhere.
And there's an even stranger consequence. Walk along the path and add up the size of every move, up or down: the total distance traveled. Sampled at sixteen steps, our path travels 4.0. At 256 steps, 12.7. At four thousand, 50.6. And at four million steps, more than sixteen hundred. Each time the steps get sixteen times finer, the distance quadruples, exactly as the formula predicts.
In the limit, it's infinite. A Brownian path has infinite length over every interval of time, however short. And that's a real problem for calculus, because the classical way to integrate against a curve, the Riemann–Stieltjes integral, needs the curve to have finite length. So we need a new idea. And it comes from a surprise: add up the squares of those moves instead, and the sum doesn't blow up at all.
What it establishes: Zooming a smooth curve gives its tangent line. Zooming Brownian motion 4:4 makes it steeper; 4:2 makes it statistically the same (W_ct = √c W_t). Secant slopes ~ 1/√h. Total variation √(2n/π) → ∞, so Riemann–Stieltjes integration fails.; Simulated on screen: The hero path itself, zoomed 4⁵ = 1,024× in time (min/max decimation keeps the roughness); its secant slopes at h = 4⁻¹…4⁻⁷; its total variation at n = 16…2²².
4The one rule: dW² = dt4 min
Here's that surprise. Take a smooth curve, and chop time into steps. On each step, build a square whose side is the curve's change over that step. Then pour all of the squares' area into this tank. Its capacity is exactly one unit of area: the same number as the length of our time interval, T equals one.
For a smooth curve, the squares fill only part of the tank. And finer steps make it emptier and emptier: each change is about the slope times delta t, so each square is about delta t squared, and the n of them add up to something on the order of delta t, which goes to zero.
Now the Brownian path. Sixteen steps: the squares more than fill the tank. Sixty-four steps: just over the brim.
Two hundred and fifty-six: just under. Four thousand: 0.993. Four million: 1.0000. The squares' total area converges to exactly one: the elapsed time.
Why? Each increment is a bell curve with variance delta t, so each square has an expected area of exactly delta t. Add up n of them, and the expected total is n delta t: the elapsed time, T.
That's only the average. But the randomness disappears too. The variance of a single square works out to two delta t squared, using the fact that a standard bell curve has fourth moment three. The increments are independent, so the variances add, giving two T delta t. And that goes to zero as the steps shrink.
A sum of many small, independent, positive pieces, whose fluctuations die away: it converges to a constant. Not just on average. On essentially every path.
Here it is across four thousand fresh paths. With sixteen steps, the sum of squares is all over the place. With 256, it bunches up around one. With four thousand, it's nearly a spike. The spread shrinks exactly like root of two over n.
The same is true at every moment along the way. Add up the squares only up to time t, and plot that running total. With sixteen steps it's a ragged staircase. Refine the steps: sixty-four, two fifty-six, four thousand. The staircase lies down on the line y equals t. The path is random, but its accumulated squared wiggle is a perfect clock: quadratic variation equals time.
This is the one rule that makes stochastic calculus different, and we write it in a single line: d W squared equals d t. It doesn't mean each little square equals delta t. Each one is delta t times a random number with mean one, which can be almost zero or bigger than four. It means that in any sum over many small steps, the squares add up exactly like delta t would.
And the other products of small quantities vanish. d t times d t sums to T delta t, which goes to zero. d t times d W sums to something like T root delta t, which also goes to zero. Only d W times d W survives. That's the multiplication table of stochastic calculus. In ordinary calculus, every product of two small changes is negligible. Here, d W is the size of root d t, so its square is as big as d t itself, and it stays.
What it establishes: Squares on each increment, poured into a tank of capacity T. Smooth: Σ(Δf)² → 0. Brownian: Σ(ΔW)² → T. E = T and Var = 2TΔt (E Z⁴ = 3). The running sum lies on y = t. (dW)² = dt and the multiplication table.; Simulated on screen: The hero path's Σ(ΔW)² at n = 16…2²² (1.280 → 1.0000); Σ(ΔW)² on 4,000 fresh paths at n = 16, 256, 4,096 (sd asserted √(2/n)).
5Integrating against noise3 min
Most of science is written in differential equations: the rate of change of X is some function of X. To add randomness, it's natural to write: rate of change equals a drift, plus some amplitude times noise. But what is the noise? It would have to be the derivative of Brownian motion, and we just saw that doesn't exist.
Here's what happens if you try anyway: the slopes of our path over steps of one sixty-fourth, one two-fifty-sixth, and one four-thousandth. The finer you look, the bigger the spikes. There's no function there to converge to.
The way out is to never differentiate. Integrate both sides instead. X at time t is its starting value, plus the integral of the drift, which is an ordinary integral, plus the integral of sigma d W. That last one is new. To make sense of noisy differential equations, we first have to define what it means to integrate against a Brownian path.
The cleanest way to think about it is gambling. Let W be the price of a stock, or your running score in a fair game. Let H be how many shares you hold: your stake. Over one short step, your gain is your stake times the change in the price, and your winnings, G, are the sum of all those gains.
Here's a strategy: hold as many shares as the current price. Watch it play out. At the start of each step, you choose your stake, looking only at the past. Then the curtain lifts, the price moves, and the gain, stake times move, goes into your winnings.
Notice the one rule we followed. Each stake was set before the price moved: you could see the past, but the future was behind a curtain. A strategy that never peeks is called adapted, or non-anticipating, and it's the only kind of integrand we allow. It's also the only kind a real gambler, or a real investor, can use.
The Itô integral is what these winnings converge to as the steps shrink: the limit of the sum of H at the left end of each step, decided before the move, times the change in W across the step.
Despite the path's infinite length, these sums do converge, because the random gains and losses cancel each other in a controlled way; we'll see exactly how in a moment. Here's the same strategy with sixty-four steps, two hundred and fifty-six, four thousand. The winnings settle onto one curve, and at time one they settle onto a number we've seen before: 0.2847, the answer with the missing half.
What it establishes: Noise isn't a function (ΔW/Δt spikes grow). The integral form of an SDE. Gambling: stake × move, with the future behind a curtain (adapted). ∫H dW as the limit of left-endpoint sums.; Simulated on screen: The hero path's slopes; the H = W strategy step by step; its winnings at n = 16…4,096 converging to 0.2847.
6Where the missing half comes from5 min
So where does the missing half come from? In ordinary calculus, it doesn't matter where inside each little step you evaluate the integrand: the left end, the right end, the middle. All the choices give the same limit. Not here. On our path, sampling W at the left end of each step gives 0.2847. Sampling at the right end gives 1.2847. The midpoint gives 0.7847.
The right sum minus the left sum is the sum of W at the right end minus W at the left end, times delta W: that's the sum of the squares, delta W squared. And we know where that goes: to T, which here is one. And notice the midpoint gives exactly half of W squared: the answer from ordinary calculus.
Here's the exact algebra, on one step. The change in W squared, from the left end to the right end, is W plus delta W, squared, minus W squared, which is two W delta W, plus delta W squared.
Now add this up over all the steps. On the left, the sum telescopes: everything cancels except W squared at the end, minus W squared at the start, which is zero. On the right: twice the left-endpoint sum, plus the sum of the squares, which converges to T.
In the limit, W squared at time T equals twice the integral of W d W, plus T. So the integral is one half W squared, minus one half T. That's the missing half, and it is the quadratic variation, in disguise.
There's a lovely picture behind this. Draw a plane where both axes measure the value of W, and draw the line y equals w. As time runs, W moves back and forth along the horizontal axis.
Take one step, from W at the left end to W at the right end. The left-endpoint gain, W times delta W, is the area of this rectangle: width delta W, height W. The area under the line over the same stretch is one half the new W squared, minus one half the old one. They differ by a triangle, with two legs of length delta W, and area one half delta W squared.
And when the step goes the other way, the rectangle counts as negative area, overshoots the region under the line, and again they differ by exactly the same kind of triangle. Up or down, the left-endpoint sum always loses one half delta W squared.
Now run all sixteen steps, and collect the triangles in a tank whose brim is at one half T. The areas under the line telescope to one half W squared at the end, no matter how the path wandered. But every step drops a triangle, and they pile up.
With sixteen steps, the triangles hold 0.64, more than the brim. With 256 steps, 0.487. With four million: 0.5000. For a smooth path, these triangles are second-order small and add up to nothing. For a Brownian path there are so many of them that they add up to exactly half the elapsed time.
So which choice is right? Itô's left-endpoint integral gives one half W squared minus one half T. The midpoint gives the ordinary-calculus answer, one half W squared. It's called the Stratonovich integral. The right endpoint overshoots by one half T.
Think about the gambler again. The midpoint and right-end rules set your stake using the price after the move: they peek at the future. And it shows in the averages. Since W squared has mean T, Itô's answer has mean zero, while the others win money on average, in a perfectly fair game. Only cheating does that. The left endpoint is the honest choice: Itô integrals are fair games, with mean zero.
Stratonovich's integral isn't wrong, though. It's a different integral, and in physics it's often the natural one: if the noise is a limit of smooth, rapidly varying forces, the Stratonovich integral is what you get. The two are related by a simple correction term. In this video, we'll use Itô's, which is the standard in probability and finance.
What it establishes: Left / right / midpoint sums differ by Σ(ΔW)². The telescoping identity W_T² = 2∫W dW + T. The picture: every left-endpoint rectangle misses a triangle of area ½(ΔW)², and the triangles fill a tank of capacity ½T. Itô vs Stratonovich; only the left end is a fair game. Wong–Zakai.; Simulated on screen: The three sums at 2²² steps; the triangles of 16 and 256 steps, and their total at 2²² (0.5000).
7Fair games and the Itô isometry3 min
That fairness is the first of two rules that make the Itô integral work. On each step, the stake is fixed before the move, and the move is a fresh, independent coin flip with mean zero. So the expected gain on every step factors into the expected stake times zero. Add them up: every Itô integral has expected value zero.
Here are our winnings from the double-down strategy, on two hundred different Brownian paths. They spread out, and some win big, but their average stays pinned at zero, all the way along. A process like this, whose best forecast of the future is its present value, is called a martingale. Itô integrals of adapted strategies are martingales: no strategy beats a fair game.
The second rule tells us how big an Itô integral is. Square the sum, and take the average. Squaring a sum of n terms gives n squared cross terms, one for every pair of steps. Here they are as a grid.
Take any cell off the diagonal, say steps two and five. Step five's move comes last. Everything else in the product is known by the start of step five, and step five's move is fresh, with mean zero. So the whole term averages to zero. The same goes for every off-diagonal cell. The fairness of each step wipes out all the cross terms.
Only the diagonal survives: the stake squared times the move squared, which averages to the stake squared times delta t. Add up the diagonal, and you get an ordinary integral. This is the Itô isometry: the average square of the integral equals the average of the integral of H squared d t.
Notice the d W squared equals d t rule hiding inside it, on the diagonal. And this identity is also what guarantees that the Riemann sums converge in the first place: it turns questions about random sums into questions about ordinary integrals.
Let's test both rules on our double-down strategy, H equals W. The isometry predicts that the average square of the winnings is the integral of t d t from zero to one: one half.
Now simulate forty thousand paths. The average of the winnings: minus 0.0007, zero up to sampling noise. The variance: 0.505. Both rules check out. And look at the shape: you can never lose more than about one half, but you can win big. Lopsided, but fair. The ordinary-calculus answer, one half W squared, would average one half: it would win money in a fair game, which is exactly why it can't be right.
What it establishes: E[∫H dW] = 0 (martingale). The isometry from the cross-term grid. A check with H = W: mean 0, variance ½, a hard left edge at −½; the naive ½W₁² averages ½.; Simulated on screen: 200 winnings paths and their mean; 40,000 Itô integrals (mean −0.0007, variance 0.505) against the exact density of (Z² − 1)/2.
8Itô's lemma: the chain rule, corrected6 min
In ordinary calculus, the chain rule tells you how a function of a changing quantity changes: d f equals f prime times d x. Applied to W squared, it would say the change in W squared is two W d W. But we've already found the truth: W squared at time T is twice the integral of W d W, plus T. So the change in W squared has an extra piece: plus d t. Where does it come from, and what is it for a general function?
Go back to basics: Taylor's theorem. Over one small step, the change in f is f prime times delta W, plus one half f double prime times delta W squared, plus a cubic term, and so on. In ordinary calculus, only the first term matters, because the others are too small to survive being added up. But now delta W is the size of root delta t. So the first term is of order root delta t, the second of order delta t, and the third of order delta t to the three halves.
Now add up n of them, one per step, where n is T over delta t. The first terms have random signs, and their sum is an Itô integral. The second terms are n times something of order delta t: that stays finite. In fact, by our rule, delta W squared adds up like delta t, so this sum becomes an ordinary integral of one half f double prime. The third terms add up to n times delta t to the three halves, which goes to zero. So do all the rest.
Let's watch it happen. For f equals x cubed, Taylor's expansion stops after three terms, so it's exact: W cubed at time one is exactly the sum of these three columns, at every resolution. As the steps shrink, the cubic column dies away to nothing. The middle column settles to 0.338, which is three times the integral of W d t, just as predicted. And the totals never change: always W cubed, 1.966.
So here's the corrected chain rule. The change in f of W is f prime d W, the term you'd expect, plus one half f double prime d t: a new term that comes straight from d W squared equals d t. This is Itô's lemma.
Check it on W squared: f double prime is two, so the change is two W d W plus d t. Exactly what the telescoping sum told us, by a completely different route. For W cubed, three W squared d W plus three W d t: the two columns in the table. And for e to the W, the correction is one half e to the W d t.
Here's the lemma at work on our path. The faint thick curve is W squared itself. The red curve integrates the ordinary chain rule, two W d W, step by step: it falls further and further behind. Add Itô's correction, plus t, and it lands right on top.
Here's the intuition. Picture a curved bowl, f, and a point at x. The noise pushes x to the left or right by the same amount, h, with equal odds. On average, x hasn't moved. But f has: the average of the two outcomes is the midpoint of this chord, and on a convex curve, the chord lies above the curve. It sits higher by one half f double prime h squared. And h squared is delta t.
So noise, plus curvature, makes drift. Across two hundred paths, the average of W stays at zero, but the average of W squared climbs steadily: one unit of height per unit of time. That climb is the Itô term, one half f double prime d t.
The same argument works for anything driven by noise. Suppose X moves with a drift mu and a noise amplitude sigma: d X equals mu d t plus sigma d W. For a function of time and X, Taylor's theorem gives three terms that might survive: the time derivative, the slope times d X, and one half the curvature times d X squared.
Use the multiplication table on d X squared. It expands into three products. d t squared is zero, d t d W is zero, and d W squared is d t. So d X squared is just sigma squared d t.
Collect the terms: d f has a drift part, f t plus mu f x plus one half sigma squared f x x, all times d t, and a noise part, sigma f x d W. This is Itô's lemma in its general form, and it's the workhorse of everything that follows.
What it establishes: Taylor's theorem with ΔW ~ √Δt: which sums survive. For f = x³ the expansion is exact. df = f′dW + ½f″dt. Checks on W², W³, e^W. W² against ∫2W dW and ∫2W dW + t on our path. Convexity: the chord's midpoint sits ½f″h² above. The general form via (dX)² = σ²dt.; Simulated on screen: The three Taylor sums of W³ on the hero path at n = 16…2²² (cubic column → 0, middle → 3∫W dt = 0.338, total = W₁³ = 1.966 exactly); E[W_t²] = t over 200 paths.
9Growth, noise, and volatility drag5 min
Itô's lemma has consequences you can feel in your wallet. Here's a game. You start with a hundred dollars and flip a coin. Heads, your wealth grows by fifty percent. Tails, it shrinks by forty percent. On average, each round multiplies your money by 1.05: an expected gain of five percent per round. Should you play?
Here's one player over a hundred rounds, on a logarithmic scale. And here are eighty more, out of ten thousand we simulated. The expected wealth really does grow by five percent a round, to 131 and a half times the stake after a hundred rounds. But the typical player goes down, and down, and down. After a hundred rounds, the median player has half a percent of their money left, and 87 percent of the players lost money.
The average is held up by a handful of spectacularly lucky players, so rare that even the average of our ten thousand only reaches 52 times the stake, not 131. The reason is simple: one heads and one tails multiply your wealth by 1.5 times 0.6, which is 0.9. You lose ten percent every two rounds. For a typical path, what matters is the average of the logarithm, not the logarithm of the average.
Now the continuous version. Let a price S have returns made of a drift, mu d t, plus noise, sigma d W. That's geometric Brownian motion, the standard model of a stock price. To match the coin game, take mu equal to five percent and sigma equal to forty-five percent per round: the game's average return and its standard deviation.
Ordinary calculus suggests a solution: S equals S zero times e to the mu t plus sigma W. But check it with Itô's lemma. The function e to the mu t plus sigma w has time derivative mu f, slope sigma f, and curvature sigma squared f. So its change is S times mu d t, plus sigma d W, plus one half sigma squared d t. That extra term means the guess solves a different equation.
The way to solve it is to look at the logarithm. Apply Itô's lemma to log S: one over S, times d S, minus one half, one over S squared, times d S squared. d S squared is sigma squared S squared d t, by the multiplication table. So the change in log S is mu d t plus sigma d W, minus one half sigma squared d t. Constant coefficients: we can integrate directly.
Log S grows at the rate mu minus one half sigma squared, plus sigma times W. And the price is S zero, times e to the mu minus one half sigma squared, t, plus sigma W. The one half sigma squared is Itô's correction, and it's exactly what the naive guess was missing.
Let's check that numerically. Simulate the equation directly, one small step at a time, a million steps, with one fixed sequence of random kicks. The naive formula, driven by the same kicks, flies off: after a hundred rounds it's too big by a factor of about twenty-five thousand. Itô's formula sits right on top of the simulation.
Now we can see the coin game's paradox in the formula. Here are geometric Brownian paths with the game's parameters. The expected price grows like e to the mu t, because the exponential of a bell curve is pulled up by its lucky tail. But the typical path, the median, grows at the rate mu minus one half sigma squared. With mu at five percent and sigma at forty-five percent, that's minus five point one percent per round, almost exactly the coin game's minus five point three.
On the log scale, the final prices form a bell curve: the price itself is log-normal. Eighty-seven percent of paths end below where they started, even though the expected price has grown a hundred and fifty times. This is volatility drag, and it's Itô's correction term at work: noise doesn't just add uncertainty, it lowers the long-run growth rate, by exactly one half sigma squared.
What it establishes: The ×1.5 / ×0.6 coin game: E grows 1.05ⁿ (131.5× after 100 rounds), the median shrinks 0.9^(n/2), and 87% of players lose. GBM; the naive solution fails Itô's check; d ln S gives S₀e^((μ−σ²/2)t+σW). Volatility drag: μ − ½σ² = −5.1% vs the game's ½ln 0.9 = −5.3%.; Simulated on screen: 10,000 players × 100 rounds (losers asserted against the exact binomial, 86.4%); a 10⁶-step Euler–Maruyama run vs both formulas (the naive one off by e^10.1 ≈ 25,000×); 4,000 GBM paths (87.6% below the start, exact 87.3%).
10Stochastic differential equations4 min
With the integral and Itô's lemma in hand, we can finally write down noisy differential equations, and solve them. A stochastic differential equation says that over each instant, X changes by a drift, a steady push that depends on where X is, plus a random kick, whose size can also depend on where X is.
Remember, it's shorthand for an integral equation: X at time t is where it started, plus the accumulated drift, plus an Itô integral of the noise.
And we can simulate them directly. Step forward by delta t: add the drift times delta t, then add a random kick, the noise amplitude times root delta t times a fresh standard normal. Here's one step: the green arrow is the drift. The bell shows where the kick might land you. And a draw from it picks the next point.
Repeat, and you've drawn a sample path. This is how nearly every simulation of a stochastic differential equation works, from molecules to markets.
Here's the most important example after Brownian motion itself. The drift is minus theta X: always pulling back toward zero, harder the farther away you are. The green arrows show that pull. It's the Ornstein–Uhlenbeck process, invented in 1930 as the velocity of a Brownian particle slowed by friction. Today it also models interest rates, and anything that wanders but is pulled back to a mean.
Start forty particles at two, and let them go. The drift pulls them in, and the noise keeps them jittering. They settle into a band around zero, where the pull and the kicks balance.
And we can solve it exactly, with a trick from ordinary differential equations: an integrating factor. Look at e to the theta t, times X. Its time derivative is theta times itself, its slope in x is e to the theta t, and its curvature in x is zero: it's linear in x. So Itô's lemma gives the ordinary chain rule, with no correction, and the drift terms cancel exactly. Only the noise is left.
Integrate, and multiply back: X at time t is the starting point, decayed by e to the minus theta t, plus a weighted Itô integral of the noise, where old kicks are forgotten exponentially. The Itô integral has mean zero, so the mean just decays. And the isometry gives the variance as an ordinary integral: sigma squared over two theta, times one minus e to the minus two theta t. As time goes on, every particle forgets where it started, and the distribution settles to a bell curve with variance sigma squared over two theta.
Here's the prediction against three thousand simulated particles. As time runs, the histogram of where they are slides toward zero and widens, and the theoretical bell curve tracks it the whole way, until it locks into the stationary bell curve, with variance one half.
Notice what changed in this picture. We stopped following individual paths, and started watching the density of the whole cloud evolve, smoothly and deterministically. That density obeys a partial differential equation of its own, and Itô's lemma is how we find it.
What it establishes: dX = μdt + σdW as an integral equation. Euler–Maruyama, step by step. Ornstein–Uhlenbeck: the drift field, paths, the integrating-factor solution, mean and variance from the isometry, the stationary N(0, σ²/2θ).; Simulated on screen: 3,000 OU particles from X₀ = 2 with a live histogram against N(e^(−θt)X₀, σ²(1−e^(−2θt))/2θ) (asserted at t = ¼, 1, 4).
11From paths to densities: Fokker–Planck4 min
So here's the question. If every particle in a cloud follows the same stochastic differential equation, each with its own independent noise, how does the density of the cloud change over time?
Itô's lemma answers it, with a classic trick: don't look at the density directly. Look at the average of some smooth test function, phi, of X. By Itô's lemma, phi of X changes by a drift term, mu phi prime plus one half sigma squared phi double prime, plus a noise term. Take the average, and the noise term vanishes: Itô integrals have mean zero.
An average is an integral against the density p. Now integrate by parts: once to move the derivative off phi prime, twice for phi double prime. The boundary terms vanish, and we get phi times something, integrated. Since this holds for every test function phi, the somethings must be equal.
The result: the rate of change of the density is minus the slope of mu times p, plus one half the curvature of sigma squared times p. This is the Fokker–Planck equation, also called Kolmogorov's forward equation. The first term carries probability along with the drift. The second spreads it out. Randomness in each path became a perfectly deterministic equation for the cloud.
Start with the simplest case: pure Brownian motion, no drift, sigma equal to one. Then Fokker–Planck is the heat equation: the density changes at a rate equal to one half its curvature. It's the same equation Einstein derived for diffusing particles. Here are four thousand particles released at one point. Their histogram spreads out, exactly along the bell curve with variance t, which solves the heat equation.
You can see why it spreads. At the peak, the curve bends down, so the density falls. Out on the shoulders, it bends up, so the density rises. Peaks get shaved, valleys get filled, and the bell flattens. And the width grows like the square root of time.
Now something richer. Let the drift be the downhill slope of a landscape with two valleys, so particles roll toward the bottoms, while the noise keeps shaking them. Drop three thousand particles into the left valley.
At first they huddle in the left valley, and the density there settles into a bell. But every so often, a run of unlucky kicks throws a particle over the ridge. Slowly, the right valley fills. And all along, the histogram of the simulated particles follows the Fokker–Planck equation, solved on a computer as a smooth curve, with no randomness at all.
Eventually the cloud stops changing. Setting the time derivative to zero, and the flow of probability to zero, gives a first-order equation we can solve: the stationary density is proportional to e to the minus two V over sigma squared. That's exactly Boltzmann's distribution from statistical mechanics, with the noise strength playing the role of temperature. Our simulated particles have found it: by the end, they're split nearly half and half between the valleys.
What it establishes: The derivation with a test function and integration by parts. The heat equation; curvature arrows. The double well V = (x² − 1)²: hopping over the barrier, histogram vs PDE, the Boltzmann limit e^(−2V/σ²) from zero flux.; Simulated on screen: 4,000 Brownian particles; 3,000 particles in the double well over t ∈ [0, 40] (σ = 0.8) beside a finite-volume Fokker–Planck solve (both asserted to reach Boltzmann).
12Backwards: averages over paths solve PDEs4 min
Fokker–Planck runs forward in time: given where the particles start, where will they be? Now turn the question around. Start a particle at x. Some payoff g depends on where it ends up at time T. What is that payoff worth on average? Call the answer u of t and x.
Here's the simplest case: a Brownian gambler starts with fortune point three, and plays until reaching one, a win, or zero, ruin. Each path is colored by how it ended. Out of four thousand simulated gamblers, 29.5 percent reach the top first, and the game lasts 0.203 time units on average.
Both numbers have exact answers, and here's where they come from. Let u of x be the chance of winning from x. Your chance, re-evaluated as the game goes on, is a fair game: it's a martingale. So by Itô's lemma, its drift, one half u double prime, must be zero. u is a straight line, zero at zero and one at one: u of x equals x. Point three. The same argument for the expected time gives one half u double prime equals minus one, and the answer x times one minus x: 0.21.
The same argument works for any payoff. Your best forecast of the payoff, given everything you know at time s, is u of s and X s. As information arrives, the forecast gets updated, but it can't be expected to drift: if you expected it to rise, you'd have raised it already. It's a martingale. Itô's lemma splits its change into a drift term and a noise term. A martingale has no drift, so the drift term must vanish, everywhere.
That's a partial differential equation for u, Kolmogorov's backward equation, solved backward from the payoff at the final time. Add a discount rate, and you get the Feynman–Kac formula: averages over random paths solve partial differential equations. Mark Kac found it in 1949, inspired by Feynman's path integrals in quantum mechanics.
In two dimensions, this idea solves a classic problem of physics. Heat the rim of a metal disk: three hot arcs, three cold ones. Wait for the temperature inside to settle. The steady temperature solves Laplace's equation: zero curvature, on average, in every direction. What's the temperature at this point?
Brownian motion knows. Release a random walker from the point, let it wander until it hits the rim, and record the temperature where it lands. Do it again, and again. The average temperature they report converges to the temperature at the point.
With twenty thousand walkers, the average is 0.533. The exact solution of Laplace's equation at that point: 0.534. The reason is Itô's lemma once more: for two-dimensional Brownian motion the drift term is one half the Laplacian, so a function with zero Laplacian, evaluated along the walk, is a fair game. Averaging where the walkers stop gives the value where they started.
Now do that at every point of the disk at once. With one walker per pixel, each pixel is just hot or cold: pure noise. Four walkers. Sixteen. Sixty-four. Two hundred fifty-six. The noise melts into the smooth solution of Laplace's equation. Shizuo Kakutani discovered this connection in 1944: harmonic functions are averages over Brownian paths.
So there are two bridges between random paths and partial differential equations. Fokker–Planck pushes densities forward in time. Kolmogorov and Feynman–Kac pull averages backward. Both come straight out of Itô's lemma.
What it establishes: u(t, x) = E[g(X_T) | X_t = x]. Gambler's ruin: P(top) = x, E τ = x(1 − x). The martingale argument gives Kolmogorov's backward equation, and discounting gives Feynman–Kac. Kakutani: walkers solve Δu = 0 in a disk with three hot and three cold arcs.; Simulated on screen: 4,000 exits from (0, 1) (29.5% vs 30%; 0.203 vs 0.21); 36 walker paths and 20,000 walk-on-spheres exits from one point (0.5328 vs exact 0.5340); Monte Carlo fields with 1–256 walkers per pixel vs the exact solution.
13Black–Scholes: hedging the noise away4 min
Here's the application that made stochastic calculus famous. A stock follows geometric Brownian motion. A call option gives you the right, but not the obligation, to buy the stock at a fixed price K at a future time T. If the stock ends above K, you collect the difference; if not, you walk away with nothing. What is that right worth today?
Call its value V, a function of time and the stock price. Itô's lemma tells us how V changes: a drift part, which includes the curvature term one half sigma squared S squared V S S, and a noise part, sigma S V S d W.
Black and Scholes, with Robert Merton, had a brilliant idea: hedge. Hold the option, and sell delta shares of the stock. The portfolio's change is the option's change minus delta times the stock's change. Both have noise in them, sigma S d W, and both have the drift mu.
Now choose delta to be exactly V S, the option's sensitivity to the stock. The noise term cancels. And so does mu: the stock's expected return has dropped out entirely. What's left is perfectly predictable.
A riskless portfolio must earn the risk-free interest rate, r, or there'd be free money to be made. Set the two equal, and rearrange: V t plus r S V S, plus one half sigma squared S squared V S S, minus r V, equals zero. That's the Black–Scholes equation. And the term that makes it work, the curvature term, is Itô's correction.
And we know how to solve equations like this one: Feynman–Kac. The option's value is the discounted average payoff, computed as if the stock grew at the risk-free rate r instead of mu. For a call, the average can be done in closed form: the famous Black–Scholes formula.
Here's the value as a function of the stock price, a year before expiry, then closer and closer, until it becomes the hockey-stick payoff. With a stock at a hundred, a strike of a hundred, five percent interest and twenty percent volatility, the formula gives 10.4506. Averaging the payoff over a million simulated risk-neutral paths gives 10.4512, plus or minus 0.015.
The derivation is also a recipe. Here's a simulated stock over one year. Here's what the option is worth along the way. Now start with the option's price in cash, and each week, hold delta shares of the stock, financed from the cash. The portfolio tracks the option, week after week, and at expiry it lands within a dollar of the payoff, using nothing but the stock and a bank account.
How good is the hedge? Here's the leftover error after a year, across five thousand simulated years, rebalancing four times, sixteen, sixty-four, and two hundred fifty-six times. Each time you rebalance four times as often, the error halves, from 3.25 dollars down to 43 cents. In the continuous limit it vanishes: the option can be manufactured exactly, so its price is forced. And the leftover error on each step comes from how far delta W squared strays from delta t: the very fluctuation that dies away in the quadratic variation.
What it establishes: The call payoff; Itô on V(t, S); Δ = V_S cancels the noise and μ; the PDE; Feynman–Kac and the closed form; replication; hedging error ∝ 1/√n.; Simulated on screen: The price 10.4506 vs 10⁶ risk-neutral paths (10.4512 ± 0.0147); one weekly-rebalanced replication; 5,000 years of hedging at 4/16/64/256 rebalances (sd 3.25 → 0.43).
14Changing the odds: Girsanov's theorem3 min
One last idea, and it's a strange one: change the probabilities, not the paths. Here are two thousand Brownian paths, all equally likely. Now give each path a weight, Z, equal to e to the theta W at time one, minus one half theta squared, and draw it with opacity proportional to its weight.
Turn up theta. Paths that end high get heavier; paths that end low fade away. The weighted average path tilts up into a straight line of slope theta, and the weighted distribution of where the paths end slides over to a bell curve centered at theta. Under the new weights, W looks exactly like Brownian motion with drift theta. Turn theta negative, and the drift goes down.
Where does that weight come from? Compare the bell curve for one step with drift theta to the one without. Their ratio is e to the theta delta W, minus one half theta squared delta t. The steps are independent, so for a whole path the ratios multiply, and the exponents add up to theta W at time T minus one half theta squared T.
And that minus one half theta squared is Itô's correction yet again. Apply Itô's lemma to Z: the minus one half theta squared from the time derivative exactly cancels the plus one half theta squared from the curvature, so Z has no drift. It's a martingale, with average one, which makes it a legitimate way to reweight probabilities.
That's Girsanov's theorem: reweighting by Z turns W into a Brownian motion with drift theta, or, equivalently, W minus theta t into a standard Brownian motion. Changing the drift is the same as changing the odds.
This explains the strangest step in Black–Scholes. In the real world, the stock drifts at mu. Reweight with theta equal to r minus mu, over sigma, and under the new probabilities, the stock drifts at exactly the risk-free rate. That's the risk-neutral world, where the option price is a plain discounted average. It isn't an assumption about investors: it's Girsanov's theorem.
Changing the odds is also a practical tool. Suppose you need the probability of a rare event: say, Brownian motion ending above four at time one. The exact answer is about three in a hundred thousand. Simulate a hundred thousand paths, and you'll see it about three times. We saw it once: an estimate off by a factor of three.
Instead, simulate with a drift of four, so half the paths land in the rare region, and undo the change by weighting each path with Girsanov's factor. Ten thousand tilted paths give 3.24 times ten to the minus five, within about two percent of the truth. This is importance sampling, and it's how banks and engineers estimate the probability of disasters.
What it establishes: Reweighting paths by Z = e^(θW − θ²/2) gives drift θ. The density-ratio derivation; Z is a martingale (Itô again). The risk-neutral measure θ = (r − μ)/σ. Importance sampling.; Simulated on screen: 2,000 paths drawn with opacity ∝ weight (effective sample size asserted > 300 at θ = 1.2); P(W₁ > 4): 1 hit in 10⁵ plain samples vs 3.24 × 10⁻⁵ ± 2% from 10⁴ tilted ones (exact 3.17 × 10⁻⁵).
15Recap1 min
Let's put it all together. It started with one fact: over a short time d t, Brownian motion moves about root d t. That makes its paths rough at every scale, with infinite length, but their squared increments add up to exactly the elapsed time: d W squared equals d t.
That one rule decides everything else. Integrals against noise have to be taken at the left end of each step, so they're fair games, and the integral of W d W picks up a minus one half t. The chain rule picks up a correction, one half f double prime d t: noise acting on curvature creates drift. That's why noisy growth compounds at mu minus one half sigma squared.
Averaging Itô's lemma turns random paths into deterministic equations: Fokker–Planck pushes densities forward in time, and Kolmogorov and Feynman–Kac pull averages backward, which is how random walkers solve Laplace's equation. And in finance it all comes together: Black and Scholes hedged the noise away to price an option, and Girsanov's theorem explains why that price is an average in a world where the stock grows at the risk-free rate.
All of it, from one line. d W squared equals d t. Thanks for watching.
What it establishes: Recap, while the hero path keeps zooming; the multiplication table; the history of the ideas.
Notes and sources
Sources
Fact-check notes and sources
The mathematics is standard; the derivations follow the usual textbook arguments (e.g. Øksendal, Stochastic Differential Equations; Shreve, Stochastic Calculus for Finance II; Karatzas & Shreve, Brownian Motion and Stochastic Calculus). Historical claims:
- Robert Brown observed the motion of particles from pollen grains (of Clarkia pulchella) in water in 1827 (published 1828).
- Louis Bachelier, Théorie de la spéculation (1900): Brownian motion as a model of prices on the Paris Bourse.
- Albert Einstein (1905): mean squared displacement ∝ t and the diffusion equation; Jean Perrin's experiments (1908–1909) confirmed it and measured Avogadro's number.
- Paul Langevin (1908): the first stochastic differential equation, for the velocity of a Brownian particle.
- Norbert Wiener, Differential space (1923): a rigorous construction of Brownian motion.
- Adriaan Fokker (1914), Max Planck (1917); Andrey Kolmogorov (1931): the forward and backward equations.
- Leonard Ornstein and George Uhlenbeck, On the theory of the Brownian motion (1930).
- Kiyosi Itô, Stochastic integral (1944) and On a formula concerning stochastic differentials (1951).
- Shizuo Kakutani, Two-dimensional Brownian motion and harmonic functions (1944).
- Robert Cameron and William Martin (1944) and Igor Girsanov (1960): changes of measure for Brownian motion.
- Mark Kac, On distributions of certain Wiener functionals (1949), inspired by Richard Feynman's path integrals (1948).
- Monroe Donsker (1951): the invariance principle (rescaled random walks converge to Brownian motion).
- Eugene Wong and Moshe Zakai (1965): smooth approximations of noise converge to Stratonovich integrals; Ruslan Stratonovich (1966).
- Fischer Black and Myron Scholes, The pricing of options and corporate liabilities, and Robert Merton, Theory of rational option pricing (both 1973).
On-screen simplifications, stated here for the record:
- "Itô integrals of adapted strategies are martingales" assumes the usual square-integrability (E∫H²dt < ∞).
- The coin-game "median" line is the continuous 0.9^(n/2); the true median of the discrete game moves in steps (it equals 0.9⁵⁰ exactly at n = 100).
- The double-well particles are drawn slightly above the potential curve, so the glow doesn't hide it. The heat-equation particles are spread vertically only for visibility (labeled on screen).
- The molecular-kick picture in chapter 1 is a schematic (labeled). The Euler–Maruyama walkthrough in chapter 10 is a real computation: eight steps of the OU equation with seeded kicks.
What is computed and built
Every item is a NumPy simulation with its own seed (PCG64), cached in
.cache/stochastic/<item>.npz. The checks run every time the item is computed.
Numbers the narration quotes are also asserted in the scene code, where they
are used.
| Item | What | Checks |
|---|---|---|
hero |
One Brownian path on [0, 1] at 2²² = 4,194,304 steps (seed 174, picked by eye among the seeds that pass hero_ok, i.e. end in (0.9, 1.3) and stay on screen: 4, 87, 119, 140, 145, 152, 174, …); its left / right / midpoint sums, quadratic and total variation, and the three Taylor sums of W³, at n = 4…2²² |
Exact identities at every n: left = ½W² − ½Q, right = ½W² + ½Q, mid = ½W², the Taylor sums add to W³. Q(2²²) = 1.00002; the cubic sum → 0; the middle one → 3∫W dt |
others |
Five more paths at 2¹⁶ steps | ½W₁² − Σ W ΔW within 0.02 of ½ on each |
walk |
Coin-flip walks at n = 16…4,096; 20,000 walks of 64 flips | mean ≈ 0, variance ≈ 1 |
fan |
200 paths at 512 steps; 20,000 samples of W at t = ¼, ½, 1 | Var = t; 68.3% within ±√t, 95.5% within ±2√t |
hook2d |
One 2D particle; 2,000 particles diffusing | ⟨r²⟩ = 2·(0.12)²·k within 8% |
qv |
Σ(ΔW)² on 4,000 fresh paths at n = 16, 256, 4,096 | mean 1; sd within 6% of √(2/n) |
ito_mc |
40,000 left-endpoint integrals ∫₀¹ W dW at n = 1,000 | mean within 3 sd of 0; variance within 0.02 of ½; the naive ½W₁² averages ½ |
coin |
10,000 players × 100 rounds of ×1.5 / ×0.6 | share of losers within 1% of the exact binomial P(heads ≤ 55) = 86.4% |
gbm |
One path at 10⁶ Euler–Maruyama steps vs the naive and Itô solutions; 4,000 exact GBM paths (μ = 0.05, σ = 0.45, T = 100) | EM within 0.05 (in log) of Itô's formula; the naive formula off by > e⁹; share below the start within 2.5% of Φ(−(μ − σ²/2)T/σ√T) |
ou |
3,000 Ornstein–Uhlenbeck particles (θ = σ = 1, X₀ = 2), Euler–Maruyama | mean and variance at t = ¼, 1, 4 against the exact formulas |
heat |
4,000 Brownian particles from 0 | Var X₁ = 1 |
well |
3,000 particles in V = (x² − 1)², σ = 0.8, t ≤ 40; Fokker–Planck by finite volumes (upwind drift, central diffusion, zero-flux walls) | the PDE conserves mass and ends within 0.03 (total variation) of Boltzmann; the particles within 0.06 |
exit |
4,000 Brownian paths from 0.3 until they leave (0, 1), Δt = 10⁻⁵ | P(top) within 3 se of 0.3; E τ within 0.01 of 0.21 |
disk |
36 walker paths (small Euler steps); 20,000 walk-on-spheres exits from z₀ = (0.32, 0.2); Monte Carlo fields at 1…256 walkers per pixel on a 160 × 160 grid | the mean at z₀ within 3 se of the exact ½ + arctan(2r³ sin 3θ / (1 − r⁶))/π; mean field error at 256 walkers < 0.03 |
hedge |
Black–Scholes (S₀ = K = 100, r = 0.05, σ = 0.2, T = 1); 10⁶ risk-neutral payoffs; delta hedging under μ = 0.10 at 4, 16, 64, 256 rebalances × 5,000 paths; one weekly path | MC within 3 se of the formula; sd ratios within 0.35 of 2 per 4× rebalancing |
girsanov |
2,000 paths at 256 steps; 10⁵ plain and 10⁴ tilted samples of W₁ | weighted means of W₁ within 0.12 of θ ∈ {0.5, 1, 1.2, −1}, effective sample size > 300; the importance-sampling estimate within 3 se of Φ(−4) |
Chapter notes
| # | Scene | What it establishes | Simulated on screen |
|---|---|---|---|
| 1 | Hook |
Brown's jittering particles; Einstein's ⟨r²⟩ ∝ t. Brownian motion as the model of noise. The puzzle: Σ W ΔW on our path is 0.2847, but ½W₁² is 0.7847. The gap is 0.5000, and it stays ½ on five more paths. The plan. | A 2D particle with a trail; 2,000 particles spreading (mean squared displacement asserted linear); the hero path's left sum at 2²² steps; five more paths at 2¹⁶ steps. |
| 2 | RandomWalk |
Var X_t = t·(Δx)²/Δt, so only Δx = √Δt gives a limit. The same coin flips scaled by Δt, √Δt, Δt^¼. CLT. W_t ~ N(0, t). The four defining properties; Wiener, Donsker. | Walks at n = 16…4,096; 20,000 walks of 64 flips; 200 Brownian paths with N(0, t) snapshots (68.3% / 95.5% inside ±√t / ±2√t). |
| 3 | Roughness |
Zooming a smooth curve gives its tangent line. Zooming Brownian motion 4:4 makes it steeper; 4:2 makes it statistically the same (W_ct = √c W_t). Secant slopes ~ 1/√h. Total variation √(2n/π) → ∞, so Riemann–Stieltjes integration fails. | The hero path itself, zoomed 4⁵ = 1,024× in time (min/max decimation keeps the roughness); its secant slopes at h = 4⁻¹…4⁻⁷; its total variation at n = 16…2²². |
| 4 | QuadraticVariation |
Squares on each increment, poured into a tank of capacity T. Smooth: Σ(Δf)² → 0. Brownian: Σ(ΔW)² → T. E = T and Var = 2TΔt (E Z⁴ = 3). The running sum lies on y = t. (dW)² = dt and the multiplication table. | The hero path's Σ(ΔW)² at n = 16…2²² (1.280 → 1.0000); Σ(ΔW)² on 4,000 fresh paths at n = 16, 256, 4,096 (sd asserted √(2/n)). |
| 5 | ItoIntegral |
Noise isn't a function (ΔW/Δt spikes grow). The integral form of an SDE. Gambling: stake × move, with the future behind a curtain (adapted). ∫H dW as the limit of left-endpoint sums. | The hero path's slopes; the H = W strategy step by step; its winnings at n = 16…4,096 converging to 0.2847. |
| 6 | MissingHalf |
Left / right / midpoint sums differ by Σ(ΔW)². The telescoping identity W_T² = 2∫W dW + T. The picture: every left-endpoint rectangle misses a triangle of area ½(ΔW)², and the triangles fill a tank of capacity ½T. Itô vs Stratonovich; only the left end is a fair game. Wong–Zakai. | The three sums at 2²² steps; the triangles of 16 and 256 steps, and their total at 2²² (0.5000). |
| 7 | ItoRules |
E[∫H dW] = 0 (martingale). The isometry from the cross-term grid. A check with H = W: mean 0, variance ½, a hard left edge at −½; the naive ½W₁² averages ½. | 200 winnings paths and their mean; 40,000 Itô integrals (mean −0.0007, variance 0.505) against the exact density of (Z² − 1)/2. |
| 8 | ItoLemma |
Taylor's theorem with ΔW ~ √Δt: which sums survive. For f = x³ the expansion is exact. df = f′dW + ½f″dt. Checks on W², W³, e^W. W² against ∫2W dW and ∫2W dW + t on our path. Convexity: the chord's midpoint sits ½f″h² above. The general form via (dX)² = σ²dt. | The three Taylor sums of W³ on the hero path at n = 16…2²² (cubic column → 0, middle → 3∫W dt = 0.338, total = W₁³ = 1.966 exactly); E[W_t²] = t over 200 paths. |
| 9 | GeometricBM |
The ×1.5 / ×0.6 coin game: E grows 1.05ⁿ (131.5× after 100 rounds), the median shrinks 0.9^(n/2), and 87% of players lose. GBM; the naive solution fails Itô's check; d ln S gives S₀e^((μ−σ²/2)t+σW). Volatility drag: μ − ½σ² = −5.1% vs the game's ½ln 0.9 = −5.3%. | 10,000 players × 100 rounds (losers asserted against the exact binomial, 86.4%); a 10⁶-step Euler–Maruyama run vs both formulas (the naive one off by e^10.1 ≈ 25,000×); 4,000 GBM paths (87.6% below the start, exact 87.3%). |
| 10 | SDEs |
dX = μdt + σdW as an integral equation. Euler–Maruyama, step by step. Ornstein–Uhlenbeck: the drift field, paths, the integrating-factor solution, mean and variance from the isometry, the stationary N(0, σ²/2θ). | 3,000 OU particles from X₀ = 2 with a live histogram against N(e^(−θt)X₀, σ²(1−e^(−2θt))/2θ) (asserted at t = ¼, 1, 4). |
| 11 | FokkerPlanck |
The derivation with a test function and integration by parts. The heat equation; curvature arrows. The double well V = (x² − 1)²: hopping over the barrier, histogram vs PDE, the Boltzmann limit e^(−2V/σ²) from zero flux. | 4,000 Brownian particles; 3,000 particles in the double well over t ∈ [0, 40] (σ = 0.8) beside a finite-volume Fokker–Planck solve (both asserted to reach Boltzmann). |
| 12 | FeynmanKac |
u(t, x) = E[g(X_T) | X_t = x]. Gambler's ruin: P(top) = x, E τ = x(1 − x). The martingale argument gives Kolmogorov's backward equation, and discounting gives Feynman–Kac. Kakutani: walkers solve Δu = 0 in a disk with three hot and three cold arcs. | 4,000 exits from (0, 1) (29.5% vs 30%; 0.203 vs 0.21); 36 walker paths and 20,000 walk-on-spheres exits from one point (0.5328 vs exact 0.5340); Monte Carlo fields with 1–256 walkers per pixel vs the exact solution. |
| 13 | BlackScholes |
The call payoff; Itô on V(t, S); Δ = V_S cancels the noise and μ; the PDE; Feynman–Kac and the closed form; replication; hedging error ∝ 1/√n. | The price 10.4506 vs 10⁶ risk-neutral paths (10.4512 ± 0.0147); one weekly-rebalanced replication; 5,000 years of hedging at 4/16/64/256 rebalances (sd 3.25 → 0.43). |
| 14 | Girsanov |
Reweighting paths by Z = e^(θW − θ²/2) gives drift θ. The density-ratio derivation; Z is a martingale (Itô again). The risk-neutral measure θ = (r − μ)/σ. Importance sampling. | 2,000 paths drawn with opacity ∝ weight (effective sample size asserted > 300 at θ = 1.2); P(W₁ > 4): 1 hit in 10⁵ plain samples vs 3.24 × 10⁻⁵ ± 2% from 10⁴ tilted ones (exact 3.17 × 10⁻⁵). |
| 15 | Outro |
Recap, while the hero path keeps zooming; the multiplication table; the history of the ideas. |
The visual languageColor legend (consistent across every scene)
| Concept | Color |
|---|---|
| Brownian motion W, dW, the noise term σ dW | blue |
| time, dt, Δt | teal |
| (dW)², quadratic variation, Itô's correction ½f″dt, the missing half | yellow |
| drift μ, μ dt | green |
| the integrand H (stake, position, Δ) | lilac |
| the Itô integral, winnings | gold |
| left / right / midpoint (Stratonovich) sums | pale green / pale red / pink |
| densities, histograms, Fokker–Planck | orange |
| the mean | white |
| the median, typical growth | pale teal |
| option values | pale purple |
| the hedge portfolio | light brown |
| Girsanov weights | rose |
| boundary temperature 1 / 0 | amber / slate blue |
Build the film
python -m videos.math.stochastic.compute # the film's numbers, into .cache/stochastic
python tools/build.py stochastic # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py stochastic Hook # one chapter, silent, with a contact sheet
Scenes: videos/math/stochastic. Setup: see the course page. Source of these notes: the README and the scenes' narration.