Simulating SDEs: the Euler–Maruyama scheme
In "Monte Carlo option pricing" every terminal price was drawn in one step, because "Itô's lemma" gave the exact solution of geometric Brownian motion. Most models used in practice have no such formula. This lesson shows how to simulate a stochastic differential equation step by step with the Euler–Maruyama scheme, how to measure the error it makes, and how fast that error shrinks as the steps get smaller. Geometric Brownian motion serves as the test case, precisely because its exact solution is known.
Stochastic differential equations
A stochastic differential equation (SDE) describes how a quantity changes over a short time :
The drift is the expected rate of change, and the diffusion coefficient scales the random shock of a Brownian motion. Geometric Brownian motion is the case , . A mean-reverting interest rate, or the variance in "Stochastic volatility and the Heston model", has other coefficients, and for many of them no closed-form solution exists.
The Euler–Maruyama step
Split into steps of length and freeze the coefficients at the start of each step. The Brownian increment over a step is normal with variance , so it can be written with standard normal. The Euler–Maruyama scheme is
It is the natural first approximation: it keeps exactly the two terms that dominate the Itô expansion of the change over one step, the term and the term, and drops everything smaller. Think of it as walking along a curved road by taking straight steps in the direction you are facing; the shorter the steps, the closer you stay to the road.
For geometric Brownian motion one step reads , while the exact solution over the same step is
Example: , , , and , so . Euler gives . The exact value is . With Euler gives against the exact . The step misses by about either way, because it ignores the curvature of the exponential.
Strong and weak error
There are two ways to judge a simulation scheme, depending on what it is used for.
- The strong error compares the simulated path with the true path driven by the same Brownian motion. It matters when the path itself matters, for example when hedging along it.
- The weak error compares only averages. It is what matters for Monte Carlo pricing, which needs the distribution of , not individual paths.
For smooth coefficients the Euler–Maruyama scheme has strong order and weak order 1: the strong error shrinks like , the weak error like . Four times as many steps halve the strong error but cut the weak error to a quarter.
Geometric Brownian motion makes the weak error easy to compute. Each Euler step multiplies the expected value by , so , against the exact . With the numbers above, , and the gaps for , and are , and : a quarter each time.
The same path on finer grids
To see the strong error you must compare a simulation with the exact path driven by the same randomness. The figure draws one Brownian path on a fine grid of 256 steps over one year, with , and ; the high volatility makes the error visible. The exact solution is drawn from that path, and the Euler approximation uses the same path on a coarser grid: each coarse increment is the sum of the fine increments it spans.
Choose , , or steps and watch the Euler path close in on the exact one; "New path" draws another Brownian path. Hover over the chart, or focus it and use the arrow keys, to compare the two values at a grid time. Below, the strong error at averaged over 500 paths is plotted against on log–log axes, next to a reference line of slope . It falls from about at to , and at : roughly halving with every fourfold refinement, as order predicts. On the first path the terminal values at are exact against for Euler.
Hover over the chart (or focus it and use the arrow keys) to compare the two values at one time.
- Exact value at T
- 177.23
- Euler value at T
- 183.44
- Error on this path
- 6.22
- Mean strong error (n = 16)
- 2.34
Simulating the logarithm instead
For geometric Brownian motion there is a better option than discretising itself. By "Itô's lemma", follows
whose coefficients are constant. Euler steps on are therefore exact, whatever is, and prices stay positive automatically. Euler on can even produce a negative price if falls below zero. Transforming a model into variables with simpler coefficients before discretising is a standard trick; when no such transformation exists, as for many mean-reverting or stochastic-volatility models, small steps and the error orders above are what you rely on.
Summary
- An SDE is simulated step by step with Euler–Maruyama: .
- The strong error (paths) has order and the weak error (averages) order 1; Monte Carlo pricing only needs the weak one.
- Coarse and fine grids must use the same Brownian path to be compared: coarse increments are sums of fine ones.
- When a transformation gives constant coefficients, as does for geometric Brownian motion, simulate that variable instead: the steps become exact.
The next lesson, "Mean reversion: Ornstein–Uhlenbeck and Vasicek", studies a process whose drift pulls it back towards a long-run level, and simulates it with exactly this kind of step.