Search

Search papers and lessons

Stochastic Differential Equation

Level 4 · 10 min read

A stochastic differential equation describes a quantity that changes by a predictable drift plus random noise, the continuous-time model behind diffusion and option pricing.

On this page

  • Colour = topic mix
  • Calculus
  • Probability
  • Stochastic processes
  • Discrete math
  • Sign in to see your progress

TL;DR

An ordinary differential equation says how a quantity changes given its current value. A stochastic differential equation (SDE) adds noise: the quantity moves by a predictable part, the drift, plus a random kick whose size depends on where it is, the diffusion. Solving an SDE means finding a random path that obeys this rule, and each run of the noise gives a different path.

SDEs are the standard model for anything that is pushed around by many small random shocks while also following a trend: a stock price, a particle in a fluid, a noisy control signal.

Where you'll see it: Black-Scholes option pricing, the forward noising process of diffusion models, and stochastic gradient Langevin dynamics for sampling from posterior distributions.

Intuition

A rule plus a coin toss at every instant

Picture a boat on a choppy lake. The wind gives it a steady push in one direction. The waves shove it sideways in a way you cannot predict exactly, but you can describe the typical size of the shove. The boat's motion over a short time is therefore the steady push times the time elapsed, plus a random shove whose spread grows with the square root of the time elapsed.

That square root is the key difference from ordinary calculus. A ball rolling for a tenth of a second moves about a tenth of its speed. A Brownian particle over the same tenth of a second moves a distance of about the square root of a tenth, roughly 0.32, which is much larger than the tenth. Random shoves add up as square roots, not as straight lines. The rules for handling that are Itô calculus, and an SDE is the object that calculus is built to solve.

Here is the picture for a noisy decay. The mean path falls exponentially, and a band of one standard deviation around it opens up over time and then levels off. Each sample path wanders inside that band.

00.511.522.533.54−0.500.511.522.5time tX_t
  • mean
  • +1 sd
  • -1 sd
Mean and one-standard-deviation band for the Ornstein-Uhlenbeck SDE with X_0 = 2, theta = 1, sigma = 0.5. The band widens and then settles at a width set by the noise.

Why the noise is written as dW

The noise term is written dWtdW_t, where WtW_t is a Brownian motion. You can read dWtdW_t as "a Gaussian increment with mean zero and variance dtdt". Its size is dt\sqrt{dt}, which is why the square root appears. Writing the noise this way, instead of as a generic random number, makes the equation mean the same thing whatever step size you use to simulate it.

Why it is useful

Many systems have a clear average behaviour plus unavoidable fluctuations. An SDE captures both in one line, and it can be simulated, solved in special cases, and studied with probability tools. It is the continuous-time version of the Markov chain idea: the next change depends on the present state, not the history that led there.

The math

Definition

Definition: Stochastic differential equation

Let XtX_t be a process, μ(x,t)\mu(x, t) the drift and σ(x,t)\sigma(x, t) the diffusion coefficient. The SDE

dXt=μ(Xt,t) dt+σ(Xt,t) dWtdX_t = \mu(X_t, t)\,dt + \sigma(X_t, t)\,dW_t

means that XX solves the integral equation

Xt=X0+∫0tμ(Xs,s) ds+∫0tσ(Xs,s) dWs,X_t = X_0 + \int_0^t \mu(X_s, s)\,ds + \int_0^t \sigma(X_s, s)\,dW_s,

where the second integral is an Itô integral against a Brownian motion WW.

Here X0X_0 is the starting value, μ\mu says which way the quantity tends to move, and σ\sigma sets how strongly random shocks push it. Both coefficients may depend on the current state XtX_t and the time tt. When σ=0\sigma = 0 the equation reduces to the ordinary differential equation dXt=μ dtdX_t = \mu\,dt, which is why the SDE is the natural generalisation.

Existence and uniqueness

