The negative binomial distribution is used to calculate the probability that there are ‘x’ failures preceding the r^{th} success in ‘x+r’ Bernoulli trials.

Let X be a random variable following the negative binomial distribution with parameters ‘r’ and ‘p’. The probability distribution function is given by the formula,

P(X=x) = {{x+r-1}\choose{r-1}} p^r (1-p)^x \text{ where } x = 0, 1, 2,\ldotsWe can use the above formula to calculate probabilities for the random variable. Notice that if we put r=1 in the above formula, we get the pdf of the geometric distribution. Thus the negative binomial distribution is a generalization of the geometric distribution.

**Example:**

Suppose that a coin is tossed some number of times. Calculate the probability that we throw the coin 10 times in order to obtain 4 heads.

** Solution**: Let X denote the number of times that we get tails (failure) in order to get heads (success) 4 times. Then X is a negative binomial random variable with the parameters given as,

p = 0.5 = probability of getting heads (success)

r = 4 = number of heads (successes) out of the total number of trials.

Then we can calculate the required probability using the above formula.

P(X=6) = {{6+4-1}\choose{4-1}} (0.5)^4 (0.5)^6 = 0.082**Properties:**

- The expected value/mean of the negative binomial distribution is given as, E(X) = \frac{rq}{p} \text{ where } q=1-p
- The variance of the negative binomial distribution is given as, V(X) = \frac{rq}{p^2}
- The moment generating function (mgf) of the negative binomial distribution is given as, M_X(t) = (\frac{pe^t}{1-qe^t})^r