Learn R Programming

actuar (version 3.3-4)

ZeroTruncatedBinomial: 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)

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.

Arguments

x

vector of (strictly positive integer) quantiles.

q

vector of quantiles.

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

size

number of trials (strictly positive integer).

prob

probability of success on each trial. 0 <= prob <= 1.

log, log.p

logical; if TRUE, probabilities \(p\) are returned as \(\log(p)\).

lower.tail

logical; if TRUE (default), probabilities are \(P[X \le x]\), otherwise, \(P[X > x]\).

Author

Vincent Goulet vincent.goulet@act.ulaval.ca

Details

The zero-truncated binomial distribution with size \(= n\) and prob \(= p\) has probability mass function $$% p(x) = {n \choose x} \frac{p^x (1 - p)^{n-x}}{1 - (1 - p)^n}$$ for \(x = 1, \ldots, n\) and \(0 < p \le 1\), and \(p(1) = 1\) when \(p = 0\). The cumulative distribution function is $$P(x) = \frac{F(x) - F(0)}{1 - F(0)},$$ where \(F(x)\) is the distribution function of the standard binomial.

The mean is \(np/(1 - (1-p)^n)\) and the variance is \(np[(1-p) - (1-p+np)(1-p)^n]/[1 - (1-p)^n]^2\).

In the terminology of Klugman et al. (2012), the zero-truncated binomial is a member of the \((a, b, 1)\) class of distributions with \(a = -p/(1-p)\) and \(b = (n+1)p/(1-p)\).

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 \(x\) such that \(P(x) \ge p\), where \(P\) is the distribution function.

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

Run this code
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