STOCHASTIC CALCULUS 06

Euler–Maruyama Method

Euler–Maruyama is a numerical method for approximating sample paths of stochastic differential equations.

The main idea

Consider the stochastic differential equation

\[ dX_t = a(X_t,t)\,dt + b(X_t,t)\,dW_t. \]

Euler–Maruyama approximates its solution on a discrete time grid.

\[ \boxed{ X_{n+1} = X_n + a(X_n,t_n)\Delta t + b(X_n,t_n)\Delta W_n } \]

where

\[ \boxed{ \Delta W_n = \sqrt{\Delta t}\,Z_n, \qquad Z_n\sim N(0,1). } \]

1. Connection with Euler's method

For an ordinary differential equation

\[ \frac{dX}{dt}=a(X,t), \]

Euler's method uses

\[ X_{n+1} = X_n + a(X_n,t_n)\Delta t. \]

Euler–Maruyama adds the stochastic contribution

\[ b(X_n,t_n)\Delta W_n. \]
\[ \boxed{ \text{Euler–Maruyama} = \text{Euler drift step} + \text{Brownian step} } \]

2. Choose a time grid

Let

\[ t_n=t_0+n\Delta t. \]

The time step is

\[ \Delta t>0. \]

We approximate

\[ X(t_n) \]

by

\[ X_n. \]

3. Brownian increment at each step

For every interval

\[ [t_n,t_{n+1}], \]

generate an independent standard normal random variable

\[ Z_n\sim N(0,1). \]

Then define

\[ \boxed{ \Delta W_n = \sqrt{\Delta t}\,Z_n } \]

so that

\[ \Delta W_n \sim N(0,\Delta t). \]

4. The update step

At time \(t_n\), calculate the drift

\[ a(X_n,t_n) \]

and diffusion coefficient

\[ b(X_n,t_n). \]

Then calculate

\[ X_{n+1} = X_n + a(X_n,t_n)\Delta t + b(X_n,t_n)\sqrt{\Delta t}\,Z_n. \]
\[ \boxed{ \text{new state} = \text{old state} + \text{drift change} + \text{random change} } \]

5. A simple example

Consider

\[ dX_t = 2\,dt + 0.5\,dW_t, \]

with

\[ X_0=1. \]

Take

\[ \Delta t=0.04. \]

Then

\[ \sqrt{\Delta t}=0.2. \]

The Euler–Maruyama update is

\[ X_{n+1} = X_n + 2(0.04) + 0.5(0.2)Z_n. \]

Therefore,

\[ \boxed{ X_{n+1} = X_n+0.08+0.1Z_n } \]

6. First numerical step

Suppose the first random number is

\[ Z_0=1.2. \]

Then

\[ X_1 = 1+0.08+0.1(1.2). \]

So

\[ X_1=1.20. \]

Thus,

\[ \boxed{ X(0.04)\approx1.20 } \]

7. A different random number gives a different path

Suppose instead

\[ Z_0=-0.8. \]

Then

\[ X_1 = 1+0.08-0.08 = 1. \]

So even with the same initial condition and parameters, the next value can be different because the Brownian increment is random.

8. Repeat the procedure

At each time step:

\[ \boxed{ 1.\; \text{generate }Z_n\sim N(0,1) } \] \[ \boxed{ 2.\; \Delta W_n=\sqrt{\Delta t}\,Z_n } \] \[ \boxed{ 3.\; X_{n+1} = X_n + a_n\Delta t + b_n\Delta W_n } \]

Repeating these steps produces one approximate sample path.

9. One simulation gives one realisation

A single sequence

\[ Z_0,Z_1,Z_2,\ldots \]

produces one stochastic trajectory.

A different sequence produces another.

\[ \boxed{ \text{one sequence of random numbers} \rightarrow \text{one sample path} } \]

10. Many trajectories

To study the distribution of possible outcomes, repeat the simulation many times.

For example, simulate

\[ X_t^{(1)}, \; X_t^{(2)}, \; \ldots, \; X_t^{(M)}. \]

These are independent approximate realisations of the same stochastic model.

11. Estimating the expected value

At a chosen time \(t\), the expectation can be estimated by the sample mean:

\[ \boxed{ E[X_t] \approx \frac{1}{M} \sum_{m=1}^{M} X_t^{(m)} } \]

As the number of independent simulations increases, this Monte Carlo estimate generally becomes more stable.

12. Estimating variance

If

\[ \bar X_t = \frac1M \sum_{m=1}^M X_t^{(m)}, \]

then the variance can be estimated by

\[ \boxed{ \operatorname{Var}(X_t) \approx \frac{1}{M-1} \sum_{m=1}^M \left( X_t^{(m)}-\bar X_t \right)^2 } \]

13. Estimating a probability

Suppose we want

\[ P(X_T>L). \]

Count how many simulated trajectories exceed \(L\) at time \(T\).

If \(K\) out of \(M\) simulations exceed the threshold, then

\[ \boxed{ P(X_T>L) \approx \frac{K}{M} } \]

14. Example: threshold exceedance

Suppose

\[ M=10000 \]

trajectories are simulated and

\[ 1830 \]

finish above a chosen threshold.

Then

\[ P(X_T>L) \approx \frac{1830}{10000} = 0.183. \]

So the estimated probability is approximately

\[ \boxed{ 18.3\% } \]

15. Visual interpretation

