## Example 1: BM
## v = k * Dt with k integer , 1 <= k <= N .
## k = 500 nombre for discretization
## Dt = 0.001 ===> v = 500 * 0.001 = 0.5
## drift <- expression(0)
## diff <- expression(1)
## AnaSimX(N=1000,M=30,t0=0,Dt=0.001,T=1,X0=0,v=0.5,drift,diff,Output=FALSE,Methods="Euler")
## summary(X)
## hist(X)
## v=0.5
## plot(density(X,kernel ="gaussian"),col="red")
## x <- seq(min(X),max(X),length=1000)
## curve(dnorm(x,0,v), col = 3, lwd = 2, add = TRUE,
## panel.first=grid(col="gray"))
## Example 2: BMG or BS
## v = k * Dt with k integer , 1 <= k <= N .
## k = 800 nombre for discretization
## Dt = 0.001 ===> v = 800 * 0.001 = 0.8
## drift <- expression(2*x)
## diff <- expression(x)
## AnaSimX(N=1000,M=30,t0=0,Dt=0.001,T=1,X0=1,v=0.8,drift,diff,Output=FALSE,Methods="Euler")
## summary(X)
## hist(X)
## plot(density(X,kernel ="gaussian"),col="red")
Run the code above in your browser using DataLab