fun=function(x0,t,deltat,mu,sigma) { n=t/deltat x.t=vector(length=n) x.t[1]=x0+(mu*deltat+sigma*sqrt(deltat)*rnorm(1)) for (I in 2:n) { x.t[i]=x.t[i-1]+(mu*deltat+sigma*sqrt(deltat)*rnorm(1)) } return(x.t) } 1/26 end.fun=function(s0,t,mu,sigma,m){ end.s=vector(length=m) for (j in 1:m){ temp=gbm.fun(s0,t,mu,sigma) end.s[j]=temp[length(temp)]} return(end.s)} gbm.fun=function(s0,t,mu,sigma){ deltat=1/365 n=t/deltat s.t=vector(length=n) deltas=s0*(mu*deltat+sigma*sqrt(deltat)*rnorm(1))…
Words 510 - Pages 3