# define a basic population
nstage <- 5
popmat <- matrix(0, nrow = nstage, ncol = nstage)
popmat[reproduction(popmat, dims = 4:5)] <- c(10, 20)
popmat[transition(popmat)] <- c(0.25, 0.3, 0.5, 0.65)
# define a dynamics object
dyn <- dynamics(popmat)
# simulate with the default updater
sims <- simulate(dyn, nsim = 1000)
# calculate distribution of minimum population sizes (default)
get_cdf(sims)
# calculate distribution of maximum population sizes
get_cdf(sims, fn = max)
# calculate distribution of the 90th percentile of
# population sizes
get_cdf(sims, fn = quantile, prob = 0.9)
# calculate distribution of minimum population sizes
# but ignore first 10 years
get_cdf(sims, fn = max, times = 11:51)
Run the code above in your browser using DataLab