nhpp.sim.slow: Simulate a non-homogeneous Poisson process.

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/poisson.R

Description

Get the n consecutive event times of a non-homogeneous poisson process.Events are simulated using an homogeneous process with rate, and an event at time t is admitted with probability prob.func(t).

Usage

1
nhpp.sim.slow(rate, num.events, prob.func, num.sims = 1, t0 = 0, prepend.t0 = T)

Arguments

rate

the rate at which events occur in the equivalent homogeneous Poisson process, aka lambda

num.events

number of event times to simulate in each process

prob.func

aka intensity function, function that takes time as sole argument and returns value between 0 and 1

num.sims

number of simulated paths to create

t0

the reference start time of all events

prepend.t0

T to include t0 at the start of the process

Details

This method is called 'thinning' by Lewis & Shedler (1978)

Value

a numeric vector of length num.events if num.sims=1 else, a num.events by num.sims matrix

Note

This item is my original (slower) implementation of NHPP simulation, hence the name. It does not use recursion so the code is easier to understand.

Author(s)

Kristian Brock - Author, Daniel Slade - Contributor

References

Lewis & Shedler, Simulation of Non-Homogeneous Poisson Processes by Thinning, 1978

See Also

nhpp.scenario, hpp.sim

Examples

1
2
3
4
intensity <- function(t) pmin(t/3, 1)
rate <- 10
num.events <- 100
nhpp.sim.slow(rate, num.events, prob.func=intensity)

Example output

  [1]  0.0000000  0.4116549  0.4655081  1.4094099  1.4488457  1.6361921
  [7]  1.6396192  1.7665498  1.8965739  1.9614692  2.5012648  2.6040403
 [13]  2.7749804  2.8038559  2.8941296  2.9089524  2.9847044  3.0030031
 [19]  3.1879452  3.2127571  3.3213756  3.4242147  3.5162812  3.5469986
 [25]  3.7125864  3.9145112  4.0947689  4.1576070  4.2067468  4.2075695
 [31]  4.2532464  4.3224989  4.4261381  4.4505781  4.4520042  4.5602001
 [37]  4.6179936  4.6682253  4.6751265  4.6924072  4.7353545  4.8109343
 [43]  4.8292302  4.8528244  4.9389766  5.1069145  5.1471498  5.1986163
 [49]  5.2906658  5.4312336  5.5938176  5.6090924  5.6120410  5.6787793
 [55]  5.6864556  5.8366333  5.8499927  5.9185221  6.1697647  6.2645798
 [61]  6.2665689  6.3464314  6.4114004  6.4412547  6.4449076  6.6721814
 [67]  6.6742618  6.9923167  7.0232604  7.0808074  7.0867798  7.1376291
 [73]  7.2405845  7.3036863  7.3259406  7.7830517  7.8662522  7.8870632
 [79]  7.9661875  8.0171238  8.0212245  8.1232042  8.2721005  8.7361643
 [85]  8.8268800  9.1334731  9.1440382  9.3562450  9.4573380  9.4975090
 [91]  9.5819067  9.7136790  9.8692218  9.9395992 10.0157435 10.0981424
 [97] 10.4266988 10.4426750 10.4637831 10.5203645 10.6345056

poisson documentation built on May 2, 2019, 6:53 a.m.