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.