You are on page 1of 51

Intro to SDEs with with Examples

Introduction to the Numerical Simulation of


Stochastic Differential Equations with
Examples
Prof. Michael Mascagni
Department of Computer Science
Department of Mathematics
Department of Scientic Computing
Florida State University, Tallahassee, FL 32306 USA
E-mail: mascagni@fsu.edu or mascagni@math.ethz.ch
URL: http://www.cs.fsu.edu/mascagni
Intro to SDEs with with Examples
Introduction
Stochastic Differential Equations
Brownian Motion
It Calculus
Numerical Solution of SDEs
Types of Solutions to SDEs
Examples
Higher-Order Methods
Some Applications
Stability
Weak Solutions
Higher-Order Schemes
Examples
Numerical Examples
Bibliography
Intro to SDEs with with Examples
Introduction
Stochastic Differential Equations
Brownian Motion
It Calculus
Numerical Solution of SDEs
Types of Solutions to SDEs
Examples
Higher-Order Methods
Some Applications
Stability
Weak Solutions
Higher-Order Schemes
Examples
Numerical Examples
Bibliography
Intro to SDEs with with Examples
Introduction
Stochastic Differential Equations
Brownian Motion
It Calculus
Numerical Solution of SDEs
Types of Solutions to SDEs
Examples
Higher-Order Methods
Some Applications
Stability
Weak Solutions
Higher-Order Schemes
Examples
Numerical Examples
Bibliography
Intro to SDEs with with Examples
Stochastic Differential Equations
Stochastic Differential Equations
Stokes law for a particle in uid
dv(t ) = v(t ) dt
where
=
6r
m
,
= viscosity coefcient.
Langevins eq. For very small particles bounced around by molecular
movement,
dv(t ) = v(t ) dt + dw(t ),
w(t ) is a Brownian motion, = Stokes coefcient. =Diffusion
coefcient.
Intro to SDEs with with Examples
Stochastic Differential Equations
Brownian Motion
1-D Brownian Motion
Figure: 1-D Brownian motion
Intro to SDEs with with Examples
Stochastic Differential Equations
Brownian Motion
2-D, or Complex Brownian Motion
Figure: 2-D Brownian motion
Intro to SDEs with with Examples
Stochastic Differential Equations
Brownian Motion
Brownian Motion
w(t ) = Brownian motion. Einsteins relation gives diffusion coefcient
=
_
2kT
m
.
and probability density function for Brownian motion satises heat
equation:
p(w, t )
t
=
1
2

2
p(w, t )
w
2
Formal solution to LE is called an Ornstein-Uhlenbeck process
v(t ) = v
0
e
t
+e
t
_
t
0
e
s
dw(s)
Intro to SDEs with with Examples
Stochastic Differential Equations
Brownian Motion
A Simple Stochastic Differential Equation
What does dw(t ) mean?
w(t ) = w
1
+w
2
+ +w
n
each increment is independent, and
E{w
i
w
j
} =
ij
t
or innitesimal version
Edw(t ) = 0
E{dw(t ) dw(s)} = (t s) dt ds
Intro to SDEs with with Examples
Stochastic Differential Equations
Brownian Motion
The Langevin Equation
Solution to LE has properties
Ev(t ) = v
0
e
t
+e
t
_
t
0
e
s
Edw(s)
= v
0
e
t
and
E(v(t ))
2
= (v
0
)
2
e
2t
+
2
e
2t
e
2t
1
2


2
2
as t
Something familiar about this?
m
2
E(v)
2
=
m
2

2
2
=
1
2
kT
Intro to SDEs with with Examples
Stochastic Differential Equations
It Calculus
It Calculus
It calculus for multi-dimensional version
dw(t )
2
dt or dw
i
(t )dw
j
(t )
ij
dt
In non-isotropic case, system
dz = b(z) dt +(z) dw(t ) (SDE)
is shorthand for
z(t ) = z
0
+
_
t
0
b(z
s
) ds +
_
t
0
(z
s
) dw
s
.
It rule for Stochastic integral:
E{
_
t
0
(z
s
)dw
s
} = 0,
and
E{
_
t
0
(z
s
)dw
s
}
2
=
_
t
0

T
(z
s
)ds.
These integrals are martingales.
Intro to SDEs with with Examples
Stochastic Differential Equations
It Calculus
A Standing Martingale
Figure: A standing martingale
Intro to SDEs with with Examples
Stochastic Differential Equations
Numerical Solution of SDEs
Numerical Solution of SDEs
Simulation? First,
Ef (z(t ))
1
N
N