If μ\mu and σ\sigma are Lipschitz in xx (their slope is bounded everywhere) and grow at most linearly, then a unique solution exists for every starting value. This is the stochastic analogue of the existence theorem for ODEs. Without these conditions the solution can blow up in finite time, just as an ODE can.

Solving linear SDEs: the Ornstein-Uhlenbeck process

The simplest SDE with a useful solution is

dXt=−θXt dt+σ dWt,θ>0.dX_t = -\theta X_t\,dt + \sigma\,dW_t, \qquad \theta \gt 0.

The drift pulls XX back toward zero at rate θ\theta, and the noise keeps kicking it away. To solve it, multiply by the integrating factor eθte^{\theta t}. Define Yt=eθtXtY_t = e^{\theta t} X_t. Itô's product rule gives

dYt=θeθtXt dt+eθt dXt=θeθtXt dt+eθt(−θXt dt+σ dWt)=σeθt dWt.dY_t = \theta e^{\theta t} X_t\,dt + e^{\theta t}\,dX_t = \theta e^{\theta t} X_t\,dt + e^{\theta t}\big(-\theta X_t\,dt + \sigma\,dW_t\big) = \sigma e^{\theta t}\,dW_t.

The dtdt terms cancel, which is the whole point of the trick. Integrating from 00 to tt and dividing by eθte^{\theta t} gives

Xt=e−θtX0+σ∫0te−θ(t−s) dWs.X_t = e^{-\theta t} X_0 + \sigma \int_0^t e^{-\theta(t-s)}\,dW_s.

Because the integrand is deterministic, the Itô integral is a Gaussian with mean zero, so XtX_t is Gaussian. Its mean and variance are

E[Xt]=X0e−θt,Var(Xt)=σ22θ(1−e−2θt).\mathbb{E}[X_t] = X_0 e^{-\theta t}, \qquad \mathrm{Var}(X_t) = \frac{\sigma^2}{2\theta}\big(1 - e^{-2\theta t}\big).

As tt grows, the variance tends to σ2/(2θ)\sigma^2/(2\theta). This is the stationary distribution of the process.

Geometric Brownian motion

The SDE

dSt=μSt dt+σSt dWtdS_t = \mu S_t\,dt + \sigma S_t\,dW_t

models a price that grows at a steady percentage rate μ\mu with percentage volatility σ\sigma. Its solution comes from Itô's lemma applied to f(s)=ln⁡sf(s) = \ln s, with f′(s)=1/sf'(s) = 1/s and f′′(s)=−1/s2f''(s) = -1/s^2. Since (dSt)2=σ2St2 dt(dS_t)^2 = \sigma^2 S_t^2\,dt,

d(ln⁡St)=dStSt−12σ2St2St2 dt=(μ−12σ2)dt+σ dWt.d(\ln S_t) = \frac{dS_t}{S_t} - \frac{1}{2}\frac{\sigma^2 S_t^2}{S_t^2}\,dt = \Big(\mu - \tfrac{1}{2}\sigma^2\Big)dt + \sigma\,dW_t.

Integrating gives

St=S0exp⁡ ⁣((μ−12σ2)t+σWt).S_t = S_0 \exp\!\Big(\big(\mu - \tfrac{1}{2}\sigma^2\big)t + \sigma W_t\Big).

The −12σ2-\tfrac{1}{2}\sigma^2 correction is the Itô term at work. It is why the median of StS_t grows more slowly than the mean.

Numerical solution: Euler-Maruyama

Most SDEs have no closed form. The Euler-Maruyama scheme discretises time in steps of size hh. Since a Brownian increment over hh has standard deviation h\sqrt{h}, the update is

Xk+1=Xk+μ(Xk,tk) h+σ(Xk,tk) h Zk,Zk∼N(0,1) independent.X_{k+1} = X_k + \mu(X_k, t_k)\,h + \sigma(X_k, t_k)\,\sqrt{h}\,Z_k, \qquad Z_k \sim \mathcal{N}(0, 1) \text{ independent}.

