0

我正在尝试编写一个基本模型来模拟人口的增长(其初始大小是从正态分布中随机抽取的),然后每个“年”按用户定义的数量增长(目前在下面的代码中有 2 个人作为参数清酒)。产生的输出只显示了一个模拟的结果,在这个模拟中,人口根本没有增长,即每一“年”人口没有增长/不增加之前的“年”人口. 我假设我已经在循环结构中塞满了一些东西,并且渴望得到任何建议!

n.years <- 3
n.sim <- 5
store.growth <- matrix(ncol=3,nrow= (n.years * n.sim))

for (i in 1:n.sim) {
 init.pop.size <- rnorm(1,100,10)
 for (j in 1:n.years){
    #grow population
    grow.pop <- init.pop.size + 5
    store.growth[j,] <- cbind(grow.pop, n.years, n.sim)
 }
}
store.growth
4

0 回答 0