0% found this document useful (0 votes)
36 views47 pages

Applied Stochastic Calculas 2

Uploaded by

Paritosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views47 pages

Applied Stochastic Calculas 2

Uploaded by

Paritosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Simulating and Manipulating

Stochastic Differential
Equations
In this lecture. . .

• Using Itô’s lemma to manipulate stochastic differential equa-


tions

• Continuous-time stochastic differential equations as discrete-


time processes

• Simple ways of generating random numbers in Excel

• Correlated random walks

1
By the end of this lecture you will be able to

• manipulate stochastic differential equations

• find transition probability density functions for arbitrary stochas-


tic differential equations

• simulate stochastic differential equations

2
Introduction

In order to become comfortable with the kind of models com-


monly used in quantitative finance you must be able to manipu-
late stochastic differential equations and generate random walks
numerically.

3
Manipulating stochastic differential equations

An equation of the form

dG = a (G, t) dt + b (G, t) dX

is called a Stochastic Differential Equation (SDE) for G (or ran-


dom walk for dG) and consists of two components:

1. a (G, t) dt is deterministic – coefficient of dt is known as the


drift or growth

2. b (G, t) dX is random – coefficient of dX is known as the


diffusion or volatility

and we say G evolves according to (or follows) this process.

4
So if for example we have a random walk

dS = µSdt + σSdX (1)

then the drift is a (S, t) = µS and the diffusion is b (S, t) = σS.

The process (1) is also called Geometric Brownian Motion


(GMB) or Exponential Brownian motion (EMB) and is a pop-
ular model for a wide class of asset prices.

5
We have previously considered Itô’s lemma to obtain the change
in a function f (X ) when X → X + dX , where X is a standard
Brownian motion.

This jump df = f (X + dX ) − f (X ) is given by

df d2f
df = dX + 1
2 dX 2 dt (2)
dX

using the result

limdt→0 dX 2 = dt.

6
Suppose we now wish to extend the result (2) to consider the
change in an option price V (S ) where the underlying variable S
follows a geometric Brownian motion.

(Of course, you are not supposed to know anything about options
yet. Just think of manipulating functions.)

7
If we rewrite (1) as

dS
= µ dt + σ dX
S

then dS represents the change in asset price S in a small time


interval dt.

This expression is the return on the asset.

µ is the average growth rate of the asset and σ the associated


volatility (standard deviation) of the returns.

dX is an increment of a Brownian Motion, known as a Wiener


process and is a Normally distributed random variable such that
dX ∼ N (0, dt).

8
An obvious question we may ask is, what is the jump in V (S + dS )
when S → S + dS?

We begin (again) by using a Taylor series as in (2), but for


V (S + dS ) to get

dV 1 d2V 2.
dV = dS + 2 dS
dS dS 2

9
We can proceed further now as we have an expression for dS
3
(and hence dS ). As dt is very small, any terms in dt 2 or dt2 are
2
insignificant in comparison and can be ignored. So working to
O (dt)
dS 2 = σ 2S 2dt.

If we substitute this into the previous expression for dV we get


Itô’s lemma as applied to V (S):

   
dV 2 2 d2V dV
dV = µS +1
2 σ S dt + σS dX. (3)
dS dS 2 dS

Note that this is another stochastic differential equation!

It contains a predictable part and a random part.

10
Suppose that we had a formula for V (S). Let’s take a very
special case, let’s consider

V (S) = log S.

Differentiating this once gives

dV 1
= .
dS S

Differentiating this again gives

d2V 1
2
= − 2
.
dS S

11
Now from (3) we have

 
1 2
d (log S ) = µ − 2 σ dt + σdX.

Integrating both sides between 0 and t

 t  t  t
1 2
d (log S ) = µ − σ dτ + σ dX (t > 0)
0 0 2 0
 
1 2
= µ − 2 σ t + σ (X (t) − X (0)) .

12
Therefore

 
S (t)  
1 2
log = µ − 2 σ t + σ (X (t) − X (0))
S (0)

Assuming X (0) = 0 and S (0) = S0, the exact solution becomes

  
1 2
S(t) = S0 exp µ − 2 σ t + σX(t) . (4)

13
Another example:

Let’s take a look at the Vasicek interest rate model for short-
term interest rates, and try manipulating that.

dr = γ (r − r) dt + σdX.

γ refers to the reversion rate and r denotes the mean rate.

14
By setting u = r − r, u is a solution of

du = −γu dt + σdX.

An analytic solution for this equation exists. To see, this write


the equation as
 
d ueγt = σeγt dX.

Integrating over from zero to t gives


 t
u(t) = u(0)e−γt + σ eγ(s−t)dXs.
0

This can be integrated by parts to give


  t 
u(t) = u(0)e−γt + σ X(t) − γ X(s)eγ(s−t) ds .
0

15
Transition probability density functions again

Let’s look at the equations governing the probability distribution


