Numerical Simulation of Stochastic Differential Equations: Lecture, Part Des Higham Department of Mathematics University of Strathclyde Course Aim: Give an accessible intro. to SDEs and their numerical simulation. Motivation: SDEs are becoming widely used in science and engineering; notably finance, physics and biology. It may very well be said that the best way to understand SDEs is to work with their numerical solutions. Salih N. Neftci, in An Introduction to the Mathematics of Financial Derivatives, Academic Press, 2nd Edition, 2. 6 p./8 Things not treated here include: Ito s lemma Convgnce/stability analysis of numerical methods Systems of SDEs Connection to Fokker Planck PDE Course Overview Overview of Lecture, Part : Background Mater Lecture : Part : Background Material Part 2: Stochastic Differential Equations Lecture 2 : Part : Euler Maruyama Method Part 2: Application: Mean Exit Time Random variables Monte Carlo simulation Brownian motion 6 p.3/8
Continuous Random Variable, X Properties of Random Variables Probability: P(a X b) = b a f(x) dx E[X + Y] = E[X] + E[Y] E[αX] = αe[x] var[αx] = α 2 var[x] Expected Value (mean): Variance: E[X] = xf(x) dx var(x) = E((X E(X)) 2 ) We can +,,, and apply functions to get new random variables: sin(x), e X+Y2,... X & Y are indepent E[g(X)h(Y)] = E[g(X)]E[h(Y)], Hence, { X & Y indep. for all g, h : R R E[XY] = E[X]E[Y] var[x + Y] = var[x] + var[y] 6 p.5/8 Normal Random Variables Properties of Normal Random Variables Density Mean is µ, variance is σ 2 We write X N(µ, σ 2 ) f(x) = e (x µ)2 2σ 2 2πσ 2.5.45 N(,) density. If X N(µ, σ 2 ) then (X µ)/σ N(, ) 2. If Y N(, ) then σy + µ N(µ, σ 2 ) 3. If X N(µ, σ 2), Y N(µ 2, σ2 2 ) and X and Y are indepent, then X + Y N(µ + µ 2, σ 2 + σ2 2 ) 4. If X and Y are normal random variables then X and Y are indepent if and only if E[XY] = E[X]E[Y].4.35.3 f(x).25.2.5..5 5 4 3 2 2 3 4 5 x 6 p.7/8
In words: Central Limit Theorem the sum of a large number of indepent random variables (whatever their distribution!) behaves like a normal random variable In maths: Let {X i } i be i.i.d. with mean a and variance b 2. Then for all α < β lim M P ( α M i= X i Ma Mb β ) = 2π β α e 2 x2 dx Pseudo-random Number Generation in MATLA rand for uniform (,), randn for N(,) En masse, the samples are designed to have the appropriate statistical properties: >> rand( state,); randn( state,) >> [rand(,), randn(,)] ans =.3929.985.6398-2.227.7245 -.239.6953.687.958-2.22.9429 -.364.635 -.83.5 -.9797.474.7882.9663.7366 6 p.9/8 Illustration of CLT 4 samples of Z = e Y, where Y is a Bernoulli r.v. Shift and scale for CLT: for k = :L Z = exp(double(rand(m,)>(-p))); S(k) = (sum(z) - M*a)/(b*sqrt(M));.45.4.35.3.25.2.5..5 N(,) density Sample data 5 5 Monte Carlo Simulation Suppose we can sample from a random variable X. Letting a = E[X] and b 2 = var[x], we want to estimate a. a M := M M i= b 2 M := M Then CLT ξ i (sample mean) M (ξ i a M ) 2 (sample variance) i= [ ] a M.96 bm, a M +.96 bm M M is an approximate 95% confidence interval for a. 6 p./8
Brownian Motion, W(t), over t T Discretized Brownian Path W() = (with probability ) 2 For s < t T, W(t) W(s) is N(, t s) 3 For s t u v T, W(v) W(u) & W(t) W(s) are indep. δt = T/L W = for i = to L- compute a N(,) sample ξ i W i+ = W i + δt ξ i Hence, W(t + δt) W(t) is N(, δt), i.e. δt N(, ) 6 p.3/8 Discretized Brownian Path δt = T/L W = for i = to L- compute a N(,) sample ξ i W i+ = W i + δt ξ i Scaling Property For any fixed c >, if W(t) is an example of Brownian motion, then so is V(t) := c W(c2 t) (Simple to check the three defining conditions.) E.g., c = /:.5 W(t).5.5 W i.5 T t.5 *W(t/).5.5..2.3.4.5.6.7.8.9 t i 6 p.4/8.5 T/ t
Non-differentiability bpath.m %BPATH Brownian path simulation Scaling property can be used to show that ( W(/n 4 ) ( ) P /n 4 > n = P W() > ) n So, with prob., W(t) is not differentiable at the origin. In fact W(t) is nowhere differentiable. In Part 2... we will see how to integrate with respect to W(t). clf randn( state,) % set the state of randn T = ; N = 5; dt = T/N; dw = zeros(,n); % preallocate arrays... W = zeros(,n); % for efficiency dw() = sqrt(dt)*randn; % first approx outside loo W() = dw(); % since W() = not allow for j = 2:N dw(j) = sqrt(dt)*randn; % general increment W(j) = W(j-) + dw(j); 6 p.6/8 plot([:dt:t],[,w], r- ) % plot W against t xlabel( t, FontSize,6) ylabel( W(t), FontSize, 6, Ro tati on, ) bpath2.m %BPATH2 Brownian path simulation: vectorized clf randn( state,) % set the state of randn T = ; N = 5; dt = T/N; dw = sqrt(dt)*randn(,n); % increments W = cumsum(dw); % cumulative sum plot([:dt:t],[,w], r- ) % plot W against t xlabel( t, FontSize,6) ylabel( W(t), FontSize, 6, Ro tati on, ) 6 p.8/8