
Density function, distribution function, quantile function and random
generation for the Zero-Truncated Binomial distribution with
parameters size
and prob
.
dztbinom(x, size, prob, log = FALSE)
pztbinom(q, size, prob, lower.tail = TRUE, log.p = FALSE)
qztbinom(p, size, prob, lower.tail = TRUE, log.p = FALSE)
rztbinom(n, size, 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.
number of trials (strictly positive integer).
probability of success on each trial. 0 <= prob <= 1
.
logical; if TRUE
, probabilities
logical; if TRUE
(default), probabilities are
dztbinom
gives the probability mass function,
pztbinom
gives the distribution function,
qztbinom
gives the quantile function, and
rztbinom
generates random deviates.
Invalid size
or prob
will result in return value
NaN
, with a warning.
The length of the result is determined by n
for
rztbinom
, and is the maximum of the lengths of the
numerical arguments for the other functions.
The zero-truncated binomial distribution with size
prob
The mean is
In the terminology of Klugman et al. (2012), the zero-truncated
binomial is a member of the
If an element of x
is not integer, the result of
dztbinom
is zero, with a warning.
The quantile is defined as the smallest value
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (2012), Loss Models, From Data to Decisions, Fourth Edition, Wiley.
dbinom
for the binomial distribution.
# NOT RUN {
dztbinom(1:5, size = 5, prob = 0.4)
dbinom(1:5, 5, 0.4)/pbinom(0, 5, 0.4, lower = FALSE) # same
pztbinom(1, 2, prob = 0) # point mass at 1
qztbinom(pztbinom(1:10, 10, 0.6), 10, 0.6)
n <- 8; p <- 0.3
x <- 0:n
title <- paste("ZT Binomial(", n, ", ", p,
") and Binomial(", n, ", ", p,") PDF",
sep = "")
plot(x, dztbinom(x, n, p), type = "h", lwd = 2, ylab = "p(x)",
main = title)
points(x, dbinom(x, n, p), pch = 19, col = "red")
legend("topright", c("ZT binomial probabilities", "Binomial probabilities"),
col = c("black", "red"), lty = c(1, 0), lwd = 2, pch = c(NA, 19))
# }
Run the code above in your browser using DataLab