for an arbitrary random walk:

dy = A(y, t) dt + B(y, t) dX
for the variable y.

Remember the transition probability density function p(y, t; y , t)


defined by
 b
Prob(a < y  < b at time t|y at time t) = p(y, t; y , t) dy .
a

In words this is ‘the probability that the random variable y lies


between a and b at time t in the future, given that it started out
with value y at time t.’

16
Think of y and t as being current values with y  and t being
future values.

The transition probability density function can be used to answer


questions such as

“What is the probability of the variable y being in a certain


range at time t given that it started out with value y at
time t?”

17
The transition probability density function p(y, t; y , t ) satisfies
two equations.

One involves derivatives with respect to the future state and


time (y  and t) and is called the forward equation.

The other involves derivatives with respect to the current state


and time (y and t) and is called the backward equation.

These can be derived by the same trinomial idea we used be-


fore (but the details are a lot messier for the general stochastic
differential equation).

18
The forward equation

Cutting to the chase, the transition probability density function


satisfies the partial differential equation

∂p 1 ∂2    2
 ∂   


= 2 2 B(y , t ) p −  A(y , t )p
∂t ∂y ∂y

This is the Fokker–Planck or forward Kolmogorov equation.

19
Example: The most important example to us is that of the
distribution of equity prices in the future. If we have the random
walk
dS = µS dt + σS dX

then the forward equation becomes

∂p ∂ 2   ∂   
1 2 2
= 2 2 σ S p − µS p .
∂t ∂S ∂S 

The solution of this representing a stock price starting at S  = S


at t = t is

 2
1 − log(S/S )+(µ− 1 σ 2)(t−t) /2σ 2(t−t)
p(S, t; S , t) =  e 2
σS  2π(t − t)

20
0.006

0.005

0.004

0.003

0.002

0.001

0
0 50 100 150 200 250

The probability density function for the lognormal random


walk, after a certain time.

21
0.014
0.012
0.01
0.008
0.006
0.004
1 0.002
0.75 0

250
232
0.5

214
196
Time

178
160
142
124
0.25

106
88
70
52
34

Asset
16

The probability density function for the lognormal random walk


evolving through time.

22
The steady-state distribution

Some random walks have a steady-state distribution.

That is, in the long run as t → ∞ the distribution p(y, t; y , t) as


a function of y  settles down to be independent of the starting
state y and time t. Possible examples are stochastic differential
equation models for interest rates, inflation, volatility.

Some random walks have no such steady state even though they
have a time-independent equation. For example the lognormal
random walk either grows without bound or decays to zero.

23
If there is a steady-state distribution p∞(y ) then it satisfies the
ordinary differential equation

d2   d
1 2
2 dy 2 B p∞ − dy  (Ap∞) = 0.

Example: The Vasicek model

dr = γ (r − r) dt + σdX.

The steady-state distribution p∞(r) satisfies

2  
1 σ 2 d p∞ − γ d (r − r  )p
2 2  ∞ = 0.
dr dr

24
The solution is

 2
1 γ − γ(r̄−r2 )
p∞ = e σ .
σ π

In other words, the interest rate r is Normally distributed with



mean r̄ and standard deviation σ/ 2γ.

25
The backward equation

Now we come to the backward equation. This will be useful if


we want to calculate probabilities of reaching a specified final
state from various initial states.

The transition probability density function satisfies the backward


Kolmogorov equation

∂p 2
1 2∂ p ∂p
+ 2 B(y, t) 2
+ A(y, t) = 0.
∂t ∂y ∂y

26
Simulating the lognormal random walk

The lognormal random walk model for assets can be written in


continuous time as

dS = µS dt + σS dX.

In discrete time this is

 
1/2
Si+1 − Si = Si µ δt + σφ δt .

To generate representative simulations of possible asset paths


we must obviously work in discrete time.

27
The random walk on a spreadsheet

The random walk can be written as a ‘recipe’ for generating Si+1


from Si:
 
Si+1 = Si 1 + µ δt + σφ δt1/2 .

We can easily simulate the model using a spreadsheet.

The method is called the Euler method.

28
Start with an initial stock price, say, 100.

And a couple of parameters, µ = 0.1 and σ = 0.2, say, that best


represent the asset in question.

Decide on a (small) time step, δt = 0.01, say.

Now start picking random numbers!

29
First time step: The random number is. . . 0.12. So

Si+1 = 100 (1 + 0.1 × 0.01 + 0.2 × 0.1 × 0.12) = 100.34.

Second time step: The random number is. . . -0.25. So

Si+1 = 100.34 (1 + 0.1 × 0.01 + 0.2 × 0.1 × (−0.25)) = 99.94.

And so on.

30
In this simulation there are several input parameters, which re-
main constant:

• a starting value for the asset

• a time step δt

• the drift rate µ

• the volatility σ

• the total number of time steps