This is the SDE analogue of the Euler method for ODEs, with the extra h\sqrt{h} on the noise. Its error shrinks like h\sqrt{h} in the strong sense, which is slower than the hh you get from Euler on an ODE.

Worked examples

Example
Ornstein-Uhlenbeck mean and variance

Take θ=1\theta = 1, σ=0.5\sigma = 0.5, X0=2X_0 = 2, and look at time t=1t = 1.

  1. Mean: E[X1]=X0e−θ=2e−1=2×0.36788=0.73576\mathbb{E}[X_1] = X_0 e^{-\theta} = 2 e^{-1} = 2 \times 0.36788 = 0.73576.
  2. Variance: Var(X1)=σ22θ(1−e−2θ)=0.252(1−e−2)=0.125×(1−0.13534)=0.125×0.86466=0.10808\mathrm{Var}(X_1) = \frac{\sigma^2}{2\theta}(1 - e^{-2\theta}) = \frac{0.25}{2}(1 - e^{-2}) = 0.125 \times (1 - 0.13534) = 0.125 \times 0.86466 = 0.10808.
  3. Standard deviation: 0.10808=0.3288\sqrt{0.10808} = 0.3288.
  4. Interpretation: after one unit of time, the typical value is about 0.74±0.330.74 \pm 0.33. The starting value has pulled the mean down by more than half, and the noise has spread the answer over a range of roughly two-thirds of a unit.
  5. Stationary check: as t→∞t \to \infty the variance tends to 0.25/2=0.1250.25/2 = 0.125, a standard deviation of 0.3540.354. The value at t=1t = 1 is already close to that level.
Example
One Euler-Maruyama step for the same process

Use the same SDE with step size h=0.1h = 0.1, starting at X0=2X_0 = 2, and draw Z0=0.3Z_0 = 0.3.

  1. Drift term: μ(X0) h=−θX0⋅h=−1×2×0.1=−0.2\mu(X_0)\,h = -\theta X_0 \cdot h = -1 \times 2 \times 0.1 = -0.2.
  2. Noise term: σh Z0=0.5×0.1×0.3=0.5×0.31623×0.3=0.04743\sigma\sqrt{h}\,Z_0 = 0.5 \times \sqrt{0.1} \times 0.3 = 0.5 \times 0.31623 \times 0.3 = 0.04743.
  3. Sum: X1=2−0.2+0.04743=1.84743X_1 = 2 - 0.2 + 0.04743 = 1.84743.
  4. Interpretation: the drift moved the value down by a fixed amount, and the noise pushed it slightly back up. The exact solution for X0.1X_{0.1} has mean 2e−0.1=1.80972e^{-0.1} = 1.8097, so the Euler step lands in the right region. Over many steps the scheme converges to the exact distribution as hh shrinks.
Example
A geometric Brownian motion price after one year

Let S0=100S_0 = 100, μ=0.08\mu = 0.08, σ=0.2\sigma = 0.2, and suppose the noise over the year came out as W1=0.5W_1 = 0.5.

  1. Exponent drift: μ−12σ2=0.08−0.02=0.06\mu - \tfrac{1}{2}\sigma^2 = 0.08 - 0.02 = 0.06.
  2. Exponent noise: σW1=0.2×0.5=0.10\sigma W_1 = 0.2 \times 0.5 = 0.10.
  3. Exponent total: 0.06+0.10=0.160.06 + 0.10 = 0.16.
  4. Price: S1=100 e0.16=100×1.17351=117.35S_1 = 100 \, e^{0.16} = 100 \times 1.17351 = 117.35.
  5. Interpretation: a price that drifts at 8 percent a year but happened to get a favourable shock ends at 117.35. The Itô term −12σ2=−0.02-\tfrac{1}{2}\sigma^2 = -0.02 is already included in the 0.06 above, so the outcome is not inflated by it.

Tradeoffs and failure modes

