Lably
Skip to content

Negative binomial distribution

Probability distribution

  • 20 min read
  • 6 chapters

Related on Lably

Through Statistics, Probability distribution and Bernoulli trial

An alternative formulation is to model the number of total trials (instead of the number of failures). In fact, for a specified (non-random) number of successes (r), the number of failures (n − r) is random because the number of total trials (n) is random. For example, we could use the negative binomial distribution to model the number of days n (random) a certain machine works (specified by r) before it breaks down.

The negative binomial distribution has a variance μ/p, with the distribution becoming identical to Poisson in the limit p→1 for a given mean μ (i.e. when the failures are increasingly rare). Here p∈[0,1] is the success probability of each Bernoulli trial. This can make the distribution a useful overdispersed alternative to the Poisson distribution, for example for a robust modification of Poisson regression. In epidemiology, it has been used to model disease transmission for infectious diseases where the likely number of onward infections may vary considerably from individual to individual and from setting to setting. More generally, it may be appropriate where events have positively correlated occurrences causing a larger variance than if the occurrences were independent, due to a positive covariance term.

The term "negative binomial" is likely due to the fact that a certain binomial coefficient that appears in the formula for the probability mass function of the distribution can be written more simply with negative numbers.

Definitions

Imagine a sequence of independent Bernoulli trials: each trial has two potential outcomes called "success" and "failure." In each trial the probability of success is p and of failure is 1−p. We observe this sequence until a predefined number r of successes occurs. Then the random number of observed failures, X, follows the negative binomial distribution: X∼NB⁡(r,p)

Probability mass function

The probability mass function of the negative binomial distribution is f(k;r,p)≡Pr(X=k)=(k+r−1k)(1−p)kpr where r is the number of successes, X = k is the number of failures before the r-th success, and p is the probability of success on each trial.

Here, the quantity in parentheses is the binomial coefficient, and is equal to (k+r−1k)=(k+r−1)!(r−1)!k!=(k+r−1)(k+r−2)⋯(r)k!=Γ(k+r)k!Γ(r)=((rk)). Note that Γ(r) is the Gamma function, and ((rk)) is the multiset coefficient.

There are k failures chosen from k + r − 1 trials rather than k + r because the last of the k + r trials is by definition a success.

This quantity can alternatively be written in the following manner, explaining the name "negative binomial":

(k+r−1)⋯(r)k!=(−1)k(−r)(−r−1)(−r−2)⋯(−r−(k−1))⏞k factorsk!=(−1)k(−r−k).

Note that by the last expression and the binomial series, for every 0 ≤ p < 1 and q=1−p,

p−r=(1−q)−r=∑k=0∞(−r−k)(−q)k=∑k=0∞(k+r−1k)qk

hence the terms of the probability mass function indeed add up to one as below. ∑k=0∞(k+r−1k)(1−p)kpr=p−rpr=1

To understand the above definition of the probability mass function, note that the probability for every specific sequence of r successes and k failures is pr(1 − p)k, because the outcomes of the k + r trials are supposed to happen independently. Since the r-th success always comes last, it remains to choose the k trials with failures out of the remaining k + r − 1 trials. The above binomial coefficient, due to its combinatorial interpretation, gives precisely the number of all these sequences of length k + r − 1.

An alternate interpretation of the probability mass function's binomial coefficient arises when considering the equivalent multiset coefficient ((rk)). A sequence of trials ending in r successes can be represented by a tuple of r non-negative integers, where each integer represents the number of failures seen before the next success. Then by applying stars and bars, it can be seen that the number of such tuples that sum to k (and hence represent k total failures and r total successes) is given by ((rk)).

Cumulative distribution function

The cumulative distribution function can be expressed in terms of the regularized incomplete beta function: F(k;r,p)≡Pr(X≤k)=Ip(r,k+1). for non-negative integer k. This formula is using the same parameterization as in the article's table, with r the number of successes, and p=r/(r+μ) with μ the mean.

It can also be expressed in terms of the cumulative distribution function of the binomial distribution: F(k;r,p)=Fbinomial(k;n=k+r,1−p).

Alternative formulations

Some sources may define the negative binomial distribution slightly differently from the primary one here. The most common variations are where the random variable X is counting different things. These variations can be seen in the table here:

Each of the four definitions of the negative binomial distribution can be expressed in slightly different but equivalent ways. The first alternative formulation is simply an equivalent form of the binomial coefficient, that is: (ab)=(aa−b)for 0≤b≤a. The second alternate formulation somewhat simplifies the expression by recognizing that the total number of trials is simply the number of successes and failures, that is: n=r+k. These second formulations may be more intuitive to understand, however they are perhaps less practical as they have more terms.

  • The definition where X is the number of n trials that occur for a given number of r successes is similar to the primary definition, except that the number of trials is given instead of the number of failures. This adds r to the value of the random variable, shifting its support and mean.
  • The definition where X is the number of k successes (or n trials) that occur for a given number of r failures is similar to the primary definition used in this article, except that numbers of failures and successes are switched when considering what is being counted and what is given. Note however, that p still refers to the probability of "success".
  • The definition of the negative binomial distribution can be extended to the case where the parameter r can take on a positive real value. Although it is impossible to visualize a non-integer number of "failures", we can still formally define the distribution through its probability mass function. The problem of extending the definition to real-valued (positive) r boils down to extending the binomial coefficient to its real-valued counterpart, based on the gamma function: (k+r−1k)=(k+r−1)(k+r−2)⋯(r)k!=Γ(k+r)k!Γ(r) After substituting this expression in the original definition, we say that X has a negative binomial (or Pólya) distribution if it has a probability mass function: f(k;r,p)≡Pr(X=k)=Γ(k+r)k!Γ(r)(1−p)kprfor k=0,1,2,… Here r is a real, positive number.

