Learn R Programming

nhppp (version 1.1.1)

rbtpois: Truncated Poisson random samples (basic R)

Description

Sample from a Poisson distribution conditional on the count being in [k_min, k_max], by inversion of the CDF restricted to the truncation region (upper-tail parameterization, accurate when the region is deep in the right tail). k_min = 1, k_max = Inf is the zero-truncated distribution (rztpois()).

Usage

rbtpois(n, lambda, k_min = 1, k_max = Inf)

Value

a vector of counts (all in [k_min, k_max]) of size n

Arguments

n

Integer, number of samples

lambda

Positive number (scalar or vector), the mean of the original (untruncated) Poisson distribution

k_min

Non-negative integer, the minimum count conditioned on

k_max

Positive integer or Inf, the maximum count conditioned on

Examples

Run this code
rbtpois(10, 1, k_min = 3)
rbtpois(10, 1, k_min = 0, k_max = 2)

Run the code above in your browser using DataLab