Generalized Binomial {GenBinomApps} | R Documentation |
The Generalized Binomial Distribution
Description
Density, distribution function, quantile function and random generation for the generalized binomial distribution with parameter vectors size
and prob
.
Usage
dgbinom(x, size, prob, log = FALSE)
pgbinom(q, size, prob, lower.tail = TRUE, log.p = FALSE)
qgbinom(p, size, prob, lower.tail = TRUE, log.p = FALSE)
rgbinom(N, size, prob)
Arguments
x , q |
vector of quantiles. |
p |
vector of probabilities. |
N |
number of observations. |
size |
vector of the number of trials for each type. |
prob |
vector of the success probabilities for each type. |
log , log.p |
logical; if TRUE probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
Details
The generalized binomial distribution with size
=c(n_{1},\dots ,n_{r})
and prob
=c(p_ {1},...,p_{r})
is the sum of r
binomially distributed random variables with different p_{i}
(and, in case, with different n_{i}
):
Z=\sum_{i=1}^{r} Z_{i}
,
Z
~ gbinom
(size
,prob
), with Z_{i}
~ binom(n_{i},p_{i}),\ i=1,\dots ,r
.
Since the sum of Bernoulli distributed random variables is binomially distributed, Z
can be also defined as:
Z=\sum_{i=1}^{r}\sum_{j=1}^{n_{i}}Z_{ij}
, with Z_{ij}
~ binom(1,p_{i}),\ j=1,...,n_{i}
.
The pmf is obtained by an algorithm which is based on the convolution of Bernoulli distributions. See the references below for further information.
The quantile is defined as the smallest value x
such that F(x) \geq p
, where F is the cumulative distribution function.
rgbinom
uses the inversion method (see Devroye, 1986).
Value
dgbinom
gives the pmf, pgbinom
gives the cdf, qgbinom
gives the quantile function and rgbinom
generates random deviates.
Note
If size
contains just one trial number and prob
one success probability, then the generalized binomial distribution results in the binomial distribution.
The generalized binomial distribution described here is also known as Poisson-binomial distribution. See the link below to the package poibin
for further information.
References
D.Kurz, H.Lewitschnig, J.Pilz, Decision-Theoretical Model for Failures which are Tackled by Countermeasures, IEEE Transactions on Reliability, Vol. 63, No. 2, June 2014.
K.J. Klauer, Kriteriumsorientierte Tests, Verlag fuer Psychologie, Hogrefe, 1987, Goettingen, p. 208 ff.
M.Fisz, Wahrscheinlichkeitsrechnung und mathematische Statistik, VEB Deutscher Verlag der Wissenschaften, 1973, p. 164 ff.
L.Devroye, Non-Uniform Random Variate Generation, Springer-Verlag, 1986, p. 85 ff.
See Also
ppoibin
, for another implementation of this distribution.
dbinom
Examples
## n=10 defect devices, divided in 3 failure types n1=2, n2=5, n3=3.
## 3 countermeasures with effectivities p1=0.8, p2=0.7, p3=0.3 are available.
## use dgbinom() to get the probabilities for x=0,...,10 failures solved.
dgbinom(x=c(0:10),size=c(2,5,3),prob=c(0.8,0.7,0.3))
## generation of N=100000 random values
rgbinom(100000,size=c(2,5,3),prob=c(0.8,0.7,0.3))
## n1=100, n2=100, n3=200, p1=0.001, p2=0.005, p3=0.01
dgbinom(c(0:2),size=c(100,100,200),prob=c(0.001,0.005,0.01))
# 0.07343377 0.19260317 0.25173556
pgbinom(2,size=c(100,100,200),prob=c(0.001,0.005,0.01),lower.tail=FALSE)
# 0.4822275