Learn R Programming

extraDistr (version 1.8.1)

TruncPoisson: Truncated Poisson distribution

Description

Density, distribution function, quantile function and random generation for the truncated Poisson distribution.

Usage

dtpois(x, lambda, s = 0, log = FALSE)
ptpois(q, lambda, s = 0, lower.tail = TRUE, log.p = FALSE)
qtpois(p, lambda, s = 0, lower.tail = TRUE, log.p = FALSE)
rtpois(n, lambda, s = 0)

Arguments

x, q
vector of quantiles.
lambda
vector of (non-negative) means.
s
truncation point (non-negtive); s=0 (default) for zero-truncated Poisson, otherwise values greater than s are truncated.
log, log.p
logical; if TRUE, probabilities p are given as log(p).
lower.tail
logical; if TRUE (default), probabilities are $P[X \le x]$ otherwise, $P[X > x]$.
p
vector of probabilities.
n
number of observations. If length(n) > 1, the length is taken to be the number required.

References

Plackett, R.L. (1953). The truncated Poisson distribution. Biometrics, 9(4), 485-488.

Singh, J. (1978). A characterization of positive Poisson distribution and its statistical application. SIAM Journal on Applied Mathematics, 34(3), 545-548.

Dalgaard, P. (May 1, 2005). [R] simulate zero-truncated Poisson distribution. R-help mailing list. https://stat.ethz.ch/pipermail/r-help/2005-May/070680.html

Examples

Run this code

x <- rtpois(1e5, 14, 16)
xx <- seq(-1, 20)
plot(prop.table(table(x)))
lines(xx, dtpois(xx, 14, 16), col = "red")
hist(ptpois(x, 14, 16))
plot(ecdf(x))
lines(xx, ptpois(xx, 14, 16), col = "red", lwd = 2)
uu <- seq(0, 1, by = 0.001)
lines(qtpois(uu, 14, 16), uu, col = "blue")

# Zero-truncated Poisson

x <- rtpois(1e5, 5, 0)
xx <- seq(-1, 50)
plot(prop.table(table(x)))
lines(xx, dtpois(xx, 5, 0), col = "red")
hist(ptpois(x, 5, 0))
plot(ecdf(x))
lines(xx, ptpois(xx, 5, 0), col = "red", lwd = 2)
lines(qtpois(uu, 5, 0), uu, col = "blue")

Run the code above in your browser using DataLab