rpoistrunc: Random Values from the Truncated Poisson Distribution

View source: R/truncpois.R

rpoistruncR Documentation

Random Values from the Truncated Poisson Distribution

Description

Generate realisations of a Poisson random variable which are truncated, that is, conditioned to be nonzero, or conditioned to be at least a given number.

Usage

rpoisnonzero(n, lambda, method=c("harding", "transform"), implem=c("R", "C"))
rpoistrunc(n, lambda, minimum = 1, method=c("harding", "transform"), implem=c("R", "C"))

Arguments

n

Number of random values to be generated.

lambda

Mean value of the un-truncated Poisson distribution. A nonnegative number, or vector of nonnegative numbers.

minimum

Minimum permitted value for the random variables. A nonnegative integer, or vector of nonnegative integers.

method

Character string (partially matched) specifying the simulation algorithm to be used. See Details.

implem

Character string specifying whether to use the implementation in interpreted R code (implem="R", the default) or C code (implem="C").

Details

rpoisnonzero generates realisations of the Poisson distribution with mean lambda conditioned on the event that the values are not equal to zero.

rpoistrunc generates realisations of the Poisson distribution with mean lambda conditioned on the event that the values are greater than or equal to minimum. The default minimum=1 is equivalent to generating zero-truncated Poisson random variables using rpoisnonzero. The value minimum=0 is equivalent to generating un-truncated Poisson random variables using rpois.

The arguments lambda and minimum can be vectors of length n, specifying different means for the un-truncated Poisson distribution, and different minimum values, for each of the n random output values.

If method="transform" the simulated values are generated by transforming a uniform random variable using the quantile function of the Poisson distribution. If method="harding" (the default) the simulated values are generated using an algorithm proposed by E.F. Harding which exploits properties of the Poisson point process. The Harding algorithm seems to be faster.

Value

An integer vector of length n.

Author(s)

\adrian

, after ideas of Ted Harding and Peter Dalgaard.

See Also

rpois for Poisson random variables.

recipEnzpois for the reciprocal moment of rpoisnonzero.

Examples

  rpoisnonzero(10, 0.8)

  rpoistrunc(10, 1, 2)

spatstat.random documentation built on Sept. 30, 2024, 9:46 a.m.