i =1
f (z
[i ]
(t ))
for sample of N paths z(t ). Paths {z
[1]
, z
[2]
, ..., z
[N]
} integrated by
some rule, e.g. Euler Two criteria two versions of solution

z(t ), z(t )
are equivalent (

z(t ) z(t )) for 0 t T, strong criteria:


P( sup
0t T
|

z(t ) z(t )| > 0) = 0


weak: for any sufciently smooth f (x),
|Ef (

z(T)) Ef (z(T))| = 0
Intro to SDEs with with Examples
Stochastic Differential Equations
Types of Solutions to SDEs
Weak Solutions
Example: weak simulation (m 0):
dx = x|x|
m1
dt +dw(t )
has solution whose distribution law satises Kolmogorov equation
p(x, t )
t
=

x
_
1
2

x
+x|x|
m1
_
p(x, t ) 0
when t . That is, x(t ) becomes stationary. p(x, t ), properly
normalized, is
p(x, ) = N
m
e

2
m+1
|x|
m+1
.
Two examples
p(x, ) = e
2|x|
for m = 0
p(x, ) =
1

e
|x|
2
for m = 1
Intro to SDEs with with Examples
Stochastic Differential Equations
Types of Solutions to SDEs
Strong Solutions
Example: a strong test,
dx = xdt +xdw(t )
having formal solution
x(t ) = x
0
exp(( +

2
2
)t +w(t )). (1)
Notice x(t ) 0 as t . Many authors (Mitsui et al, Higham, ...)
have studied stability regions, , , for asymptotic stability x(t
n
) 0,
when
t
n
= h
1
+h
2
+. . . +h
n

may have varying stepsizes. Cases
t = T
1
= n h,
and h h/2
m
= h

,
t = T
m
= n2
m
h

Intro to SDEs with with Examples


Stochastic Differential Equations
Types of Solutions to SDEs
Strong Solutions
allow pathwise comparisons when
t
n
= T
1
= T
m
= n h
w(T
m
+h

) =

1
w(T
m
+h

+ h

) =

1
+

2
. . .
w(T
m
+h) =

m
k=1

k
w(T
1
+h) = w(T
m
+h)
Here, one follows the pathwise convergence as m is changed. See
Kloeden and Platen, chapt. 9, p. 309. One compares "exact" solution,
equation (1), with simulation values at points T
1
= T
m
.
Intro to SDEs with with Examples
Stochastic Differential Equations
Types of Solutions to SDEs
Strong Solutions
Numerical criteria similar: discrete times t
k
= kh, h = step size,
T = Mh, and
z
k
= numerical approx.,
strong order :
(E max
0kM
|z
k
z(t
k
)|
2
)
1/2
K
1
h

weak order : for f (z) C


2
,
|Ef (z
M
) Ef (z(T))| K
2
h

Intro to SDEs with with Examples


Stochastic Differential Equations
Examples
Examples
Example methods:
Euler-Maruyama
z
k+1
= z
k
+b(z
k
)h + (z
k
)W
is strong order = 1/2, weak order 1.
Milstein
z
k+1
=z
k
+b(z
k
)h +(z
k
)W
+
1
2
(z
k
)

(z
k
)(W
2
h)
is strong order = 1, weak order 1
Intro to SDEs with with Examples
Stochastic Differential Equations
Higher-Order Methods
Higher-Order Methods
Higher order weak methods require modeling
I
ij
=
_
h
0
w
i
dw
j
I
i 0
=
_
h
0
w
i
(s)ds
I
ijk
=
_
h
0
w
i
w
j
dw
k
I
ii 0
=
_
h
0
w
2
i
ds
For example, for Runge-Kutta type methods
I
ij

1
2

j
+
h
2

ij
,
I
i 0

h
2

i
,
I
ijk

h
2

ij

k
I
ii 0

h
2

2
i

ij
is a model for
_
w
i
dw
j
w
j
dw
i
.
Intro to SDEs with with Examples
Stochastic Differential Equations
Higher-Order Methods
Examples
w = is approximately gaussian
E = 0, E
2
= h, E
3
= 0, E
4
= 3h
2
.
Do N sample paths per time-step - one for each z
[i ]
. A simple w is
=

