Using R for (discrete) modeling
There are two aspects to your question: conceptual and coding.
, :
1.
, , , , , , . , , , .
, , , , $\ Delta t $. , , .
, , ( ) . $W_t $ , , . ( $W_t $, , .)
:
- $x $ , .. $\ epsilon_t = 0 $.
- $W_t $ $W_0 $. , . , $W_0 $, - 1000 .
- , , $W_0 $ $\ epsilon_0 = x $, $W_1 $.
- : $x $ - $\ epsilon_1 $. , $W_2 $ ..
2. ( )
R , .
, , .
, $\ pi $- .
, , :
dt <- 0.5
r <- 1
lambda <- 1
sigma <- 1
w0 <- rep(1,1000)
x <- rnorm(1000,mean=0,sd=1)
w1 <- w0*exp(r*dt)*(1+exp((sigma*lambda-0.5*sigma^2)*dt +
sigma*x*sqrt(dt) -1))
, , . , , , .
w <- w*exp(r*dt)*(1+exp((sigma*lambda-0.5*sigma^2)*dt +
sigma*rnorm(1000,mean=0,sd=1)*sqrt(dt) -1))
(5- ):
hist(w)
summary(w)
, , , - $\ pi $, - - R .