Gentpois {VGAM} | R Documentation |
Density, distribution function, and random generation for the generally-truncated Poisson distribution.
dgentpois(x, lambda, truncate = 0, max.support = Inf, log = FALSE) pgentpois(q, lambda, truncate = 0, max.support = Inf) rgentpois(n, lambda, truncate = 0, max.support = Inf, maxits = 10000)
x, q |
vector of quantiles. |
n |
number of observations.
Fed into |
lambda |
vector of positive means (of an ordinary Poisson distribution). Short vectors are recycled. |
truncate |
vector of nonnegative integers; the truncated values.
Must have unique values only.
A |
max.support |
numeric; the maximum support value so that any value larger
has been truncated.
This argument is necessary because
|
log |
logical; see |
maxits |
Maximum number of iterations; used to avoid an infinite loop.
If exceeded, random variates with |
The generally-truncated Poisson distribution is a Poisson distribution with the probability of certain (truncated) values being zero. The other probabilities are scaled up to add to unity.
dgentpois
gives the density,
pgentpois
gives the distribution function,
rgentpois
generates random deviates.
The function can run slowly for certain combinations
of lambda
and truncate
, e.g.,
rgentpois(100, 1, trunc = 0:5)
.
Failure to obtain random variates will result in some
NA
values instead.
T. W. Yee and Theodora Jin.
gentpoisson
,
Genapois
,
Genipois
,
dpospois
,
rpois
.
lambda <- 2; y <- rgentpois(n = 1000, lambda, truncate = 3:5) table(y) tvec <- 2:4 # Truncate these values (ii <- dgentpois(0:7, lambda, truncate = tvec)) table(rgentpois(100, lambda, truncate = tvec)) ## Not run: x <- 0:7 barplot(rbind(dgentpois(x, lambda, truncate = tvec), dpois(x, lambda)), beside = TRUE, col = c("blue", "orange"), main = paste("Gen-truncated Pois(lambda = ", lambda, ", ", "truncate = c(", paste(tvec, collapse = ","), ")) vs", " Pois(", lambda, ")", sep = ""), sub = "Generally-truncated Poisson is blue; Poisson is orange", names.arg = as.character(x), las = 1, lwd = 2) ## End(Not run)