Calculator

Negative Binomial Distribution Calculator Online

Calculate probabilities and cumulatives of failures before reaching a target number of successes.

Settings

Calculator focused on this distribution.

Result and visualization

Calculate PDF/PMF, CDF and percentiles instantly.

Result pending…

Explanation

The negative binomial distribution models the number of failures that accumulate before reaching a fixed number of successes \( r \) in a sequence of independent trials, each with the same success probability \( p \). It is a discrete distribution that generalizes the geometric distribution: when \( r = 1 \), it models the number of failures before the first success, equivalent to the failures-based geometric (support on \(\{0,1,2,\ldots\}\)), which differs by 1 from the variant that counts total trials (support on \(\{1,2,3,\ldots\}\)). Its mean is \( r(1-p)/p \) and its variance \( r(1-p)/p^2 \), always greater than the mean, which also makes it useful for modeling overdispersed counts where the variance exceeds the mean.

Use it when you want to answer questions like "how many failed attempts will there be before achieving \( r \) successes?" or, in its alternative parameterization, "how many trials in total are needed?". It is common in project management (attempts until closing contracts), clinical trials (recruiting \( r \) patients who respond), data science (modeling overdispersed counts) and reliability analysis. If count data show variance greater than the mean (overdispersion relative to Poisson), the negative binomial usually fits better.

Formula

$$ P(X=k)=\binom{k+r-1}{k}(1-p)^k p^r $$

Parameters

  • r: desired number of successes.
  • p: probability of success on each trial.
  • k: number of failures observed before reaching the r successes.

Worked example

Situation: A researcher runs independent clinical trials, each with a success probability of \(p = 0.4\). They want to know how many failures accumulate before achieving exactly \(r = 3\) successes. Let \(X\) be the number of failures before the third success.

Question 1: What is the probability of getting exactly 5 failures before the third success, \(P(X = 5)\)?

Solution: We use the negative binomial PMF. The third success occurs on trial \(r + k = 3 + 5 = 8\), with the remaining 2 successes distributed among the first 7 trials: \[ P(X = 5) = \binom{r + k - 1}{k}\,p^r\,(1-p)^k = \binom{7}{5}(0.4)^3(0.6)^5 \] \[ = 21 \times 0.064 \times 0.07776 \approx 0.1045 \] There is approximately a 10.45% probability of accumulating exactly 5 failures before the third success.

Question 2: What is the expected number of failures before the third success, \(E[X]\)?

Solution: The mean of the negative binomial is: \[ E[X] = \frac{r(1-p)}{p} = \frac{3 \times 0.6}{0.4} = \frac{1.8}{0.4} = 4.5 \] On average, 4.5 failures are expected before completing 3 successes, implying an expected total of \(3 + 4.5 = 7.5\) trials.

Interpretation: With a 40% success rate, achieving 3 successes requires 7.5 attempts on average. Knowing this distribution allows planning resources and establishing confidence intervals for the total number of trials needed.

How to interpret the result

The calculator offers three types of output. The PMF, \( P(X = k) \), gives the probability that exactly \( k \) failures (or trials, depending on the chosen parameterization) are needed before obtaining the r-th success. For example, if \( P(X = 8) = 0.09 \) with \( r = 3 \) and \( p = 0.25 \), it means that approximately 9% of processes of this type require exactly 8 failures before achieving 3 successes. In the chart, the vertical bars show the probability of each possible count; the distribution tends to be skewed to the right.

The CDF, \( P(X \leq k) \), accumulates the probability that the number of failures is at most \( k \). If \( P(X \leq 12) = 0.82 \), 82% of experiments of this type conclude with 12 or fewer failures before the r-th success. The right tail \( P(X > k) \) indicates how rare it is to need more than \( k \) additional attempts. The green area in the chart represents the cumulative probability of the selected range; the horizontal axis shows the possible failure counts.

The percentile result returns the smallest integer \( k \) such that \( P(X \leq k) \geq p \). The 90th percentile sets a planning threshold: if the 90th percentile is \( k = 15 \), 90% of processes will have concluded with 15 or fewer failures. In project management or sales contexts, this allows sizing resources (time, attempts, budget) with a defined confidence margin.

Frequently asked questions

  • What does the negative binomial model? The number of accumulated failures before achieving the r-th success in independent trials with probability p, which is the convention this calculator uses. It generalises the geometric, which is the case r = 1.
  • How does it differ from the binomial? The binomial fixes the number of trials and counts successes; the negative binomial fixes the number of successes you want and counts how many failures occur along the way.
  • Why is it used for overdispersed count data? Because its variance exceeds its mean, unlike the Poisson, where both coincide. That makes it a better fit for real count data with excess variability.

Reference: Negative binomial distribution — Wikipedia