Negative Binomial Distribution Calculator

Enter r successes, probability p and k failures.

How it is calculated

The tool gives the probability of exactly k failures before the r-th success in independent trials with the same success probability: P(X = k) = C(k + r − 1, k) × pr × (1 − p)k. Here r is the number of successes you wait for, p is the success probability of one trial as a number from 0 to 1, k is the number of failures, and C(n, m) counts the ways to place the k failures among the trials before the last success. The mean number of failures is r (1 − p) / p and the variance is r (1 − p) / p². The probability is shown to four decimals, mean and variance to two. The tool requires r to be a whole number of at least 1, k a whole number of at least 0, and p above 0 and at most 1. With p = 1 there are never any failures, so k = 0 gives 1.0000. The answer is for exactly k failures, not for k or fewer.

Worked example

A player needs 5 successes, and each attempt succeeds with probability 0.6. What is the chance of exactly 3 failures before the 5th success? C(3 + 5 − 1, 3) = C(7, 3) = 35. p5 = 0.65 = 0.07776. (1 − p)3 = 0.43 = 0.064. Probability = 35 × 0.07776 × 0.064 = 0.1742. Mean failures = 5 × 0.4 / 0.6 = 3.33, and variance = 5 × 0.4 / 0.36 = 5.56. So exactly 3 failures happens about 17.4% of the time.

Try this example →

Common mistakes

  • Entering p as a percentage, such as 60 for 60%. The field is a probability between 0 and 1, so type 0.6; 60 gives no result.
  • Entering the number of trials as k. The tool counts failures; with 5 successes and 3 failures, the total number of trials is 8.
  • Reading P(X = k) as the chance of at most k failures. It is the chance of exactly k; add the values for k = 0, 1, 2, … for a cumulative figure.
  • Mixing up r and k. The r field is the number of successes you wait for (at least 1), while k can be 0.
  • Expecting the mean to be the number of trials. The mean is the average number of failures, r (1 − p) / p, which here is 3.33; the average number of trials would be that plus r.

About this calculator

The negative binomial distribution models the number of failures that occur before a fixed number of successes, r, is reached in a sequence of independent trials each with success probability p — for example, how many times you would expect to miss a free throw before making your 5th successful one. Its mean is r(1−p)/p and its variance is r(1−p)/p², and setting r = 1 reduces it to the simpler geometric distribution, which just counts failures before the first success.

It differs from the ordinary binomial distribution in what is held fixed: binomial fixes the number of trials and counts successes, while negative binomial fixes the number of successes and counts trials (or failures) needed to get there. Beyond coin-flip style examples, the distribution is widely used in reliability engineering to model the number of failures before a set number of successful units, in sports analytics for streaks, and in ecology and epidemiology to model overdispersed count data — counts with more variance than a plain Poisson distribution would predict, such as disease case counts across regions.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators