Negative binomial distribution


In probability theory and statistics, the negative binomial distribution is a discrete probability distribution that models the number of failures in a sequence of independent and identically distributed Bernoulli trials before a specified number of successes occurs. For example, we can define rolling a 6 on a die as a success, and rolling any other number as a failure, and ask how many failed rolls will occur before we see the third success. In such a case, the probability distribution of the number of non-6s that appear will be a negative binomial distribution.
The Pascal distribution and Polya distribution are special cases of the negative binomial distribution. A convention among engineers, climatologists, and others is to use "negative binomial" or "Pascal" for the case of an integer-valued stopping-time parameter r, and use "Polya" for the real-valued case.
For occurrences of associated discrete events, like tornado outbreaks, the Polya distributions can be used to give more accurate models than the Poisson distribution by allowing the mean and variance to be different, unlike the Poisson. The negative binomial distribution has a variance, with the distribution becoming identical to Poisson in the limit for a given mean. 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

Suppose there is a sequence of independent Bernoulli trials. Thus, each trial has two potential outcomes called "success" and "failure". In each trial the probability of success is p and of failure is. We are observing this sequence until a predefined number r of successes have occurred. Then the random number of failures we have seen, X, will have the negative binomial distribution:
When applied to real-world problems, outcomes of success and failure may or may not be outcomes we ordinarily view as good and bad, respectively. Suppose we used the negative binomial distribution to model the number of days a certain machine works before it breaks down. In this case "failure" would be the result on a day when the machine worked properly, whereas a breakdown would be a "success". If we used the negative binomial distribution to model the number of goal attempts an athlete makes before scoring r goals, though, then each unsuccessful attempt would be a "failure", and scoring a goal would be "success". If we are tossing a coin, then the negative binomial distribution can give the number of tails we are likely to encounter before we encounter a certain number of heads. In the probability mass function below, p is the probability of success, and is the probability of failure.

Probability mass function

The probability mass function of the negative binomial distribution is
where r is the number of successes, k is the number of failures, and p is the probability of success. Here the quantity in parentheses is the binomial coefficient, and is equal to
There are k failures chosen from k+r-1 samples rather than k+r because the last of the k+r samples is by definition a success.
This quantity can alternatively be written in the following manner, explaining the name "negative binomial":
Note that by the last expression and the binomial series, for every,
hence the terms of the probability mass function indeed add up to one.
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, because the outcomes of the k + r trials are supposed to happen independently. Since the rth 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.

Cumulative distribution function

The cumulative distribution function can be expressed in terms of the regularized incomplete beta function:
It can also be expressed in terms of the cumulative distribution function of the binomial distribution:

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 these 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:. 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:. These second formulations may be more intuitive to understand, however they are perhaps less practical as they have more terms.
  1. The definition where X is the number of k failures that occur for a given number of r successes. This definition is very similar to the primary definition used in this article, only that k successes and r failures are switched when considering what is being counted and what is given. Note however, that p still refers to the probability of "success".
  2. The definition where X is the number of n trials that occur for a given number of r successes. This definition is very similar to definition #2, only that r successes is given instead of k failures. Note however, that p still refers to the probability of "success".
In negative binomial regression, the distribution is specified in terms of its mean,, 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 and. 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:
The variance can then be written as. Some authors prefer to set, and express the variance as. 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.

Selling candy

Pat Collis is required to sell candy bars to raise money for the 6th grade field trip. There are thirty houses in the neighborhood, and Pat is 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 nth house?
Successfully selling candy enough times is what defines our stopping criterion, so k in this case represents the number of failures and r represents the number of successes. Recall that the NegBin distribution describes the probability of k failures and r successes in k + r Bernoulli trials with success on the last trial. Selling five candy bars means getting five successes. The number of trials 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 NegBin mass function and obtain the following mass function of the distribution of houses :
What's the probability that Pat finishes on the tenth house?
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:
What's the probability that Pat exhausts all 30 houses in the neighborhood?
This can be expressed as the probability that Pat does not finish on the fifth through the thirtieth house:
Because of the rather high probability that Pat will sell to each house, the probability of her NOT fulfilling her quest is vanishingly slim.

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.

Properties

Expectation

The expected total number of successes in a negative binomial distribution with parameters is rp/. To see this, imagine an experiment simulating the negative binomial is performed many times. That is, a set of trials is performed until failures are obtained, then another set of trials, and then another etc. Write down the number of trials performed in each experiment: and set. Now we would expect about successes in total. Say the experiment was performed times. Then there are failures in total. So we would expect, so. See that is just the average number of trials per experiment. That is what we mean by "expectation". The average number of successes per experiment is. This agrees with the mean given in the box on the right-hand side of this page.

Variance

When counting the number of successes given the number r of failures, the variance is rp/2.
When counting the number of successes before the r-th failure, the variance is r/p2.

Relation to the binomial theorem

Suppose Y is a random variable with a binomial distribution with parameters n and p. Assume p + q = 1, with p, q ≥ 0, then
Using Newton's binomial theorem, this can equally be written as:
in which the upper bound of summation is infinite. In this case, the binomial coefficient
is defined when n is a real number, instead of just a positive integer. But in our case of the binomial distribution it is zero when k > n. We can then say, for example
Now suppose r > 0 and we use a negative exponent:
Then all of the terms are positive, and the term
is just the probability that the number of failures before the rth success is equal to k, provided r is an integer.
Now we also allow non-integer values of r. Then we have a proper negative binomial distribution, which is a generalization of the Pascal distribution, which coincides with the Pascal distribution when r happens to be a positive integer.
Recall from above that
This property persists when the definition is thus generalized, and affords a quick way to see that the negative binomial distribution is infinitely divisible.

Recurrence relation

The following recurrence relation holds:

Related distributions

Consider a sequence of negative binomial random variables where the stopping parameter r goes to infinity, whereas the probability of success in each trial, p, goes to zero in such a way as to keep the mean of the distribution constant. Denoting this mean as λ, the parameter p will be p = λ/
Under this parametrization the probability mass function will be
Now if we consider the limit as r → ∞, the second factor will converge to one, and the third to the exponent function:
which is the mass function of a Poisson-distributed random variable with expected value λ.
In other words, the alternatively parameterized negative binomial distribution converges to the Poisson distribution and r controls the deviation from the Poisson. This makes the negative binomial distribution suitable as a robust alternative to the Poisson, which approaches the Poisson for large r, but which has larger variance than the Poisson for small r.

Gamma–Poisson mixture

The negative binomial distribution also arises as a continuous mixture of Poisson distributions where the mixing distribution of the Poisson rate is a gamma distribution. That is, we can view the negative binomial as a distribution, where λ is itself a random variable, distributed as a gamma distribution with shape = r and scale θ = or correspondingly rate.
To display the intuition behind this statement, consider two independent Poisson processes, “Success” and “Failure”, with intensities p and 1 − p. Together, the Success and Failure processes are equivalent to a single Poisson process of intensity 1, where an occurrence of the process is a success if a corresponding independent coin toss comes up heads with probability p; otherwise, it is a failure. If r is a counting number, the coin tosses show that the count of successes before the rth failure follows a negative binomial distribution with parameters r and p. The count is also, however, the count of the Success Poisson process at the random time T of the rth occurrence in the Failure Poisson process. The Success count follows a Poisson distribution with mean pT, where T is the waiting time for r occurrences in a Poisson process of intensity 1 − p, i.e., T is gamma-distributed with shape parameter r and intensity 1 − p. Thus, the negative binomial distribution is equivalent to a Poisson distribution with mean pT, where the random variate T is gamma-distributed with shape parameter r and intensity. The preceding paragraph follows, because λ = pT is gamma-distributed with shape parameter r and intensity.
The following formal derivation confirms the intuition.
Because of this, the negative binomial distribution is also known as the gamma–Poisson distribution.
Note: The negative binomial distribution was originally derived as a limiting case of the gamma-Poisson distribution.

Distribution of a sum of geometrically distributed random variables

If Yr is a random variable following the negative binomial distribution with parameters r and p, and support, then Yr is a sum of r independent variables following the geometric distribution with parameter 1 − p. As a result of the central limit theorem, Yr is therefore approximately normal for sufficiently large r.
Furthermore, if Bs+r is a random variable following the binomial distribution with parameters s + r and 1 − p, then
In this sense, the negative binomial distribution is the "inverse" of the binomial distribution.
The sum of independent negative-binomially distributed random variables r1 and r2 with the same value for parameter p is negative-binomially distributed with the same p but with r-value r1 + r2.
The negative binomial distribution is infinitely divisible, i.e., if Y has a negative binomial distribution, then for any positive integer n, there exist independent identically distributed random variables Y1, ..., Yn whose sum has the same distribution that Y has.

