genpois0UC.RdDensity, distribution function, quantile function and random generation for the original parameterization of the generalized Poisson distribution.
dgenpois0(x, theta, lambda = 0, log = FALSE)
pgenpois0(q, theta, lambda = 0, lower.tail = TRUE)
qgenpois0(p, theta, lambda = 0)
rgenpois0(n, theta, lambda = 0, algorithm = c("qgenpois0",
"inv", "bup","chdn", "napp", "bran"))Vector of quantiles.
Vector of probabilities.
Similar to runif.
See genpoisson0.
The default value of lambda corresponds to an
ordinary Poisson distribution.
Nonnegative values
of lambda are currently required.
Similar to Poisson.
Character.
Six choices are available, standing for the
qgenpois0,
inversion, build-up, chop-down,
normal approximation and branching methods.
The first one is the default and
calls qgenpois0 with runif as
its first argument.
The value inputted may be abbreviated, e.g., alg = "n".
The last 5 algorithms are a direct implementation of Demirtas (2017)
and the relative performance of the algorithms are
described there—however, the vectorization here may render
the comments on relative speed as no longer holding.
dgenpois0 gives the density,
pgenpois0 gives the distribution function,
qgenpois0 gives the quantile function, and
rgenpois generates random deviates.
For some of these functions such as
dgenpois0 and pgenpois0
the value NaN is returned for elements not satisfying
the parameter restrictions, e.g., if \(\lambda > 1\).
For some of these functions such as
rgenpois0
the input must not contain NAs or NaNs, etc. since
the implemented algorithms are fragile.
Most of the background to these functions are given
in genpoisson0.
Some warnings relevant to this distribution are given there.
The complicated range of the
parameter lambda when negative is no longer
supported because the distribution is not normalized.
For other GPD variants see Genpois1.
For rgentpois0():
(1). "inv", "bup" and "chdn" appear similar and
seem to work okay.
(2). "napp" works only when theta is large, away from 0.
It suffers from 0-inflation.
(3). "bran" has a relatively heavy RHS tail and
requires positive lambda.
More details can be found in
Famoye (1997) and
Demirtas (2017).
The function dgenpois0
uses lfactorial, which
equals Inf when x is approximately 1e306
on many machines.
So the density is returned as 0 in very extreme cases;
see .Machine.
Demirtas, H. (2017). On accurate and precise generation of generalized Poisson variates. Communications in Statistics—Simulation and Computation, 46, 489–499.
Famoye, F. (1997). Generalized Poisson random variate generation. Amer. J. Mathematical and Management Sciences, 17, 219–237.
These have not been tested thoroughly.
For pgentpois0() mapply is called
with 0:q as input, hence will be very slow and
memory-hungry for large values of q.
Likewise qgentpois0() and rgentpois0()
may suffer from the same limitations.
sum(dgenpois0(0:1000, theta = 2, lambda = 0.5))
#> [1] 1
if (FALSE) theta <- 2; lambda <- 0.2; y <- 0:10
proby <- dgenpois0(y, theta = theta, lambda = lambda, log = FALSE)
#> Error: object 'theta' not found
plot(y, proby, type = "h", col = "blue", lwd = 2, ylab = "Pr(Y=y)",
main = paste0("Y ~ GP-0(theta=", theta, ", lambda=",
lambda, ")"), las = 1, ylim = c(0, 0.3),
sub = "Orange is the Poisson probability function")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'y' in selecting a method for function 'plot': object 'proby' not found
lines(y + 0.1, dpois(y, theta), type = "h", lwd = 2, col = "orange") # \dontrun{}
#> Error: object 'theta' not found