popsim {IBMPopSim} | R Documentation |
This function simulates the random evolution of an IBM.
popsim(
model,
population,
events_bounds,
parameters = NULL,
age_max = Inf,
time,
multithreading = FALSE,
num_threads = NULL,
clean_step = NULL,
clean_ratio = 0.1,
seed = NULL
)
model |
Model resulting from a call to the function |
population |
Data frame representing the initial population. |
events_bounds |
Named vector of events bounds, with names corresponding to events names. |
parameters |
List of model parameters. |
age_max |
Maximum age of individuals in the population ( |
time |
Final time (Numeric). If |
multithreading |
Logical for multithread activation, |
num_threads |
(Optional) Number of threads used for multithreading. Set by default to the number of concurrent threads supported by the available hardware implementation. |
clean_step |
(Optional) Optional parameter for improving simulation time. Time step for removing dead (or exited) individuals from the population. By default, equal to age_max. |
clean_ratio |
(Optional) Optional parameter for improving simulation time. 0.1 by default. |
seed |
(Optional) Random generator seed, random by default. |
popsim returns a list of composed of
Simulation inputs (initial population, parameters value, multithreading...)
Simulation logs (algorithm duration, accepted/rejected events...).
If time
is of length 1, population is a data frame composed of all individuals who lived in the population of [0,time]
. If time
is a vector, population
is a list of population data frames.
init_size <- 100000
pop <- data.frame(birth = rep(0, init_size), death = NA)
birth = mk_event_poisson(type = 'birth', intensity = 'lambda')
death = mk_event_poisson(type = 'death', intensity = 'mu')
params = list('lambda' = 100, 'mu' = 100)
birth_death <- mk_model(events = list(birth, death),
parameters = params)
sim_out <- popsim(model = birth_death,
population = pop,
events_bounds = c('birth' = params$lambda, 'death' = params$mu),
parameters = params,
time = 10)