A generalization of the geometric distribution. It is the number of successes in a sequence of i.i.d. Bernoulli trials before a specified number (\(r\)) of failures occurs.

NegativeBinomial(size, p = 0.5)

size | The number of failures (an integer greater than \(0\)) until the experiment is stopped. Denoted \(r\) below. |
---|---|

p | The success probability for a given trial. |

A `NegativeBinomial`

object.

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{p r}{1-p}\)

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

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

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

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

Too nasty, ommited.

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

$$ \frac{(1-p)^r}{(1-pe^t)^r}, t < -\log p $$

Other discrete distributions: `Bernoulli`

,
`Binomial`

, `Categorical`

,
`Geometric`

, `HyperGeometric`

,
`Multinomial`

, `Poisson`

#> Negative Binomial distribution (size = 10, p = 0.3)#> [1] 45 25 27 41 13 11 16 22 12 23#> [1] 0.0001591371#> [1] -8.745745#> [1] 0.001665663#> [1] 27