Skip to contents

Simulates population growth over multiple time steps using a stochastic logistic growth model. This model incorporates both stochastic elements and a carrying capacity to describe population dynamics.

Usage

sim_stochastic_logistic(n0, lambda, mu, K, steps, delta_t)

Arguments

n0

Numeric value indicating the initial population size. Must be a non-negative integer.

lambda

Numeric vector of birth rates. This can be a single value (constant birth rate) or a vector of length steps specifying the birth rate at each time step.

mu

Numeric vector of death rates. This can be a single value (constant death rate) or a vector of length steps specifying the death rate at each time step.

K

Numeric value representing the carrying capacity of the environment. Must be a non-negative integer.

steps

Integer value specifying the number of time steps to simulate. Must be a non-negative integer.

delta_t

Numeric vector of time step sizes. This can be a single value (constant time step) or a vector of length steps. If a single value is provided, it is replicated for each time step.

Value

A tibble with columns:

  • time: The cumulative time at each step.

  • count: The population size at each time step.

  • group: A factor indicating the group of contiguous intervals where the birth and death rates are constant.