Library: | times |
See also: | simgOU simHeston |
Quantlet: | simGBM | |
Description: | Simulation of discrete observations of a Geometric Brownian Motion (GBM) via direct integration (method=1) or Euler scheme (method=2). The process follows the stochastic differential equation: dX(t) = mu X(t) dt + sigma X(t) dW(t). |
Usage: | x = simGBM(n,x0,mu,sigma,delta,method) | |
Input: | ||
n | scalar, time. The number of observations is represented by (ceil(n/delta)+1) | |
x0 | scalar, starting value of the process | |
mu | scalar, drift | |
sigma | scalar, volatility | |
delta | scalar, time step size. The process is simulated at time points 0, delta, 2*delta, ..., n*delta | |
method | scalar, optional, method=1 (default) - direct integration method=2 - Euler scheme | |
Output: | ||
x | (n+1) x 1 vector, simulated trajectory |
library("times") library("plot") randomize(102) time =(0:100) x = simGBM(1,0.84,0.02,sqrt(0.1),1/100) pp=setmask(time~x,"line","blue") plot(pp) setgopt(plotdisplay,1,1,"xlabel","time t","ylabel","X(t)")
A display containing a typical trajectory of a GBM is shown.