Density function, distribution function, quantile function and random
generation for the Logarithmic (or log-series) distribution with parameter
prob
.
dlogarithmic(x, prob, log = FALSE)
plogarithmic(q, prob, lower.tail = TRUE, log.p = FALSE)
qlogarithmic(p, prob, lower.tail = TRUE, log.p = FALSE)
rlogarithmic(n, prob)
vector of (strictly positive integer) quantiles.
vector of quantiles.
vector of probabilities.
number of observations. If length(n) > 1
, the length is
taken to be the number required.
parameter. 0 <= prob < 1
.
logical; if TRUE
, probabilities
logical; if TRUE
(default), probabilities are
dlogarithmic
gives the probability mass function,
plogarithmic
gives the distribution function,
qlogarithmic
gives the quantile function, and
rlogarithmic
generates random deviates.
Invalid prob
will result in return value NaN
, with a warning.
The length of the result is determined by n
for
rlogarithmic
, and is the maximum of the lengths of the
numerical arguments for the other functions.
The logarithmic (or log-series) distribution with parameter
prob
The logarithmic distribution is the limiting case of the
zero-truncated negative binomial distribution with size
parameter equal to prob
generally corresponds to the probability of failure
of the zero-truncated negative binomial.
If an element of x
is not integer, the result of
dlogarithmic
is zero, with a warning.
The quantile is defined as the smallest value
Johnson, N. L., Kemp, A. W. and Kotz, S. (2005), Univariate Discrete Distributions, Third Edition, Wiley.
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (2012), Loss Models, From Data to Decisions, Fourth Edition, Wiley.
Kemp, A. W. (1981), “Efficient Generation of Logarithmically Distributed Pseudo-Random Variables”, Journal of the Royal Statistical Society, Series C, vol. 30, p. 249-253. http://www.jstor.org/stable/2346348
Devroye, L. (1986), Non-Uniform Random Variate Generation, Springer-Verlag. http://luc.devroye.org/rnbookindex.html
dztnbinom
for the zero-truncated negative binomial
distribution.
# NOT RUN {
## Table 1 of Kemp (1981) [also found in Johnson et al. (2005), chapter 7]
p <- c(0.1, 0.3, 0.5, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99, 0.995, 0.999, 0.9999)
round(rbind(dlogarithmic(1, p),
dlogarithmic(2, p),
plogarithmic(9, p, lower.tail = FALSE),
-p/((1 - p) * log(1 - p))), 2)
qlogarithmic(plogarithmic(1:10, 0.9), 0.9)
x <- rlogarithmic(1000, 0.8)
y <- sort(unique(x))
plot(y, table(x)/length(x), type = "h", lwd = 2,
pch = 19, col = "black", xlab = "x", ylab = "p(x)",
main = "Empirical vs theoretical probabilities")
points(y, dlogarithmic(y, prob = 0.8),
pch = 19, col = "red")
legend("topright", c("empirical", "theoretical"),
lty = c(1, NA), pch = c(NA, 19), col = c("black", "red"))
# }
Run the code above in your browser using DataLab