Negative Binomial Distribution Calculator
Compute the probability of observing a given number of failures before the r-th success in a sequence of independent Bernoulli trials.
Mode
Probability of exactly 2 failures before success #3
- 1
log C(k + r − 1, k)
log C(4, 2) = 1.7918 - 2
r × log(p)
3 × log(0.5) = -2.0794 - 3
k × log(1 − p)
2 × log(0.5) = -1.3863 - 4
log P(X = k)
1.7918 + (-2.0794) + (-1.3863) = -1.674 - 5
P(X = k)
e^(-1.674) = 0.187500Exponentiate the log-probability to get the PMF value.
How does this calculator work?
The negative binomial distribution gives P(X = k) = C(k+r−1, k)·p^r·(1−p)^k, the chance of k failures before the r-th success. Enter r, p, and k to get the exact or cumulative probability, plus the mean r(1−p)/p and variance r(1−p)/p² of the failure count.
Formula
How this is calculated
The negative binomial (Pascal) distribution models the number of failures X = k that occur before the r-th success, where each independent trial succeeds with probability p. The probability mass function is P(X = k) = C(k + r − 1, k) · p^r · (1 − p)^k for k = 0, 1, 2, …. The binomial coefficient counts the arrangements of the first k failures and r − 1 successes among the first k + r − 1 trials; the final trial is always the r-th success. This calculator evaluates the coefficient through the log-gamma function so it stays numerically stable for large r and k.
Enter r (successes needed, a positive integer), p (per-trial success probability between 0 and 1), and k (failures). The mode selector chooses between an exact point probability P(X = k), the lower cumulative P(X ≤ k), and the upper tail P(X ≥ k) = 1 − P(X ≤ k − 1). The mean number of failures is r(1 − p)/p and the variance is r(1 − p)/p², so the spread grows quickly as p approaches 0.
Assumptions: trials are independent and identically distributed, p is constant, and counts are non-negative integers (k is rounded). The result is undefined when p ≤ 0 or p > 1; as p → 1 the distribution collapses toward k = 0 because successes arrive almost immediately.
Frequently asked questions
The binomial fixes the number of trials and counts successes; the negative binomial fixes the number of successes (r) and counts the failures (or trials) needed to reach them.
It counts failures k before the r-th success. The total number of trials is k + r, so add r to convert.
With r = 1 the negative binomial reduces to the geometric distribution: the probability of k failures before the first success.
Also known as
TG we-Calculate Editorial Team. (2026). Negative Binomial Distribution Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/negative-binomial-distribution-calculator
TG we-Calculate Editorial Team. "Negative Binomial Distribution Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/negative-binomial-distribution-calculator.
TG we-Calculate Editorial Team, "Negative Binomial Distribution Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/negative-binomial-distribution-calculator
@misc{wecalculate_negative_binomial_distribution_calculator, title = {Negative Binomial Distribution Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/negative-binomial-distribution-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