3h with probability
1
6
,
=

3h with probability
1
6
,
= 0 with probability
2
3
.
Important facts about these bounded increments:

they introduce Fourier spectra with wave vectors = k

3h, where
k Z
d
.

in d > 1 dimensions, w is not isotropic.


Intro to SDEs with with Examples
Stochastic Differential Equations
Higher-Order Methods
Examples
w = is approximately gaussian
E = 0, E
2
= h, E
3
= 0, E
4
= 3h
2
.
Do N sample paths per time-step - one for each z
[i ]
. A simple w is
=

3h with probability
1
6
,
=

3h with probability
1
6
,
= 0 with probability
2
3
.
Important facts about these bounded increments:

they introduce Fourier spectra with wave vectors = k

3h, where
k Z
d
.

in d > 1 dimensions, w is not isotropic.


Intro to SDEs with with Examples
Stochastic Differential Equations
Higher-Order Methods
Examples of Bounded Increments
Figure: 3-D distribution of bounded increments
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Some Applications
Some applications:

Black-Scholes model for asset volatility

Langevin dynamics

shearing of light in inhomogeneous universes


Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Some Applications
Some applications:

Black-Scholes model for asset volatility

Langevin dynamics

shearing of light in inhomogeneous universes


Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Some Applications
Some applications:

Black-Scholes model for asset volatility

Langevin dynamics

shearing of light in inhomogeneous universes


Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Black-Scholes
Black-Scholes model. Let S = asset price, r = interest rate. Without
volatility,
dS = r S dt .
With efcient market hypothesis, uctuations(S) S:
dS = rS dt +S dw.
is called the volatility. Solution to SDE
S(t ) = S
0
e
(r
1
2

2
)t +w(t )
.
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Langevin Dynamics
Langevin dynamics: we want some physical quantity
Ef =
_
p(x)f (x)d
n
x =
_
e
S(x)
f (x)d
n
x
_
e
S(x)
d
n
x
.
To nd a covering distribution q(x), q(x) p(x), but 1 is not
large - difcult if n large.
Alternative is Langevin dynamics:
dx(t ) =
1
2
S
x
dt +dw(t ),
and use
Ef = lim
T
1
T
_
T
0
f (x(t ))dt .
The following is sufcient for convergence: if |x| big,
x
S
x
> 1
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
A Simple Example
A simple example: dx = sign(x)dt +dw, whose p.d.f as t is
p(x, ) = e
2|x|
.
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Stochastic Dyer-Roeder
Stochastic Dyer-Roeder: Sachs equations for shear (), ray
separation , in free space with scattered point-like particles:
d
ds
+2 = F
d
ds
+
2
+||
2
= 0
is complex, F is the Weyl term, and s is an afne parameter -
related to redshift z.
=
1
2
d
dz
ln(A)
where A D
2
is the beam area, get two eqs.,
d
ds
+2
1
D
dD
ds
= F
1
D
d
2
D
ds
2
+||
2
= 0.
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Stochastic Dyer-Roeder
In Lagrangian coordinates (contract with redshift z), the Weyl term to
1
st
order has derivatives of the gravitational potential (x, y), with
z = x +i y:
F =
1
c
2
(1 +z)
2
d
2

dz
2
.
Light "sees" shearing forces orthogonal to congruence. Problem is
essentially 2-D:
x
y
light ray
scattering plane
Figure: 2-D character of light scattering
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Stochastic Dyer-Roeder
Correlation length is about 7 cells, i.e. 7 Mpc at z = 0. Softened
(2-3 cells) shears are normal in < 128 Mpc.
Figure: Shearing forces, from H. Couchmans code
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Stochastic Dyer-Roeder
More useful form for 1st:
D
2
=
_
s
0
D
2
(s

)F(s

)ds

.
Expressing the afne parameter in terms of the redshift
s =
_
z
0
d
(1 +)
3

1 +)
Yields a generalized Dyer-Roeder eq.
(1 +z)(1 +z)
d
2
D
dz
2
+(
7
2
z +

2
+3)
dD
dz
+
|(z)|
2
(1 +z)
5
D = 0.
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Stochastic Dyer-Roeder
Shear can be well approximated by
(z) =
3
8(D(z))
2

_
z
0
(D())
2
(1 +)(1 +)

