## Example 1: Ito sde
## dX(t) = 2*(3-X(t)) dt + 2*X(t) dW(t)
f <- expression(2*(3-x) )
g <- expression(2*x)
res <- snssde1d(drift=f,diffusion=g,M=50,x0=1,N=1000)
res
## Sim <- res$X
summary(res)
plot(res,plot.type="single")
lines(time(res),mean(res),col=2,lwd=2)
lines(time(res),bconfint(res,level=0.95)[,1],col=4,lwd=2)
lines(time(res),bconfint(res,level=0.95)[,2],col=4,lwd=2)
legend("topleft",c("mean path",paste("bound of", 95,"percent confidence")),
inset = .01,col=c(2,4),lwd=2,cex=0.8)
## Example 2: Stratonovich sde
## dX(t) = ((2-X(t))/(2-t)) dt + X(t) o dW(t)
f <- expression((2-x)/(2-t))
g <- expression(x)
res1 <- snssde1d(type="str",drift=f,diffusion=g,M=50,x0=1,N=1000,
method="milstein")
res1
summary(res1)
plot(res1,plot.type="single")
lines(time(res1),mean(res1),col=2,lwd=2)
lines(time(res1),bconfint(res1,level=0.95)[,1],col=4,lwd=2)
lines(time(res1),bconfint(res1,level=0.95)[,2],col=4,lwd=2)
legend("topleft",c("mean path",paste("bound of", 95,"percent confidence")),
inset = .01,col=c(2,4),lwd=2,cex=0.8)
Run the code above in your browser using DataLab