R/ppp_exactly_n.R

Defines functions ppp_exactly_n

Documented in ppp_exactly_n

#' Simulate exactly `n` points from a homogeneous Poisson Point Process over (t_min, t_max]
#'
#' @param n (int) the number of points to be simulated
#' @param t_min (double) the lower bound of the time interval
#' @param t_max (double) the upper bound of the time interval
#'
#' @return a vector of event times of size `n`
#' @export
#'
#' @examples
#' x <- ppp_exactly_n(n = 10, t_min = 0, t_max = 10)
ppp_exactly_n <- function(n, t_min, t_max) {
  U <- stats::runif(n = n, min = t_min, max = t_max)
  if (n == 1) {
    return(U)
  }
  return(U[order(U, method = "shell")])
}

Try the nhppp package in your browser

Any scripts or data that you put into this service are public.

nhppp documentation built on Oct. 30, 2024, 9:28 a.m.