1
2
dw()
where w(z) is a complex (2-D) B-motion. Constant 0.62 was
determined by N-body simulations.
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Stochastic Dyer-Roeder
Figure: Shear free Dyer-Roeder D(z)
Intro to SDEs with with Examples
Stochastic Differential Equations
Some Applications
Stochastic Dyer-Roeder
Figure: D(z) histograms at 0 z 5. Non-linear integration. Scales for the
abscissas are: 10
6
for z = 1/2, 10
5
for z = 1, 2, 3, 4, 5.
Intro to SDEs with with Examples
Stability
Weak Solutions
Weak Simulations
Recall some basic rules of the It calculus
Edw(t ) = 0
E{dw(t ) dw(s)} = (t s) dt ds
Multi-dimensional version
dw
i
(t )
2
dt or dw
i
(t )dw
j
(t )
ij
dt
Usual z(t ) C
0
process:
dz = b(z) dt +(z) dw(t ) (SDE)
is shorthand for
z(t ) = z
0
+
_
t
0
b(z
s
) ds +
_
t
0
(z
s
) dw
s
.
Stochastic integral is non-anticipating. Important thing about It rule:
E{
_
t
0
(z
s
)dw
s
} = 0.
Intro to SDEs with with Examples
Stability
Weak Solutions
Weak Simulations
Taking the expression for z(t ) for one step t t +h,
z(t +h) = z
t
+
_
t +h
t
b
s
ds +
_
t +h
t

s
dw
s
,
and substituting z(s) from the right-hand side into the left side
integrals, e. g.
_
t +h
t
b(z
s
) ds =
_
t +h
t
b(z
t
+
_
s
t
b
u
du +
_
s
t

u
dw
u
) ds.
Since t u s t +h and
_
s
t

u
dw(u) = O((s t )
1/2
)
an expansion gives, including the
_
dw term, Picard-fashion, a
stochastic Taylor series (due to Wolfgang Wagner)
Intro to SDEs with with Examples
Stability
Weak Solutions
Weak Simulations
Truncating Taylor series to O(h) accuracy, we get Milsteins method
(scalar case):
z(t +h) = z(t ) +hb(z(t )) +(z(t ))
+
1
2

(
2
h)
Again
=

h
where =zero-centered, univariate normal:
E = 0, E
2
= 1.
Notice that because E
2
= h, Milsteins term preserves the
Martingale property
E
1
2

t
(
2
h) = 0.
Intro to SDEs with with Examples
Stability
Weak Solutions
Weak Simulations
It is not hard to modify this for vector case:
z
t +h
= z
t
+hb
t
+
t
w+
1
2

t

Where matrix is a model

_
t +h
t

=
h
2
(

) >
=
h
2
(

1
+

) <
=
h
2
((

1
)
2
1) =
Additional variables

are also zero-centered, univariate normals


but independent of the s in

.
Intro to SDEs with with Examples
Stability
Higher-Order Schemes
Higher-Order Schemes
Here is a second order accurate method. Writing b = A +B,
z

t +h
= z

t
+
h
2
(A

(z
t +h
) +B

(z
t
+
t

1
+(A
t
+B
t
)h)
+A

(z
t
) +B

(z
t
))
+
1
2
{

(z
t
+
_
1
2

0
+
h
2
(A
t
+B
t
))
+

(z
t

_
1
2

0
+
h
2
(A
t
+B
t
))}

1
+(

t
)

.
The rst A(z
t +h
) is implicit.
Intro to SDEs with with Examples
Stability
Examples
An Example
Lets take a simple case, M > 0 (stable matrix),
dz = Mzdt +dw
and write M = A +B, where I +hA is easy to invert. The semi-implicit
algorithm is
(I +hA) z
t +h
= (I hB) z
t
+ w
or
z
t +h
= (I +hA)
1
((I hB) z
t
+w)
In particular case A = B =
1
2
M,
z
t +h
= (I +
h
2
M)
1
((I
h
2
M)z
t
+w).
Stability of procedure will depend on L
2
norm
||(I +
h
2
M)
1
(I
h
2
M)|| < 1.
Intro to SDEs with with Examples
Stability
Examples
An Example
Even in scalar case, when h is large enough (h > 2/M), |1 hM| > 1,
but
|(1 hM/2)/(1 +hM/2)| 1
for all h > 0.
Two dimensional case when scales of e.v.s are very different:
_
dx
dy
_
=
1
2
_

1
+
2
,
1

