R code: 蒙地卡羅模擬 20211126
m01 <- matrix( rnorm(30*100000, 1.07, 0.2), ncol = 30 )
df1 <- matrix(4200,nrow=100000,ncol = 1)
for(i in 1:100000)
{
k <- df1[i]
ref <- m01[i,]
for(j in 1:30)
{
k <- k*ref[j]-60*1.02^(j-1)-106
}
df1[i] <-k
}
df1 <- matrix(4200,nrow=100000,ncol = 1)
for(i in 1:100000)
{
k <- df1[i]
ref <- m01[i,]
for(j in 1:30)
{
k <- k*ref[j]-60*1.02^(j-1)-106
}
df1[i] <-k
}
quantile(df1, c(.25,.26,.27))
留言
張貼留言