Representation as compound Poisson distribution

The negative binomial distribution NB can be represented as a compound Poisson distribution: Let denote a sequence of independent and identically distributed random variables, each one having the logarithmic distribution Log, with probability mass function
Let N be a random variable, independent of the sequence, and suppose that N has a Poisson distribution with mean. Then the random sum
is NB-distributed. To prove this, we calculate the probability generating function GX of X, which is the composition of the probability generating functions GN and GY1. Using
and
we obtain
which is the probability generating function of the NB distribution.
The following table describes four distributions related to the number of successes in a sequence of draws:
With replacementsNo replacements
Given number of drawsbinomial distributionhypergeometric distribution
Given number of failuresnegative binomial distributionnegative hypergeometric distribution

(a,b,0) class of distributions

The negative binomial along with the Poisson and binomial distributions is a member of the class of distributions. All three of these distributions are special cases of the Panjer distribution. They are also members of the Natural exponential family.

Statistical inference

Parameter estimation

MVUE for ''p''

Suppose p is unknown and an experiment is conducted where it is decided ahead of time that sampling will continue until r successes are found. A sufficient statistic for the experiment is k, the number of failures.
In estimating p, the minimum variance unbiased estimator is

Maximum likelihood estimation

The maximum likelihood estimate of p is
but this is a biased estimate. Its inverse /r, is an unbiased estimate of 1/p, however.
The maximum likelihood estimator only exists for samples for which the sample variance is larger than the sample mean. The likelihood function for N iid observations is
from which we calculate the log-likelihood function
To find the maximum we take the partial derivatives with respect to r and p and set them equal to zero:
where
Solving the first equation for p gives:
Substituting this in the second equation gives:
This equation cannot be solved for r in closed form. If a numerical solution is desired, an iterative technique such as Newton's method can be used. Alternatively, the expectation–maximization algorithm can be used.

Occurrence and applications

Waiting time in a Bernoulli process

For the special case where r is an integer, the negative binomial distribution is known as the Pascal distribution. It is the probability distribution of a certain number of failures and successes in a series of independent and identically distributed Bernoulli trials. For k + r Bernoulli trials with success probability p, the negative binomial gives the probability of k successes and r failures, with a failure on the last trial. In other words, the negative binomial distribution is the probability distribution of the number of successes before the rth failure in a Bernoulli process, with probability p of successes on each trial. A Bernoulli process is a discrete time process, and so the number of trials, failures, and successes are integers.
Consider the following example. Suppose we repeatedly throw a die, and consider a 1 to be a "failure". The probability of success on each trial is 5/6. The number of successes before the third failure belongs to the infinite set. That number of successes is a negative-binomially distributed random variable.
When r = 1 we get the probability distribution of number of successes before the first failure, which is a geometric distribution:

Overdispersed Poisson

The negative binomial distribution, especially in its alternative parameterization described above, can be used as an alternative to the Poisson distribution. It is especially useful for discrete data over an unbounded positive range whose sample variance exceeds the sample mean. In such cases, the observations are overdispersed with respect to a Poisson distribution, for which the mean is equal to the variance. Hence a Poisson distribution is not an appropriate model. Since the negative binomial distribution has one more parameter than the Poisson, the second parameter can be used to adjust the variance independently of the mean. See Cumulants of some discrete probability distributions.
An application of this is to annual counts of tropical cyclones in the North Atlantic or to monthly to 6-monthly counts of wintertime extratropical cyclones over Europe, for which the variance is greater than the mean. In the case of modest overdispersion, this may produce substantially similar results to an overdispersed Poisson distribution.
The negative binomial distribution is also commonly used to model data in the form of discrete sequence read counts from high-throughput RNA and DNA sequencing experiments.

History

This distribution was first studied in 1713, by Montmort, as the distribution of the number of trials required in an experiment to obtain a given number of successes. It had previously been mentioned by Pascal.