Skip to contents

This function simulates a timeseries for the average number of occurrences of a species using a random walk over time.

Usage

simulate_random_walk(
  initial_average_occurrences = 50,
  n_time_points = 10,
  sd_step = 0.05,
  seed = NA
)

Arguments

initial_average_occurrences

A positive numeric value indicating the average number of occurrences to be simulated at the first time point.

n_time_points

A positive integer specifying the number of time points to simulate.

sd_step

A positive numeric value indicating the standard deviation of the random steps.

seed

A positive numeric value setting the seed for random number generation to ensure reproducibility. If NA (default), then set.seed() is not called at all. If not NA, then the random number generator state is reset (to the state before calling this function) upon exiting this function.

Value

A vector of integers of length n_time_points with the average number of occurrences.

Examples

simulate_random_walk(
  initial_average_occurrences = 50,
  n_time_points = 10,
  sd_step = 1,
  seed = 123
)
#>  [1] 50.00000 49.43952 49.20935 50.76806 50.83856 50.96785 52.68292 53.14383
#>  [9] 51.87877 51.19192