
Vectorized simulation from a non homogeneous Poisson Point Process (NHPPP) from (t_min, t_max) given the cumulative intensity function and its inverse
Source:R/vdraw_cumulative_intensity.R
vdraw_cumulative_intensity.RdSample NHPPP times using the cumulative intensity function and its inverse.
Usage
vdraw_cumulative_intensity(
Lambda,
Lambda_inv,
t_min,
t_max,
Lambda_args = NULL,
Lambda_inv_args = NULL,
tol = 10^-6,
atmost1 = FALSE,
report_first_K = NULL,
report_last_K = NULL,
atleast1 = FALSE,
generate_at_least_K = NULL,
generate_at_most_K = NULL,
output = c("matrix", "long")
)Arguments
- Lambda
(function, double vector) an increasing function which is the integrated rate of the NHPPP. It should take a vectorized argument t for times and an optional arguments list.
- Lambda_inv
(function, double vector) the inverse of
Lambda(), also in vectorized form It should take a vectorized argument z and an optional arguments list.- t_min
(scalar | vector | column matrix) the lower bound of the interval for each sampled point process The length of this argument is the number of point processes that should be drawn.
- t_max
(scalar | vector | column matrix) the upper bound of the interval for each sampled point process The length of this argument is the number of point processes that should be drawn.
- Lambda_args
(list) arguments for BOTH
LambdaandLambda_inv, with up to two elements:shared(named list of row-invariant arguments) androw_args(data.frame or data.table with one row per point process). When the structured container is used it is passed as the second positional argument of both functions; the name of the second formal is up to you. A flat list keeps the released behavior (Lambda(t, Lambda_args = ...), named) with a deprecation warning.- Lambda_inv_args
(list) deprecated; pass one structured
Lambda_argscontainer used by bothLambdaandLambda_inv.- tol
the tolerange for the calulations.
- atmost1
boolean, report at most 1 event time per sampled point process (alias for
report_first_K = 1).- report_first_K
NULLor a positive integer: report only the earliest K event times (reporting truncation).- report_last_K
NULLor a positive integer: report only the latest K event times (reporting truncation).- atleast1
boolean, condition on at least 1 event (alias for
generate_at_least_K = 1).- generate_at_least_K
NULLor a positive integer: condition the sampled process on at least K events in(t_min, t_max).- generate_at_most_K
NULLor a positive integer: condition the sampled process on at most K events in(t_min, t_max). May be combined withgenerate_at_least_K(K1 <= K2); equal bounds condition on exactly K events. Any generation bound switches the sampler from sequential inversion to the order-statistics construction on theLambdascale with a doubly-truncated Poisson number of events.- output
(string)
"matrix"(default) returns the NA-padded event matrix, one row per point process."long"returns the long event formatlist(id, time, n_draws)with one entry per event:idis the 1-based point-process index (ascending; times ascending withinid); a point process with no events contributes no entries, andn_drawsdistinguishes "no events" from "not sampled". On the conditioned (order-statistics) path the long format is built with no dense intermediate, andLambda_invis called on the event VECTOR with the container'srow_argssubset to one row per event (aligned byid); the unconditioned path converts its dense walk at the end.
Value
a matrix of event times with one row per sampled point process,
or the long event format if output = "long".
Examples
Z <- vdraw_cumulative_intensity(
Lambda = function(t) t^1.5,
Lambda_inv = function(z) z^(1 / 1.5),
t_min = 0,
t_max = rep(2, 10)
)
# arguments in the structured container; conditioned on exactly two events
Z <- vdraw_cumulative_intensity(
Lambda = function(t, a) t^a$shared$p,
Lambda_inv = function(z, a) z^(1 / a$shared$p),
t_min = 0,
t_max = rep(2, 10),
Lambda_args = list(shared = list(p = 1.5)),
generate_at_least_K = 2, generate_at_most_K = 2
)