2
,
1
+
2
_ _
x
y
_
dt
+
_
dw
1
(t )
dw
2
(t )
_
.
which converges for
i
> 0, but if
1

2
, the stepsize
h < 2/
1
- too small to be useful. This is stiffness, just
like in the ODE case.
Intro to SDEs with with Examples
Stability
Examples
Another Example
For real, SPD matrix M:
dz = Mzdt +dw.
The solution is formally
z(t ) = e
Mt
z(0) +
_
t
0
e
M(st )
dw(s).
Large t corr. matrix approximates
1
2
M
1
:
Ez
i
()z
j
() =
1
2
[M
1
]
ij
.
For big M, actual computational method is
Ez
i
()z
j
()
1
T
_
T
0
z
i
(t )z
j
(t )dt
as T gets big, from the ergodic theorem.
Intro to SDEs with with Examples
Stability
Examples
Non-Symmetric Case
Non-symmetric case:
dX = MXdt +dw,
dY = M
T
Ydt +dw,
initial conditions X(0) = Y(0) = 0. Same nD w for both X(t ), Y(t ).
From formal solutions, extract X, Y covariance
EX(t )Y
T
(t )
1
2
M
1
as t .
Again, splitting M = A +B, a stabilized and cheap procedure for each
X(t ), Y(t ) is
z
t +h
= (I +hA)
1
(I hB) z
t
+w
where in the diffusion term, we ignore the O(h
3/2
) contribution.
Examples: A = diag(M), or A = tridiag(M)
Intro to SDEs with with Examples
Stability
Examples
A Test Problem
Test problem: M = U
T
TrU, where Tr = upper triangular,
diag(Tr ) = (1, . . . , N), [Tr ]
i ,j
N(0, 1), j > i . Random orthogonal U
by Pete Stewarts procedure: S = diag(sign(u
1
))
U = SU
0
U
1
. . . U
N2
where
U
k
=
_
I
k
H
Nk
_
H
j
= Householder transforms,
H
j
= I
j
2
uu
T
||u||
2
with j length vectors u
u = x ||x||e
1
,
each x
i
N(0, 1), i = 1, . . . , j . Also, cond(M) N.
Intro to SDEs with with Examples
Stability
Numerical Examples
Convergence of the Euler Method
1
Intro to SDEs with with Examples
Stability
Numerical Examples
Convergence of a Second-Order Method
1
Intro to SDEs with with Examples
Stability
Numerical Examples
More Examples
More general problems? Some has been done. Talay, Tubaro, and
Ballys Euler estimates
|Ef (z(T)) Ef (z
n
(T))| h
K(T)||f ||

T
q
h = T/n = time step, q > 0 constant, and K(T) is non-decreasing.
Optimal choice of T is unclear. Example of Langevin dynamics,
dz(t ) = b(z)dt +dw(t ), (2)
want z to converge to stationary. For large |z(t )|,
E|z +z|
2
E|z|
2
.
From eq. (2),
2z b(z) 1
Discretization errors O(h) for Euler, O(h
2
) for 2nd order RK.
Intro to SDEs with with Examples
Stability
Numerical Examples
A Final Example
A nal example model problem, where m Z
+
dx = x|x|
m1
dt +dw(t )
Two procedures: =

h ,
x
h
= XTR(x
0
, )
= x
0

h
2
(x
euler
|x
euler
|
m1
+x
0
|x
0
|
m1
)
+
x
h
= ITR(x
0
, )
= x
0

h
2
(x
h
|x
h
|
m1
+x
0
|x
0
|
m1
)
+
Intro to SDEs with with Examples
Stability
Numerical Examples
A Final Example
Intro to SDEs with with Examples
Bibliography
Selected Bibliography
[1] P. E. Kloeden and E. Platen, Numerical Solution of Stochastic
Differential Equations, Springer, 1999.
[2] G. N. Milstein Numerical Integration of Stochastic Differential
Equations, Kluwer, 1995.
[3] W. Petersen, J. Comp. Physics, 113(1), July 1994.
[4] W. Petersen, J. Stoch. Analysis and Applications, 22(4):
9891008, 2004.
[5] W. Petersen, SIAM Journal on Numerical Analysis, 35(4): 1439,
1998.
[6] F. Buchmann and W. Petersen, Preconditioner..., SAM Report,
2003.
[7] G. W. Stewart, SIAM Journal on Numerical Analysis, 17(3), 1980.

You might also like