Then, at each time step, we must choose a random number φ


from a Normal distribution.

This can be done easily in Excel in several ways, we will see a


couple now.

31
Slow but accurate

The Excel spreadsheet function RAND() gives a uniformly-distributed


random variable.

This can be used, together with the inverse cumulative distribu-


tion function NORMSINV to give a genuinely Normally distributed
number:

• NORMSINV(RAND()).

Why does this work?

32
The pdf and cdf for the Normal distribution
1.2
0.45

0.4
1

0.35

0.3 0.8

0.25
0.6
0.2

0.15 0.4

0.1
0.2
0.05

0 0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2

The inverse cumulative distribution function


2.5

1.5

0.5

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
-0.5

-1

-1.5

-2

-2.5

33
Fast but inaccurate

An approximation to a Normal variable that is fast in a spread-


sheet, and quite accurate, is simply to add up twelve random
variables drawn from a uniform distribution over zero to one,
and subtract six:

 
12
•  RAND() − 6.
i=1

34
Why 12?

Any ‘large’ number will do. The larger the number, the closer
the end result will be to being normal, but the slower it is.

Why subtract off 6?

The random number must have a mean of zero.

And the standard deviation?

Must be 1.

35
A B C D E F G
1 Asset 100 Time Asset
2 Drift 0.15 0 100
3 Volatility 0.25 0.01 96.10692
4 Timestep 0.01 0.02 96.99647
5 0.03 94.76352
6 0.04 91.46698
=D4+$B$4
7 0.05 88.83325
8 0.06 88.42727
9 0.07 90.62882
10 0.08 88.80545
11 =E7*(1+$B$2*$B$4+$B$3*SQRT($B$4)*(RAND()+RAND()+RAND()+RAND()
0.09 87.72282
12 +RAND()+RAND()+RAND()+RAND()+RAND()+RAND()+RAND()+RAND()-6))
0.1 86.84395
13 0.11 84.93865

36
180

160

140

120

100

80

60

40

20

0
0 0.2 0.4 0.6 0.8 1 1.2

37
Simulating other random walks

This method is not restricted to the lognormal random walk.

Later in the course we will be modeling interest rates as stochas-


tic differential equations.

The following is a stochastic differential equation model for an


interest rate, that goes by the name of an Ornstein-Uhlenbeck
process (an example of a mean-reverting random walk), or when
used in an interest rate context the Vasicek model:

dr = γ (r − r) dt + σdX.

In discrete time we can approximate this by

ri+1 = ri + γ (r − ri) dt + σφ δt1/2.

38
0.12

0.1

0.08

0.06

0.04

0.02

0
-1 1 3 5 7 9 11 13 15

39
Producing correlated random numbers

We will often want to simulate paths of correlated random walks.

We may want to examine the statistical properties of a portfolio


of stocks, or value a convertible bond under the assumption of
random asset price and random interest rates.

40
Example:

Assets S1 and S2 both follow lognormal random walks with cor-


relation ρ.

In continuous time we write

dS1 = µ1S1 dt + σ1S1 dX1,

dS2 = µ2S2 dt + σ2S2 dX2,


with
E[dX1 dX2] = ρ dt.

41
In discrete time these become

 
1/2
S1i+1 − S1i = S1i µ1 δt + σ1φ1 δt

and

 
1/2
S2i+1 − S2i = S2i µ2 δt + σ2φ2 δt

with

E[φ1 φ2] = ρ.

42
Q: How can we choose a φ1 and a φ2 which are both Normally
distributed, both have mean zero and standard deviation of one,
and with a correlation of ρ between them?

A: This can be done in two steps, first pick two uncorrelated


Normally distributed random variables, and then combine them.

43
Step 1: Choose uncorrelated $1 and $2, both Normally dis-
tributed with zero means and standard deviations of one.

Step 2: Convert these independent Normal numbers into corre-


lated Normals by taking a linear combination.

φ1 = $1


φ2 = ρ $1 + 1 − ρ2 $2.

44
Check:

E[φ2
1 ] = 1,

    
E φ2 2 2 2 2 2
2 = E ρ $1 + 2ρ 1 − ρ $1$2 + (1 − ρ )$2

= ρ2 + 0 + (1 − ρ2) = 1,
and
  
E [φ1φ2] = E ρ$2
1+ 1 − ρ2$1$2 = ρ.

And Normality?

45
Weighted sums of Normally distributed numbers are themselves
Normally distributed!

If Xi ∼ N (µi, σi2) for i = 1, . . . , n then

 
n n n
wiXi ∼ N  wi µ i , wi2σi2 .
i=1 i=1 i=1

46
Summary

Please take away the following important ideas

• With the right tool (Itô’s lemma) you can examine functions
of stochastic variables

• Partial differential equations can be used for finding proba-


bility density functions for arbitrary random walks

• Simulating random walks can be very easy indeed

47

You might also like