Probability function, distribution function, quantile function and random generation for the Gamma Count distribution.

dgcnt(x, lambda, alpha, log = FALSE, offset = 1)

pgcnt(x, lambda, alpha = 1, lower.tail = TRUE, log = FALSE)

qgcnt(p, lambda, alpha = 1)

rgcnt(n, lambda, alpha = 1)

Arguments

x

Positive interger value.

lambda

A numeric vector with values for the location parameter of the Gamma Count distribution.

alpha

A numeric vector with values for the dispersion parameter of the Gamma Count distribution.

log

A logical value. If TRUE, probabilities p are given as log(p).

offset

A numeric vector with the correponding space size where the counts are observed.

lower.tail

A logical value. If TRUE (default), probabilities are \(\Pr(X \leq x)\) otherwise, \(\Pr(X > x)\).

p

A vector of probabilities.

n

An integer vector of length one that is the amount of random numbers to be generated.

Value

dgcnt gives the probability \(\Pr(X = x)\), pgcnt gives the cummulated probability \(\Pr(X \leq x)\) or its complement, qgcnt gives the quantiles and rgcnt generates random values.

Details

The function dgcnt() is implemented in R. The probability function of the Gamma Count is based on the difference of cumulated probabilities of the Gamma density function. These differences are numerically non distinguishable of zero at the tails, so the logarithm of the probabilities is -Inf. We decide replace -Inf by -744, that is the logarithm of the smallest value.

BBBB

The qgcnt() is implemented in C++ in two versions. The first is implemented for the idd case that is when both lambda and alpha are vectors of length one. In this case, the vector of probabilities p is ordered for the quantile search in the ascending direction. At the end, the values are restored to the original order. The other version deals with the non idd case by recursive calls of the function at each vector point. For simulation studies is desirable use the idd version because it is faster.

The rgcnt() is implemented in C++ in two versions. The first is implemented for the idd case that is when both lambda and alpha are vectors of length one. In this case, a vector of n uniform random numbers is ordered for the quantile search in the ascending direction. At the end, the values are randomized in the vector. The other version deals with the non idd case by recursive calls of the function at each vector point. For simulation studies is desirable use the idd version because it is faster.

Examples

dgcnt(5, 5, 1)
#> [1] 0.1754674
dpois(5, 5, 1)
#> [1] -1.740302
qgcnt(runif(5), 10, 1)
#> [1] 9 12 6 7 8
qpois(runif(5), 10)
#> [1] 7 11 13 15 10
x <- rgcnt(1000, 10, 1) plot(ecdf(x))
curve(ppois(x, 10), add = TRUE, type = "s", col = 2)