Negative Binomial Distribution

DESCRIPTION:
Functions for the density, cumulative distribution, quantiles and random generation of the Negative Binomial distribution. The distribution models the number of failures before size successes occur in a sequence of Bernoulli trials.

USAGE:
dnbinom(x, size, prob)
pnbinom(q, size, prob)
qnbinom(p, size, prob)
rnbinom(n, size, prob)

REQUIRED ARGUMENTS:
x:
vector of (positive) quantiles. Missing values (NAs) are allowed.
q:
vector of (positive) quantiles. Missing values (NAs) are allowed.
p:
vector of probabilities. Missing values (NAs) are allowed.
n:
sample size.
size:
vector of positive integers; the Negative Binomial represents the number of failures (or tails in coin tossing) before size successes (or heads in coin tossing) are achieved where the probability of a success (or of a head) is prob.
prob:
vector of probabilities of a success. If length(n) is larger than 1, then length(n) random values are returned.

VALUE:
density (dnbinom), probability (pnbinom), quantile (qnbinom), or random sample (rnbinom) for the Negative Binomial distribution with parameters size and prob. The quantile is defined as the smallest value q such that Pr(Negative Binomial random variate <= x) >= p.

SIDE EFFECTS:
The function rbinom causes the creation of the dataset .Random.seed if it does not already exist, otherwise its value is updated.

Elements of q or p that are missing will cause the corresponding elements of the result to be missing.


SEE ALSO:
set.seed , Binomial .

EXAMPLES:
rbinom(20,10,0.5)  # sample of size 20 with mean 10*0.5 = 5