set.seed(123)
alive <- vector("list", 20)
mu <- 0.1
n <- 10
alive[[1]] <- rbinom(n, 100, exp(-mu))
for(i in 2:20)
alive[[i]] <- rbinom(n, alive[[i-1]], exp(-mu))
I renamed the variable sample
to n
to avoid confusion with the commonly used function sample()
.