Euler–Maruyama sample paths Several irregular numerical trajectories begin from the same initial state and then separate because different Brownian increments are generated. t X different numerical sample paths

16. The time grid is discrete

Euler–Maruyama calculates values only at

\[ t_0,t_1,t_2,\ldots \]

so the numerical output is discrete in time.

But the SDE being approximated is still a continuous-time model.

\[ \boxed{ \text{continuous-time SDE} \neq \text{discrete numerical approximation} } \]

17. Why the plot appears continuous

A computer usually draws straight lines between the computed values.

These connecting lines are for visualisation only.

They do not mean the numerical method calculated every intermediate time point.

18. Smaller time steps

Using a smaller \(\Delta t\) usually improves the numerical approximation.

But it also requires more calculations and more random increments.

\[ \boxed{ \text{smaller }\Delta t \Rightarrow \text{finer approximation} } \]

19. Two kinds of numerical accuracy

For stochastic differential equations, it is useful to distinguish two ideas.

Strong convergence concerns how closely a numerical path follows the corresponding true stochastic path.

Weak convergence concerns how accurately the numerical method reproduces quantities such as expectations or probability distributions.

20. Strong order of Euler–Maruyama

Under standard regularity conditions, Euler–Maruyama has strong convergence order

\[ \boxed{ \frac12 } \]

for many SDEs.

Very roughly, reducing the step size improves pathwise accuracy at a rate proportional to \((\Delta t)^{1/2}\).

21. Weak order

For sufficiently smooth problems, Euler–Maruyama commonly has weak order

\[ \boxed{ 1 } \]

for suitable expectation-type quantities.

So the numerical purpose matters when choosing a method.

22. State-dependent diffusion

Consider

\[ dX_t = \mu X_t\,dt + \sigma X_t\,dW_t. \]

Euler–Maruyama gives

\[ \boxed{ X_{n+1} = X_n + \mu X_n\Delta t + \sigma X_n\sqrt{\Delta t}\,Z_n } \]

or

\[ X_{n+1} = X_n \left( 1+\mu\Delta t + \sigma\sqrt{\Delta t}\,Z_n \right). \]

23. Systems of SDEs

Euler–Maruyama also applies to several stochastic state variables.

For example, if

\[ d\mathbf{X}_t = \mathbf{a}(\mathbf{X}_t,t)\,dt + B(\mathbf{X}_t,t)\,d\mathbf{W}_t, \]

then

\[ \boxed{ \mathbf{X}_{n+1} = \mathbf{X}_n + \mathbf{a}_n\Delta t + B_n\Delta\mathbf{W}_n } \]

where the components of \(\Delta\mathbf{W}_n\) represent Brownian increments.

24. Epidemic example

Suppose a stochastic epidemic model contains

\[ dI_t = a(S_t,I_t)\,dt + b(S_t,I_t)\,dW_t. \]

Then one Euler–Maruyama step is

\[ I_{n+1} = I_n + a(S_n,I_n)\Delta t + b(S_n,I_n)\sqrt{\Delta t}\,Z_n. \]

The first contribution gives the deterministic epidemic tendency.

The second introduces stochastic variation around that tendency.

25. Numerical values must remain meaningful

In population models, the state may need to satisfy restrictions such as

\[ I_t\ge0. \]

A simple Euler–Maruyama discretisation can sometimes generate negative numerical values even when the intended continuous model is nonnegative.

This is a numerical issue that must be checked rather than ignored.

26. Simulation is not the same as the exact SDE

A simulated Euler–Maruyama path contains two approximations:

\[ \boxed{ \text{the continuous SDE is sampled on a finite time grid} } \]

and

\[ \boxed{ \text{the numerical update approximates the exact SDE solution} } \]

Therefore numerical results should be checked for sensitivity to the chosen step size.

27. A useful convergence check

Run the simulation with

\[ \Delta t, \]

then repeat with a smaller step such as

\[ \frac{\Delta t}{2}. \]

If important estimated quantities change substantially, the original time step may have been too large.

28. Monte Carlo error is different from time-step error

There are two separate sources of numerical uncertainty:

\[ \boxed{ \text{discretisation error} } \]

from the finite time step, and

\[ \boxed{ \text{Monte Carlo sampling error} } \]

from using only finitely many simulated trajectories.

Using a smaller time step addresses the first. Using more simulations addresses the second.

29. The practical algorithm

\[ \boxed{ 1.\; \text{Choose }X_0,\ T,\ \Delta t } \] \[ \boxed{ 2.\; \text{Set }t_n=n\Delta t } \] \[ \boxed{ 3.\; \text{Generate }Z_n\sim N(0,1) } \] \[ \boxed{ 4.\; \Delta W_n=\sqrt{\Delta t}\,Z_n } \] \[ \boxed{ 5.\; X_{n+1} = X_n + a_n\Delta t + b_n\Delta W_n } \] \[ \boxed{ 6.\; \text{Repeat until }T } \] \[ \boxed{ 7.\; \text{Repeat the full path if many realisations are required} } \]

30. The central idea

\[ \boxed{ dX_t = a\,dt+b\,dW_t } \] \[ \downarrow \] \[ \boxed{ X_{n+1} = X_n + a_n\Delta t + b_n\sqrt{\Delta t}\,Z_n } \]

Euler–Maruyama turns a continuous stochastic differential equation into a step-by-step numerical simulation while preserving the essential Brownian scaling.