rtpois {random.cdisc.data}R Documentation

Zero-Truncated Poisson Distribution

Description

[Stable]

This generates random numbers from a zero-truncated Poisson distribution, i.e. from X | X > 0 when X ~ Poisson(lambda). The advantage here is that we guarantee to return exactly n numbers and without using a loop internally. This solution was provided in a post by Peter Dalgaard.

Usage

rtpois(n, lambda)

Arguments

n

(numeric)
Number of random numbers.

lambda

(numeric)
Non-negative mean(s).

Value

The random numbers.

Examples

x <- rpois(1e6, lambda = 5)
x <- x[x > 0]
hist(x)

y <- rtpois(1e6, lambda = 5)
hist(y)

[Package random.cdisc.data version 0.3.15 Index]