全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 经管百科 爱问频道
1371 0
2018-03-03
S0=2986.6;      #initial price S0
mu=0.019623;    #drift mu
sigma=0.2893;  # volatility sigma
T=1;        #1 year
NSteps=48;
NReps=10000;
SPaths = matrix(NA,NReps,NSteps+1);
SPaths[,1] = S0;
dt = T/NSteps
nudt = (mu-0.5*sigma^2)*dt
sidt = sigma*sqrt(dt)
x=seq(1:(NSteps+1))
colno=c(1,2,3,4,5,6,7,8,9,10)
set.seed(123)
for (i in 1:NReps){
  for (j in 1:NSteps){
    SPaths[i,j+1] = SPaths[i,j]*exp(nudt + sidt*rnorm(1))
  }
  if(i == 1) plot(x,SPaths[i,],"l", xlab="时间t",ylim=c(1500,5000),ylab="上证50指数",col =sample(colno,1))
  if (i != 1) lines(x,SPaths[i,],xlab="时间t",ylim=c(1500,5000),ylab="上证50指数",col =sample(colno,1))

}

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群