Learn R Programming

Distributacalcul (version 0.2.2)

E_negbinom: Expected value of the negative binomial distribution

Description

Expected value of the negative binomial distribution with parameters \(r\) (number of successful trials) and \(p\) (probability of success).

Usage

E_negbinom(
  size,
  prob = (1/(1 + beta)),
  beta = ((1 - prob)/prob),
  nb_tries = FALSE
)

Arguments

size

Number of successful trials.

prob

Probability of success.

beta

Alternative parameterization of the negative binomial distribution where beta = (1 - p) / p.

nb_tries

logical; if FALSE (default) number of trials until the rth success, otherwise, number of failures until the rth success.

Value

Function :

Invalid parameter values will return an error detailing which parameter is problematic.

Details

When \(k\) is the number of failures until the \(r\)th success, with a probability \(p\) of a success, the negative binomial has density: $$\left(\frac{r + k - 1}{k}\right) (p)^{r} (1 - p)^{k}$$ for \(k \in \{0, 1, \dots \}\)

When \(k\) is the number of trials until the \(r\)th success, with a probability \(p\) of a success, the negative binomial has density: $$\left(\frac{k - 1}{r - 1}\right) (p)^{r} (1 - p)^{k - r}$$ for \(k \in \{r, r + 1, r + 2, \dots \}\)

The alternative parameterization of the negative binomial with parameter \(\beta\), and \(k\) being the number of trials, has density: $$\frac{\Gamma(r + k)}{\Gamma(r) k!} \left(\frac{1}{1 + \beta}\right)^{r}% \left(\frac{\beta}{1 + \beta}\right)^{k - r}$$ for \(k \in \{0, 1, \dots \}\)

See Also

Other Negative Binomial Distribution: MGF_negbinom(), PGF_negbinom(), V_negbinom()

Examples

Run this code
# NOT RUN {
# Where k is the number of trials for a rth success
E_negbinom(size = 2, prob = .4)

# Where k is the number of failures before a rth success
E_negbinom(size = 2, prob = .4, nb_tries = TRUE)

# With alternative parameterization where k is the number of trials
E_negbinom(size = 2, beta = 1.5)

# }

Run the code above in your browser using DataLab