NegativeBinomial {distributions3} | R Documentation |

A generalization of the geometric distribution. It is the number
of failures in a sequence of i.i.d. Bernoulli trials before
a specified target number (`r`

) of successes occurs.

```
NegativeBinomial(size, p = 0.5, mu = size)
```

`size` |
The target number of successes (greater than |

`p` |
The success probability for a given trial. |

`mu` |
Alternative parameterization via the non-negative mean
of the distribution (instead of the probability |

We recommend reading this documentation on https://alexpghayes.github.io/distributions3/, where the math will render with additional detail and much greater clarity.

In the following, let `X`

be a negative binomial random variable with
success probability `p`

= `p`

.

**Support**: `\{0, 1, 2, 3, ...\}`

**Mean**: `\frac{(1 - p) r}{p} = \mu`

**Variance**: `\frac{(1 - p) r}{p^2}`

**Probability mass function (p.m.f.)**:

```
f(k) = {k + r - 1 \choose k} \cdot p^r (1-p)^k
```

**Cumulative distribution function (c.d.f.)**:

Omitted for now.

**Moment generating function (m.g.f.)**:

```
\left(\frac{p}{1 - (1 -p) e^t}\right)^r, t < -\log (1-p)
```

**Alternative parameterization**: Sometimes, especially when used in
regression models, the negative binomial distribution is parameterized
by its mean `\mu`

(as listed above) plus the size parameter `r`

.
This implies a success probability of `p = r/(r + \mu)`

. This can
also be seen as a generalization of the Poisson distribution where the
assumption of equidispersion (i.e., variance equal to mean) is relaxed.
The negative binomial distribution is overdispersed (i.e., variance greater than mean)
and its variance can also be written as `\mu + 1/r \mu^2`

. The Poisson
distribution is then obtained as `r`

goes to infinity. Note that in this
view it is natural to also allow for non-integer `r`

parameters.
The factorials in the equations above are then expressed in terms of the
gamma function.

A `NegativeBinomial`

object.

Other discrete distributions:
`Bernoulli()`

,
`Binomial()`

,
`Categorical()`

,
`Geometric()`

,
`HurdleNegativeBinomial()`

,
`HurdlePoisson()`

,
`HyperGeometric()`

,
`Multinomial()`

,
`Poisson()`

,
`ZINegativeBinomial()`

,
`ZIPoisson()`

,
`ZTNegativeBinomial()`

,
`ZTPoisson()`

```
set.seed(27)
X <- NegativeBinomial(size = 5, p = 0.1)
X
random(X, 10)
pdf(X, 50)
log_pdf(X, 50)
cdf(X, 50)
quantile(X, 0.7)
## alternative parameterization of X
Y <- NegativeBinomial(mu = 45, size = 5)
Y
cdf(Y, 50)
quantile(Y, 0.7)
```

[Package *distributions3* version 0.2.1 Index]