poisson_process_sim: Simulation of a Poisson process

Description Usage Arguments Details Value Examples

View source: R/poisson_process_simulation.R

Description

Simulates event times from a (one-dimensional, homogeneous) Poisson process of rate λ 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

1
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

1
2
3
4
5
sim1 <- poisson_process_sim(lambda = 2, hours = 24)
plot(sim1)

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

paulnorthrop/stat1004 documentation built on Nov. 17, 2019, 3:49 a.m.