SDEs are the right model when a state changes continuously and noise is a real part of the system. They are the wrong model when the noise is better described by jumps, or when the state is discrete.

SituationProblemBetter choice
Prices with sudden crashesContinuous diffusion underestimates tail riskSDE with a jump term (jump-diffusion)
Closed form needed for a nonlinear SDEMost nonlinear SDEs have no closed formEuler-Maruyama or Milstein simulation
Many small steps needed for accuracyStrong error shrinks only like h\sqrt{h}Higher-order schemes such as Milstein
Noise is coloured (correlated in time)Standard Brownian increments are independentSDE driven by a different noise process
Discrete-time dataContinuous model is an approximationFit a discrete model, such as an AR process

The most common mistake is to treat the noise like ordinary calculus. If you apply the usual chain rule to f(Xt)f(X_t) and forget the second-order Itô term, you get the wrong drift. The geometric Brownian motion example shows the size of the error: the −12σ2-\tfrac{1}{2}\sigma^2 term puts the median below the mean by a factor of e−σ2t/2e^{-\sigma^2 t/2}.

Another failure is a non-Lipschitz coefficient. The equation may still have a solution, but a naive simulation can diverge, and the answer depends on the discretisation.

History

Louis Bachelier modelled stock prices as random walks in his 1900 thesis, before Einstein's 1905 analysis of Brownian motion in physics. Paul Langevin wrote down a stochastic equation of motion for a particle in a fluid in 1908, adding a random force to Newton's law. Its drift and noise structure is the template for what we now call an SDE.

Kiyosi Itô gave the rigorous foundation in 1944 by defining the stochastic integral and proving the change-of-variables rule that now bears his name. Ornstein and Uhlenbeck studied the linear equation that carries their names in 1930 as a model of velocity in Brownian motion. Its mean-reverting behaviour made it popular in physics and later in finance.

SDEs caught on in finance after Fischer Black, Myron Scholes and Robert Merton used a geometric Brownian motion to price options in 1973. In machine learning they became central again when diffusion models treated image generation as the reverse of a noising SDE.

Check yourself

QuestionWhat does the drift term contribute over a short time step hh, and how does the noise term scale with hh?Show answer

The drift contributes μ(Xt,t) h\mu(X_t, t)\,h, which is proportional to hh. The noise contributes σ(Xt,t) dWt\sigma(X_t, t)\,dW_t, whose size is proportional to h\sqrt{h}. So over short intervals the noise dominates the drift, because h\sqrt{h} is much larger than hh when hh is small.

QuestionFor the Ornstein-Uhlenbeck process with θ=2\theta = 2 and σ=1\sigma = 1, what is the stationary variance?Show answer

The stationary variance is σ2/(2θ)=1/4=0.25\sigma^2/(2\theta) = 1/4 = 0.25. Setting t→∞t \to \infty in the variance formula kills the exponential term, leaving σ2/(2θ)\sigma^2/(2\theta).

QuestionWhy does the geometric Brownian motion solution have −12σ2-\tfrac{1}{2}\sigma^2 in the exponent?Show answer

It is the Itô correction. Applying Itô's lemma to ln⁡St\ln S_t produces a −12σ2 dt-\tfrac{1}{2}\sigma^2\,dt term, because (dSt)2=σ2St2 dt(dS_t)^2 = \sigma^2 S_t^2\,dt is not zero. In ordinary calculus this term would vanish, and the exponent would be μt+σWt\mu t + \sigma W_t instead.

QuestionA trader models a stock with geometric Brownian motion. Why might the model underprice a deep out-of-the-money put?Show answer

Geometric Brownian motion has continuous paths and log-normal returns, so large drops are very unlikely. Real markets have sudden crashes that put more probability on extreme losses than a log-normal does. A jump-diffusion model, which adds a jump term to the SDE, puts more weight on those tails and gives a higher price for deep out-of-the-money puts.

Sources