Density, distribution function, quantile function and 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 rgenpois0
the input must not contain NA
s or NaN
s, etc. since
the implemented algorithms are fragile.
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.
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
.
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.
# NOT RUN {
sum(dgenpois0(0:1000, theta = 2, lambda = 0.5))
# }
# NOT RUN {
theta <- 2; lambda <- 0.2; y <- 0:10
proby <- dgenpois0(y, theta = theta, lambda = lambda, log = FALSE)
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")
lines(y + 0.1, dpois(y, theta), type = "h", lwd = 2, col = "orange")
# }
Run the code above in your browser using DataLab