Library: | times |
See also: |
Quantlet: | simou | |
Description: | Simulation of discrete observations of an Ornstein-Uhlenbeck process via its transition probability law. The simulated process follows the stochastic differential equation: dX(t) = aX(t) dt + s dW(t). |
Usage: | x = simou(n,a,s,delta) | |
Input: | ||
n | scalar, (n+1) represents the number of observations | |
a | scalar, drift parameter of the simulated Ornstein-Uhlenbeck process, a has to be smaller than 0 to make the process stationary | |
s | scalar, diffusion parameter of the simulated Ornstein-Uhlenbeck process | |
delta | scalar, time step size. The process is simulated at time points 0, delta, 2*delta, ..., n*delta | |
Output: | ||
x | (n+1)-dimensional vector, containing the simulated trajectory |
randomize(123) n = 1000 ; number of observations a = -1 ; speed of adjustment s = .1 ; diffusion coefficient delta = 0.001 ; time step size ou = simou(n,a,s,delta) ; simulation of a path of an OU process in [0,1](n*delta = 10) time =(0:n)*delta ; time scale library("plot") d=createdisplay(1,1) ouplot = setmask(time~ou,"line") show(d,1,1,ouplot) setgopt(d,1,1,"xlabel","time t","ylabel","X(t)") setgopt(d,1,1,"yvalue",0|1)
A display containing a typical trajectory of an OU process in [0,1] is shown.