ZeroTruncatedBinomial {actuar} | R Documentation |
The Zero-Truncated Binomial Distribution
Description
Density function, distribution function, quantile function and random
generation for the Zero-Truncated Binomial distribution with
parameters size
and prob
.
Usage
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)
Arguments
x |
vector of (strictly positive integer) quantiles. |
q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. If |
size |
number of trials (strictly positive integer). |
prob |
probability of success on each trial. |
log , log.p |
logical; if |
lower.tail |
logical; if |
Details
The zero-truncated binomial distribution with size
and
prob
has probability mass function
for and
, and
when
.
The cumulative distribution function is
where is the distribution function of the standard binomial.
The mean is and the variance is
.
In the terminology of Klugman et al. (2012), the zero-truncated
binomial is a member of the class of
distributions with
and
.
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 such that
, where
is the distribution function.
Value
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.
Note
Functions {d,p,q}ztbinom
use {d,p,q}binom
for all
but the trivial input values and .
rztbinom
uses the simple inversion algorithm suggested by
Peter Dalgaard on the r-help mailing list on 1 May 2005
(https://stat.ethz.ch/pipermail/r-help/2005-May/070680.html).
Author(s)
Vincent Goulet vincent.goulet@act.ulaval.ca
References
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (2012), Loss Models, From Data to Decisions, Fourth Edition, Wiley.
See Also
dbinom
for the binomial distribution.
Examples
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))