Learn R Programming

nhppp (version 1.1.1)

vdraw_cumulative_intensity: Vectorized simulation from a non homogeneous Poisson Point Process (NHPPP) from (t_min, t_max) given the cumulative intensity function and its inverse

Description

Sample 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")
)

Value

a matrix of event times with one row per sampled point process, or the long event format if output = "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 Lambda and Lambda_inv, with up to two elements: shared (named list of row-invariant arguments) and row_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_args container used by both Lambda and Lambda_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

NULL or a positive integer: report only the earliest K event times (reporting truncation).

report_last_K

NULL or 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

NULL or a positive integer: condition the sampled process on at least K events in (t_min, t_max).

generate_at_most_K

NULL or a positive integer: condition the sampled process on at most K events in (t_min, t_max). May be combined with generate_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 the Lambda scale 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 format list(id, time, n_draws) with one entry per event: id is the 1-based point-process index (ascending; times ascending within id); a point process with no events contributes no entries, and n_draws distinguishes "no events" from "not sampled". On the conditioned (order-statistics) path the long format is built with no dense intermediate, and Lambda_inv is called on the event VECTOR with the container's row_args subset to one row per event (aligned by id); the unconditioned path converts its dense walk at the end.

Examples

Run this code
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
)

Run the code above in your browser using DataLab