Stochastic Differential Equations, Brownian Motion, and Itô’s Lemma Wiener process · quadratic variation (dW)² = dt · Itô integral & isometry · Itô’s lemma · Ornstein–Uhlenbeck
A Recurrence That Turns Any Start Into N(0, 1)
Motivation
Start 10,000 copies at x_0 = 2 and iterate x_{k+1} = 0.99\,x_k + \sqrt{0.02}\,\xi_k with \xi_k \sim \mathcal{N}(0, 1)(h = 0.01,t = kh). By 400 steps, every trace of x_0 = 2 has vanished into \mathcal{N}(0, 1):
Why \sqrt{h} Instead of h? Over step h = 0.01, the deterministic decay 0.99 = 1 - h changes x by O(h), but the noise kick \sqrt{2h} = \sqrt{0.02} \approx 0.141 has size O(\sqrt{h}). Its square is O(h), breaking the ordinary chain rule.
Why Deterministic Flows Cannot Forget Their Start
Forward Noising Processes
A generative diffusion model needs a forward process that maps every data distribution p_0 = p_{\text{data}} to the same tractable prior p_T \approx \mathcal{N}(\mathbf{0}, \mathbf{I}). No invertible ODE flow \Phi_T can do this (if \Phi_T mapped two laws p \ne q to the same law, applying \Phi_T^{-1} would force p = q):
Drift Alone (\dot{x} = -x): Collapses x_0 = \pm 2 to the point mass 0(\pm 0.0996 at t=3), not a Gaussian.
Noise Alone (dX = \sqrt{2}\,dW): Spreads each start as \mathcal{N}(x_0, 2t) (variance-exploding); usable once \sqrt{2t} \gg |x_0|, but has no stationary limit.
Drift Plus Noise (dX = -X\,dt + \sqrt{2}\,dW): Mean decay and noise injection balance at the stationary law \mathcal{N}(0, 1)(\mathcal{N}(\pm 0.0996, 0.9975) by t = 3).
From Random Walks to the √Δt Scaling Law
Constructing Brownian Motion
Over k = t/\Delta t independent steps of size \pm c(\Delta t)^a, the total variance at time t scales as:
Unique critical exponent (a = 1/2): If a > 1/2, the variance vanishes as \Delta t \to 0; if a < 1/2, it explodes to \infty. Only \pm\sqrt{\Delta t} steps survive in the limit W_t \sim \mathcal{N}(0, t).
The Wiener Process: Axioms, Covariance, and Roughness
Brownian Motion
The continuous-time limit W_t (Brownian motion or the Wiener process) is characterized by four axioms: (1) W_0 = 0; (2) independent incrementsW_t - W_s for s < t; (3) Gaussian incrementsW_t - W_s \sim \mathcal{N}(0, t - s); and (4) continuous sample paths.
Exact Increment Recipe: Over any interval \Delta t, \Delta W = W_{t + \Delta t} - W_t = \sqrt{\Delta t}\,\xi, \quad \xi \sim \mathcal{N}(0, 1)
Nowhere Differentiable Paths: The difference quotient blows up as \Delta t \to 0: \left|\frac{\Delta W}{\Delta t}\right| = \frac{|\xi|}{\sqrt{\Delta t}} \;\xrightarrow{\Delta t \to 0}\; \infty
Pointwise Marginals vs. Pathwise Envelopes
Simulating Brownian Paths
At any single fixed time t, W_t \sim \mathcal{N}(0, t) lies inside the \pm 2\sqrt{t} two-standard-deviation envelope with probability 95.4\%. What fraction of 20{,}000 simulated paths stays inside \pm 2\sqrt{t} across all grid times on [0, 1]?
inside +-2 sqrt(t) at t = 1: 0.954 (Gaussian: 0.954)
inside at all 50 grid times: 0.697
inside at all 500 grid times: 0.535
Pointwise vs. Pathwise Laws: Every additional inspection time gives a jagged path another chance to cross the boundary (70\% stay inside across 50 times, 54\% across 500 times, and 0\% in continuous time because Brownian paths cross \pm 2\sqrt{t} infinitely often near t = 0).
Quadratic Variation of Brownian Motion: (dW)² = dt
Foundation of Itô Calculus
Partition [0, t] into 0 = t_0 < t_1 < \cdots < t_n = t with mesh h_{\max} = \max_i \Delta t_i. For a smooth path |x'(t)| \le M, the sum of squared increments vanishes (\sum_i (\Delta x_i)^2 \le M^2 h_{\max} t \to 0). For Brownian motion, the random sum converges to the deterministic time t:
Mean Equals Elapsed Time: Since \Delta W_i \sim \mathcal{N}(0, \Delta t_i), \mathbb{E}[Q_n] = \sum_{i=0}^{n-1} \mathbb{E}\!\left[(\Delta W_i)^2\right] = \sum_{i=0}^{n-1} \Delta t_i = t
Variance Vanishes as O(h_{\max}): Using \mathbb{E}[\xi^4] = 3, \operatorname{Var}((\Delta W_i)^2) = 2\Delta t_i^2, so by independence: \mathbb{E}\!\left[(Q_n - t)^2\right] = \operatorname{Var}(Q_n) = 2\sum_{i=0}^{n-1} \Delta t_i^2 \le 2h_{\max}t \to 0
Measuring Quadratic Variation on a Single Path
Numerical Verification
Viewing a single Brownian realization on [0, 1] across subgrids of n = 16 up to 2^{18} intervals confirms that \sum_{i=0}^{n-1} (\Delta W_i)^2 \to 1 with standard deviation \sqrt{2/n}, whereas \sum (\Delta \sin 2\pi t_i)^2 \approx 2\pi^2 / n \to 0:
n QV of W sqrt(2/n) QV of sin 2 pi^2/n
16 1.1551 0.3536 1.217927 1.233701
64 0.9103 0.1768 0.308177 0.308425
256 0.8957 0.0884 0.077102 0.077106
1024 0.9560 0.0442 0.019277 0.019277
4096 1.0044 0.0221 0.004819 0.004819
16384 0.9893 0.0110 0.001205 0.001205
65536 1.0007 0.0055 0.000301 0.000301
262144 1.0017 0.0028 0.000075 0.000075
The Itô Multiplication Table: In stochastic differentials, squared Brownian increments survive at first order while higher products vanish: (dW)^2 = dt, \qquad dW\,dt = 0, \qquad (dt)^2 = 0
Why Riemann Sums Disagree on Stochastic Integrals
The Evaluation-Point Dilemma
For a smooth curve, left-endpoint and right-endpoint Riemann sums converge to the same integral. For \int_0^t W_s\,dW_s, their difference is the quadratic variation:
left sum -0.3614 right sum 0.6124
right - left 0.9738 sum of (dW)^2 0.9738
Two Different Limits: Because the sum of left and right approximations telescopes (\sum_i (W_{t_{i+1}} + W_{t_i})\Delta W_i = \sum_i (W_{t_{i+1}}^2 - W_{t_i}^2) = W_t^2), the left-endpoint sum converges to \frac{1}{2}(W_t^2 - t) while the right-endpoint sum converges to \frac{1}{2}(W_t^2 + t).
The Itô Integral and the Itô Isometry
Stochastic Integration
Itô’s integral evaluates H_s at the left endpointt_i, so H_i is independent of the future kick \Delta W_i = W_{t_{i+1}} - W_{t_i}:
Drift f(X, t): The conditional mean velocity over a short interval, \mathbb{E}[dX \mid X_t] = f(X_t, t)\,dt.
Diffusion g(X, t): The noise amplitude setting the local variance injection rate, \operatorname{Var}(dX \mid X_t) = g(X_t, t)^2\,dt.
Additive vs. Multiplicative Noise:
Additive Noise (g = g(t)): Noise amplitude depends only on time (used in all standard diffusion models).
Multiplicative Noise (g = g(X, t)): Noise amplitude scales with the state (e.g., geometric Brownian motion g(X) = \nu X).
Why the Ordinary Chain Rule Fails: Jensen’s Gap
Geometric Intuition for Itô’s Lemma
The ordinary chain rule predicts d(W_t^2) = 2W_t\,dW_t, which integrates to \int_0^t 2W_s\,dW_s = W_t^2 - t, missing the +t term. One step of a coin-flip walk shows why any curved function \phi(x) experiences a deterministic drift from symmetric noise:
Symmetric Kick on a Convex Curve: From x, a step \pm\sqrt{\Delta t} lands at x + \sqrt{\Delta t} or x - \sqrt{\Delta t} with probability \frac{1}{2} each.
Second-Order Jensen Gap: For \phi(x) = x^2(\phi''(x) = 2), the average value after the step is: \frac{1}{2}\left[(x + \sqrt{\Delta t})^2 + (x - \sqrt{\Delta t})^2\right] = x^2 + \Delta t = \phi(x) + \frac{1}{2}\phi''(x)\,\Delta t
Non-Vanishing Rate: Because (\Delta W)^2 \approx \Delta t, the curvature gain +\frac{1}{2}\phi''(x) per unit time survives the \Delta t \to 0 limit.
Theorem: Itô’s Lemma (The Stochastic Chain Rule)
Core Theorem
Expanding \phi(X_t, t) to second order in dX = f\,dt + g\,dW and applying (dX)^2 = g^2(dW)^2 = g^2\,dt yields Itô’s lemma:
Multivariate isotropic form (\mathbb{R}^d):d\phi = (\partial_t\phi + \nabla\phi\cdot\mathbf{f} + \tfrac12 g(t)^2\Delta\phi)\,dt + g(t)\nabla\phi\cdot d\mathbf{W}_t, where \tfrac12 g^2\Delta\phi is the Itô curvature correction.
Watching the Itô Correction Accumulate Along One Path
Numerical Verification of Itô’s Lemma
On X_t = W_t(f = 0, g = 1) with \phi(x) = x^2, Itô’s lemma gives d(W_t^2) = 2W_t\,dW_t + dt, so W_t^2 - \int_0^t 2W_s\,dW_s = t deterministically along every individual path:
final gap W_1^2 - int 2W dW = 0.9738 (Ito correction: t = 1)
max |gap_t - t| along the path = 0.0364
The naive chain-rule curve \int_0^t 2W_s\,dW_s sags below W_t^2 by the running quadratic variation \sum (\Delta W_i)^2 \approx t; adding +t restores exact pathwise agreement.
Worked Application: Geometric Brownian Motion
Multiplicative Noise & Concave Drift Shift
The SDE dX_t = \mu X_t\,dt + \nu X_t\,dW_t(X_0 > 0) models a positive quantity whose noise amplitude g(X) = \nu X is proportional to its current level (multiplicative noise):
Log-Transform via Itô’s Lemma: Apply Itô’s lemma to \phi(x) = \log x, which has \phi'(x) = \frac{1}{x} and \phi''(x) = -\frac{1}{x^2}: d\log X_t = \frac{1}{X_t}\,dX_t + \frac{1}{2}\left(-\frac{1}{X_t^2}\right)(\nu^2 X_t^2)\,dt = \left(\mu - \frac{1}{2}\nu^2\right)dt + \nu\,dW_t
Exact Closed-Form Solution: Integrating from 0 to t and exponentiating gives: X_t = X_0 \exp\!\left(\left(\mu - \frac{1}{2}\nu^2\right)t + \nu W_t\right)
Mean vs. Median Divergence: Because \log x is strictly concave (\phi'' < 0), symmetric noise slows the median growth rate to \mu - \frac{1}{2}\nu^2 even though the expectation still grows at the drift rate \mathbb{E}[X_t] = X_0 e^{\mu t}.
The Ornstein–Uhlenbeck Process and Mean Reversion
The Canonical Diffusion Process
Adding constant-amplitude Brownian noise g\,dW to the linear decay equation \dot{x} = -\theta x(\theta > 0) produces the Ornstein–Uhlenbeck (OU) process:
dX_t = -\theta X_t\,dt + g\,dW_t
Exact Solution via Integrating Factor: Apply Itô’s lemma to \phi(x, t) = e^{\theta t}x. Because \phi is linear in x(\phi_{xx} = 0), the Itô correction is zero: d\!\left(e^{\theta t}X_t\right) = \theta e^{\theta t}X_t\,dt + e^{\theta t}(-\theta X_t\,dt + g\,dW_t) = g\,e^{\theta t}\,dW_t
Fading-Memory Integral: Integrating from 0 to t gives: X_t = X_0\,e^{-\theta t} + g\int_0^t e^{-\theta(t-s)}\,dW_s
Closed-Form OU Gaussian Kernel and Stationary Law
Transition Kernel
Because the integrand e^{-\theta(t-s)} is deterministic, \int_0^t e^{-\theta(t-s)}\,dW_s is a Gaussian random variable with mean 0 and variance given directly by the Itô isometry:
Proposition (OU Transition Kernel): Given X_0 = x_0, the state at any time t > 0 is exact Gaussian: X_t \mid X_0 = x_0 \;\sim\; \mathcal{N}\!\left(\alpha_t x_0,\; \sigma_t^2\right), \qquad \alpha_t = e^{-\theta t}, \qquad \sigma_t^2 = \frac{g^2}{2\theta}\left(1 - e^{-2\theta t}\right)
Stationary Distribution (t \to \infty): After a few multiples of the relaxation time 1/\theta, the mean x_0 e^{-\theta t} \to 0 and the variance saturates at \sigma_\infty^2 = \frac{g^2}{2\theta}, so X_t \to \mathcal{N}\!\left(0, \frac{g^2}{2\theta}\right) from every starting state x_0.
Variance-Preserving Normalization and the VP-SDE
Foundation of DDPM
Choosing g^2 = 2\theta fixes the stationary variance to \frac{g^2}{2\theta} = 1 and ties the noise variance directly to the signal decay via \sigma_t^2 = 1 - \alpha_t^2. Writing \bar{\alpha}_t = \alpha_t^2 = e^{-2\theta t} (DDPM notation):
Why It Is Called Variance-Preserving (VP): If the data distribution X_0 has mean 0 and unit variance \operatorname{Var}(X_0) = 1, then at every time t \ge 0: \operatorname{Var}(X_t) = \bar{\alpha}_t \operatorname{Var}(X_0) + (1 - \bar{\alpha}_t) = \bar{\alpha}_t + 1 - \bar{\alpha}_t = 1
Shape Reshaping: Higher moments still evolve into a Gaussian—for Rademacher data X_0 \in \{\pm 1\}, the fourth moment climbs smoothly from \mathbb{E}[X_0^4] = 1 to \mathbb{E}[X_t^4] = 3 - 2\bar{\alpha}_t^2 \to 3.
Time-Dependent Schedule (VP-SDE): Allowing the rate \beta(t) = 2\theta(t) = g(t)^2 to increase with time gives dX = -\frac{1}{2}\beta(t)X\,dt + \sqrt{\beta(t)}\,dW, whose marginal has \bar{\alpha}_t = \exp\!\big(-\int_0^t \beta(s)\,ds\big).
Simulating SDEs: Euler–Maruyama vs. Exact Transitions
Numerical SDE Schemes
Euler–Maruyama freezes f and g at the start of each step \Delta t and injects a \sqrt{\Delta t} Gaussian kick:
Exact OU vs. Euler–Maruyama (\theta = 1, g = \sqrt{2}, \Delta t = 0.01): Exact DDPM steps use a = e^{-\theta\Delta t} and b = 1 - e^{-2\theta\Delta t}(v_\infty = 1.000), whereas Euler–Maruyama’s 1 - \theta\Delta t inflates v_\infty = 1.005(+0.5\% bias).
Implementing Batched Euler–Maruyama With Shared Noise
Clean SDE Simulator
Passing the Brownian increments dW as an explicit argument allows us to drive coarse and fine time grids with the exact same noise realization when measuring strong pathwise convergence:
def euler_maruyama(f, g, x0, t, dW):"""Simulate dX = f dt + g dW on the grid t for a batch of paths.""" X = np.empty((len(x0), len(t))) X[:, 0] = x0for k inrange(len(t) -1): h = t[k +1] - t[k] X[:, k +1] = (X[:, k] + f(X[:, k], t[k]) * h+ g(X[:, k], t[k]) * dW[:, k])return X
Milstein’s Higher-Order Correction (p_{\text{strong}} = 1): Adding the omitted intra-step diffusion integral \frac{1}{2}g(\hat{X}_n)\,\partial_x g(\hat{X}_n)\big((\Delta W_n)^2 - \Delta t\big) to the Euler–Maruyama update restores strong order 1 even for multiplicative noise.
Strong Pathwise Error vs. Weak Distributional Error
Two Notions of Convergence
Because SDE solutions are random variables, numerical accuracy can be judged either by how closely a simulated path tracks the specific realization of W_t, or by how closely the histogram at time T matches the true marginal law:
Strong Error (\mathbb{E}\,|\hat{X}_N - X_T| \le C\,\Delta t^p): Couples coarse and fine runs with the exact same Brownian pathW_t. Required for multilevel Monte Carlo.
Weak Error (|\mathbb{E}\,\varphi(\hat{X}_N) - \mathbb{E}\,\varphi(X_T)| \le C\,\Delta t^p): Compares expectations/histograms at time T across independent noise draws. Generative diffusion samplers only require weak convergence.
Strong Order: Additive vs. Multiplicative Noise
Pathwise Convergence
Why does Euler–Maruyama achieve strong order p = 1 on the additive-noise OU process, but drop to strong order p = 1/2 on multiplicative-noise geometric Brownian motion (g(X) = \nu X)?
The Omitted Milstein Term: Freezing g(X) misses its intra-step variation g(X_s) - g(X_{t_n}) \approx g\,\partial_x g\,(W_s - W_{t_n}), whose Itô integral over [t_n, t_{n+1}] is: g\,\partial_x g \int_{t_n}^{t_{n+1}} (W_s - W_{t_n})\,dW_s = \frac{1}{2}g\,\partial_x g\left((\Delta W_n)^2 - \Delta t\right)
Random Walk of Step Errors: Each step omits a zero-mean error of size O(\Delta t); summing N = T/\Delta t independent errors gives \sqrt{N}\,\Delta t = O(\Delta t^{1/2}) unless \partial_x g = 0 (additive noise, where strong order is O(\Delta t)).
strong-order slopes: OU (additive) 1.03, GBM (multiplicative) 0.48
Measuring Weak Order 1 via Exact Moment Recursions
Distributional Convergence
Because every omitted stochastic term has mean zero, the one-step distributional bias of Euler–Maruyama is O(\Delta t^2), accumulating over N = T/\Delta t steps to weak order 1(O(\Delta t)) for both additive and multiplicative noise:
n EM mean EM var exact 0.7358, 0.8647
10 0.6974 0.9247
20 0.7170 0.8938
40 0.7265 0.8791
80 0.7311 0.8718
160 0.7335 0.8682
320 0.7346 0.8664
weak-order slopes: mean 1.01, variance 1.01
Itô vs. Stratonovich Pitfall: Naive higher-order ODE solvers cannot be plugged directly into multiplicative SDEs—applying Heun’s predictor-corrector to g(X) averages the left and right endpoints, converging to the Stratonovich solution X_0 e^{\mu T + \nu W_T} instead of the Itô solution X_0 e^{(\mu - \nu^2/2)T + \nu W_T}.
Concept Check: Itô Calculus and Ornstein–Uhlenbeck
Concept Check
Work out these three stochastic calculus problems:
Itô’s Lemma on a Cubic: For standard Brownian motion W_t, compute the stochastic differential d(W_t^3) and find \mathbb{E}[W_t^3] and \mathbb{E}[W_t^2].
Stationary Variance: Consider the OU process dX_t = -3X_t\,dt + \sqrt{3}\,dW_t started at X_0 = 5. What is its limiting distribution as t \to \infty?
Strong vs. Weak Order: If you quarter the step size \Delta t \to \Delta t / 4 in Euler–Maruyama on a multiplicative-noise SDE, by what factor does the strong error shrink, and by what factor does the weak error shrink?
Answers:
With \phi(x) = x^3, \phi' = 3x^2 and \phi'' = 6x, so d(W_t^3) = 3W_t^2\,dW_t + \frac{1}{2}(1)^2(6W_t)\,dt = 3W_t^2\,dW_t + 3W_t\,dt. By symmetry \mathbb{E}[W_t^3] = 0, while d(W_t^2) = 2W_t\,dW_t + dt \implies \mathbb{E}[W_t^2] = t.
With \theta = 3 and g^2 = 3, the stationary distribution is \mathcal{N}\!\left(0, \frac{g^2}{2\theta}\right) = \mathcal{N}\!\left(0, \frac{1}{2}\right).
Strong error (order 1/2) shrinks by 4^{1/2} = 2\times; weak error (order 1) shrinks by 4^1 = 4\times.