Output 9
Output 9
Further, due to the properties of the Wiener process we can simulate its values at the
selected points by
Choose h for the size of every step and set tn = t0 + nh. Set tn+1 = tn + h and consider
yn+1 = yn + hf (tn , yn ).
The value of yn is an approximation of the solution to the ODE at time tn , that is,
yn ≈ y (tn ).
A recap from ODEs
Choose h for the size of every step and set tn = t0 + nh. Set tn+1 = tn + h and consider
yn+1 = yn + hf (tn , yn ).
The value of yn is an approximation of the solution to the ODE at time tn , that is,
yn ≈ y (tn ).
Note that any ODE of order N can be represented as a system of first-order ODEs.
Indeed, given
y (N) (t) = f (t, y (t), y ′ (t), . . . , y (N−1) (t))
z1′ (t) y ′ (t) z2 (t)
.. .. ..
′
z (t) =
.
= .
= .
′ (t) y (N−1) (t)
zN−1 zN (t)
′
zN (t) (N)
y (t) f (t, z1 (t), . . . , zN (t))
The Euler–Maruyama scheme
The framework
We consider the SDE
dXt = a(t, Xt )dt + b(t, Xt )dWt
where
∆Wn = Wtn+1 − Wtn .
The Euler–Maruyama scheme
In order to obtain this scheme the following approximation is used
Z tn+1
b(s, Xs ) dWs ≈ b(tn , Xn )∆Wn ,
tn
Z tn+1
a(s, Xs ) ds ≈ a(tn , Xn )δt.
tn
The Euler–Maruyama scheme
In order to obtain this scheme the following approximation is used
Z tn+1
b(s, Xs ) dWs ≈ b(tn , Xn )∆Wn ,
tn
Z tn+1
a(s, Xs ) ds ≈ a(tn , Xn )δt.
tn
Black–Scholes
We know that the solution to
dSt = St µ dt + St σ dWt .
is
St = S0 exp(σWt + (µ − 12 σ 2 )t).
The Euler–Maruyama scheme
In order to obtain this scheme the following approximation is used
Z tn+1
b(s, Xs ) dWs ≈ b(tn , Xn )∆Wn ,
tn
Z tn+1
a(s, Xs ) ds ≈ a(tn , Xn )δt.
tn
Black–Scholes
We know that the solution to
dSt = St µ dt + St σ dWt .
is
St = S0 exp(σWt + (µ − 12 σ 2 )t).
delta_t = T/N
W[0] = 0
For n = 0, 1, ..., N-1
W[n+1] = W[n] + sqrt (delta_t) * N[n]
S[0] = S0
For n = 0, 1, ..., N-1
S[n+1] = S[n] + S[n] * mu * delta_t + S[n] * sigma * (W[n+1] - W[n])
return S[N]
Approximation errors
We may vary the step size in order to get some idea about the approximation error. We
will measure the performance in two ways. We make M independent runs of the
algorithm and compute
M
1 X σ2
|S0 exp(σW m [N] + (µ − )T − S m [N]| ≈ E ST − S[N]
M 2
m=1
M
σ2 1 X m
|E(S0 exp(σWT + (µ − )T ) − S [N]| ≈ EST − ES[N]
2 M
m=1
Piecewise approximations
tn = n · δt,
Xn is the computed value at tn .
A numerical scheme is
strongly convergent, if
weakly convergent, if
lim |Eg (XT ) − Eg (XTδt )| = 0
δt→0
Stability generally means that the numerical solution remains bounded and behaves
similarly to the exact solution as the time step size decreases. Stability can be
categorised into different types, including:
Mean-Square Stability: EM is not always mean-square stable, especially for stiff SDEs.
For certain SDEs, especially those with large coefficients, EM can exhibit numerical
instability unless the time step size ∆t is chosen to be very small.
Almost Sure Stability: EM can also exhibit instability in an almost sure sense,
particularly for stiff SDEs or those with certain types of coefficients.
The Milstein scheme is a more accurate approximation than EM, incorporating an additional
term to account for the derivative of the diffusion coefficient.
Mean-Square Stability: The Milstein scheme is generally more stable than EM. It tends
to exhibit better mean-square stability properties, particularly for SDEs where the
diffusion coefficient g (Xt ) varies significantly.
Almost Sure Stability: The Milstein scheme also tends to be more stable in the almost
Weak/strong convergence of EM
E XT − XTδt ) ⩽ KT · (δt)γ .
Convergence orders
E XT − XTδt ) ⩽ KT · (δt)γ .
The constant KT depends on T and the considered SDE. The numerical scheme is
weakly convergent with order γ, whenever
E XT − XTδt ) ⩽ KT · (δt)γ .
The constant KT depends on T and the considered SDE. The numerical scheme is
weakly convergent with order γ, whenever
If a numerical scheme is convergent with order γ and we make the step k times smaller,
then the approximation error will decrease by a factor of k γ .
Thus, the order equal 1 means that if we want to decrease error 100 times, we have to
make the step 100 times smaller. The order equal to 1/2 means that if we want to
decrease error 100 times, we have to make the step 1002 = 10000 times smaller. And
the computation time grows by the same factor.
Euler-Maruyama scheme is
Weak convergence:
Weak convergence:
Strong convergence:
Still considering
dXt = a(Xt ) dt + b(Xt ) dWt X0 = x
The scheme:
X0 = x
1
Xn+1 = Xn a(Xn )δt + b(Wn )∆Wn + b ′ (Xn )b(Xn )((∆Wn )2 − δt)
2
Derivation
We can apply the Itô formula on the expressions a(Xs ) and b(Xs ), which are the
coefficients in our SDE.
Derivation
Rt Rs
Xti+1 = Xti + ti i+1 (a(Xti + ti (a′ (Xu )a(Xu ) + 12 a′′ (Xu )b 2 (Xu ))du
Rs
+ ti a′ (Xu )b(Xu )dWu )ds
Rt Rs
+ ti i+1 (b(Xti + ti (b ′ (Xu )a(Xu )
+ 12 b ′′ (Xu )b 2 (Xu ))du
Rs
+ ti b ′ (Xu )b(Xu )dWu )dWs .
Derivation
δt · δt = O((δt)2 )
∆W · δt = O((δt)3/2 )
∆W · ∆W = O(δt)
Derivation
δt · δt = O((δt)2 )
∆W · δt = O((δt)3/2 )
∆W · ∆W = O(δt)
We then obtain
Rt
Xti+1 ≈ Xti + ti i+1 a(Xti )ds
Rt Rs
+ ti i+1 (b(Xti + ti b ′ (Xu )b(Xu )dWu )dWs
Rt Rs
≈ Xti + a(Xti )δt + b(Xti )∆Wi + ti i+1 ti b ′ (Xu )b(Xu )dWu dWs
The first two summands in the equation above are well known from the
Euler–Maruyama scheme. The third one is new. We approximate the third term above
by
Z ti+1 Z s Z ti+1 Z s
b ′ (Xu )b(Xu )dWu dWs ≈ b ′ (Xti )b(Xti ) dWu dWs
ti ti ti ti
Derivation
The integral on the right hand side of the last equality is well known in Continuous
Time Finance. It is
Z ti+1 Z s
′ 1
b (Xti )b(Xti ) dWu dWs = b ′ (Xti )b(Xti )((∆Wi )2 − δt)
ti ti 2
Derivation
The integral on the right hand side of the last equality is well known in Continuous
Time Finance. It is
Z ti+1 Z s
′ 1
b (Xti )b(Xti ) dWu dWs = b ′ (Xti )b(Xti )((∆Wi )2 − δt)
ti ti 2
Substituting this in our previous approximation we finally obtain the Milstein scheme.
Derivation
The integral on the right hand side of the last equality is well known in Continuous
Time Finance. It is
Z ti+1 Z s
′ 1
b (Xti )b(Xti ) dWu dWs = b ′ (Xti )b(Xti )((∆Wi )2 − δt)
ti ti 2
Substituting this in our previous approximation we finally obtain the Milstein scheme.
One can prove that the Milstein scheme converges strongly with order 1 to the solution
of the SDE.