poisson_process_sim: Simulation of a Poisson process

View source: R/poisson_process_simulation.R

poisson_process_simR Documentation

Simulation of a Poisson process

Description

Simulates event times from a (one-dimensional, homogeneous) Poisson process of rate \lambda per hour. The user has the options to simulate events over a fixed time period of hours hours or to simulate a fixed number n_events of events.

Usage

poisson_process_sim(lambda = 1, hours = 24, n_events = NULL)

Arguments

lambda

A positive numeric scalar. The rate of the Poisson process.

hours

A positive integer scalar. The number of hours for which to simulate a Poisson process of rate \lambda events per hour.

n_events

A positive integer scalar. The number of events to simulate.

Details

If n_events is supplied then exactly n_events are simulated and hours has no effect. If n_events is not supplied then events are simulated over the time interval (0, hours). If no events occur in (0, hours) then the value -1 is returned.

Value

A numeric vector containing the (ordered, smallest to largest) times at which the events occur. The returned object has class "poisson_process".

Examples

sim1 <- poisson_process_sim(lambda = 2, hours = 24)
plot(sim1)

sim2 <- poisson_process_sim(lambda = 2, n_events = 50)
plot(sim2)

paulnorthrop/stat0002 documentation built on Oct. 10, 2024, 1:27 p.m.