rpoistrunc: Truncated Poisson Distribution

View source: R/truncpois.R

rpoistruncR Documentation

Truncated Poisson Distribution

Description

Generate random realisations, or calculate probability distribution or quantiles, of a Poisson random variable which is conditioned to be nonzero, or conditioned to be at least a given number.

Usage

dpoisnonzero(x, lambda, log=FALSE)
ppoisnonzero(q, lambda, lower.tail=TRUE, log.p=FALSE)
qpoisnonzero(p, lambda, lower.tail=TRUE, log.p=FALSE)
rpoisnonzero(n, lambda, method=c("harding", "transform"), implem=c("R", "C"))

dpoistrunc(x, lambda, minimum=1, log=FALSE)
ppoistrunc(q, lambda, minimum=1, lower.tail=TRUE, log.p=FALSE)
qpoistrunc(p, lambda, minimum=1, lower.tail=TRUE, log.p=FALSE)
rpoistrunc(n, lambda, minimum=1, method=c("harding", "transform"), implem=c("R", "C"))

Arguments

x

Vector of quantiles.

q

Vector of quantiles.

p

Vector of probabilities.

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.

lower.tail

Logical value. If TRUE (the default), probabilities are P[X <= x]; otherwise probabilities are P[X > x].

log, log.p

Logical value. If TRUE, probabilities are given as the natural logarithm \log(p).

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. The functions dpoisnonzero, ppoisnonzero, qpoisnonzero calculate the probability mass function, cumulative distribution function, and quantile function, respectively.

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 functions dpoistrunc, ppoistrunc, qpoistrunc calculate the probability mass function, cumulative distribution function, and quantile function, respectively.

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.

For the random generators, 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

Numerical vector.

Author(s)

\adrian

, after ideas of Ted Harding and Peter Dalgaard.

References

E.F. Harding (2005) Email to R-help email group, 01 May 2005.

P. Dalgaard (2005) Email to R-help email group, 01 May 2005.

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 May 24, 2026, 9:07 a.m.