In negative binomial regression, the distribution is specified in terms of its mean, m=r(1−p)p, which is then related to explanatory variables as in linear regression or other generalized linear models. From the expression for the mean m, one can derive p=rm+r and 1−p=mm+r. Then, substituting these expressions in the one for the probability mass function when r is real-valued, yields this parametrization of the probability mass function in terms of m:

Pr(X=k)=Γ(r+k)k!Γ(r)(rr+m)r(mr+m)kfor k=0,1,2,… The variance can then be written as m+m2r. Some authors prefer to set α=1r, and express the variance as m+αm2. In this context, and depending on the author, either the parameter r or its reciprocal α is referred to as the "dispersion parameter", "shape parameter" or "clustering coefficient", or the "heterogeneity" or "aggregation" parameter. The term "aggregation" is particularly used in ecology when describing counts of individual organisms. Decrease of the aggregation parameter r towards zero corresponds to increasing aggregation of the organisms; increase of r towards infinity corresponds to absence of aggregation, as can be described by Poisson regression.

Alternative parameterizations

Sometimes the distribution is parameterized in terms of its mean μ and variance σ2: p=μσ2,r=μ2σ2−μ,Pr(X=k)=(k+μ2σ2−μ−1k)(1−μσ2)k(μσ2)μ2/(σ2−μ)E⁡(X)=μVar⁡(X)=σ2.

Another popular parameterization uses r and the failure odds β: p=11+βPr(X=k)=(k+r−1k)(β1+β)k(11+β)rE⁡(X)=rβVar⁡(X)=rβ(1+β).

Examples

Length of hospital stay

Hospital length of stay is an example of real-world data that can be modelled well with a negative binomial distribution via negative binomial regression.

Result Based as opposed to Time Based labour

Villy was a retired sheet metal worker who has been asked to come out of retirement to help his previous factory deal with low quality output in a certain subassembly in which he was master craftsman. Villy also needs the money, so he accepts. The manual process is practically the same except that he no longer has to clock in and out each day, but rather he will be measured on results rather than time spent. In the past, he could produce 28 subassemblies where on average one in seven would spoil due to dynamic cooling conditions in the process. In other words, instead of working 7 hours, he is now merely asked to produce 24 subassemblies in a day, irrespective of time taken. This is an example of moving from a process predicated on a binomial distribution over to one which is of the negative binomial.

Selling candy

Pat Collis is required to sell candy bars to raise money for the 6th grade field trip. Pat is (somewhat harshly) not supposed to return home until five candy bars have been sold. So the child goes door to door, selling candy bars. At each house, there is a 0.6 probability of selling one candy bar and a 0.4 probability of selling nothing.

What's the probability of selling the last candy bar at the n-th house?

Successfully selling candy enough times is what defines our stopping criterion (as opposed to failing to sell it), so k in this case represents the number of failures and r represents the number of successes. Recall that the NB(r, p) distribution describes the probability of k failures and r successes in k + r Bernoulli(p) trials with success on the last trial. Selling five candy bars means getting five successes. The number of trials (i.e. houses) this takes is therefore k + 5 = n. The random variable we are interested in is the number of houses, so we substitute k = n − 5 into a NB(5, 0.4) mass function and obtain the following mass function of the distribution of houses (for n ≥ 5):

f(n)=((n−5)+5−1n−5)(1−0.4)50.4n−5=(n−1n−5)352n−55n.

What's the probability that Pat finishes on the tenth house?

f(10)=9797769765625≈0.10033.

What's the probability that Pat finishes on or before reaching the eighth house?

To finish on or before the eighth house, Pat must finish at the fifth, sixth, seventh, or eighth house. Sum those probabilities: f(5)=2433125≈0.07776f(6)=4863125≈0.15552f(7)=291615625≈0.18662f(8)=1360878125≈0.17418 ∑j=58f(j)=4641378125≈0.59409.

What's the probability that Pat exhausts all 30 houses that happen to stand in the neighborhood?

This can be expressed as the probability that Pat does not finish on the fifth through the thirtieth house: 1−∑j=530f(j)=1−I0.4(5,30−5+1)≈1−0.999999823=0.000000177.

Because of the rather high probability that Pat will sell to each house (60 percent), the probability of her not fulfilling her quest is vanishingly slim.

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Statistics