Simulating Bm
Simulating Bm
Simulating Bm
With an Application in R
Bocconi University
1/9
Outline
Introduction
Definition
SDE Representation
Euler Approximation
R Code
2/9
Introduction
3/9
Definition
Definition
A stochastic process B = {B(t) : t ≥ 0} is a standard Brownian
motion if:
▶ B(0) = 0 almost surely.
▶ The mapping t 7→ B(t) is continuous on [0, T ] with probability
1.
▶ B has stationary independent increments.
▶ B(t) − B(s) ∼ N (0, t − s) for 0 ≤ s < t.
4/9
Standard Brownian Motion
X (t) − x − µt
(1)
σ
is a standard Brownian motion. The process X can be constructed
from a standard Brownian motion B setting:
5/9
SDE Representation
For time-varying drift µ(t) and volatility σ(t), the equation gener-
alizes to:
dX (t) = µ(t)dt + σ(t)dB(t). (4)
R
t Rt
▶ X (t) − X (s) ∼ N s µ(u)du, s σ 2 (u)du .
▶ X has continuous sample paths and independent increments.
6/9
Euler Approximation
where:
▶ µ represents the expected return (drift term).
▶ σ represents volatility (diffusion term).
▶ dt is the time increment1 .
▶ Z (t) is an independent standard normal random variable (Z (t) ∼
N (0, 1)).
1
e.g., dt = 1/250 for daily prices, assuming 250 trading days in a year.
7/9
R Code
# define a function
sim.Brownian.motion = function(X0,dt,mu,sigma,T){
X = rep(NA,T)
Z = rnorm(T,mean=0,sd=1)
X[1] = X0
for(t in 2:T){
X[t] = X[t-1] + X[t-1]*mu*dt + X[t-1]*sigma*sqrt(dt)*Z[t]
}
return(X)
}
8/9
Graphical Visualization
100
95
Time (days)
9/9