Calculators

Negative Binomial Distribution Calculator

Calculate negative binomial distribution probabilities for trials until a fixed number of successes, plus mean and variance, locally in your browser.

Find probabilities for the number of independent trials needed to reach a fixed number of successes. Your data stays in your browser.

Enter p as a decimal from 0.000000000001 to 1, the target successes r as a whole number from 1 to 1000, and the trial number k as a whole number from r to 1000000000. Trials must be independent with the same success probability.

Your negative binomial distribution results will appear here.

Model the wait until a fixed number of successes.

The negative binomial distribution models independent trials with a constant success probability p until r successes occur. X counts all trials including the r-th success, so X starts at r. P(X = k) = C(k − 1, r − 1) × p^r × (1 − p)^(k − r), the mean is r/p, and the variance is r × (1 − p)/p². With r = 1 it reduces to the geometric distribution. For p = 0.25, r = 3 and k = 10, the exact probability is about 0.075085, cumulative probability about 0.474407, probability of needing more than 10 trials about 0.525593, and the mean and variance are 12 and 36. Enter decimal p from 0.000000000001 to 1, whole r from 1 to 1000, and whole k from r to 1000000000. Cumulative and upper-tail probabilities use log-space binomial arithmetic, so very large trial counts stay accurate where naive calculation would underflow. A success probability of zero never reaches r successes and is excluded. This uses the trials convention; the alternative failures-before-success count is X − r. Results use floating-point arithmetic rounded to 12 significant digits; extremely small probabilities may round to zero. Calculations stay in your browser.

Frequently Asked Questions

Everything you need to know about this tool, how it works, and privacy.

What does X count?

X counts all trials up to and including the r-th success. Its smallest value is r. The failures-before-success convention counts X − r; if you have that count, add r before entering k.

How does this relate to the geometric distribution?

With r = 1, the negative binomial is the same as the geometric distribution in the trials-until-first-success convention.

When is this model suitable?

Use independent trials with the same success probability on each trial until you reach exactly r successes, such as draws until collecting a fixed number of a rare card. Dependent trials or changing probabilities do not follow this model.

What if success is certain?

When p = 1, you reach r successes exactly on trial r. P(X = r) is 1, mean is r, variance is 0.

Are the results exact?

Results use floating-point arithmetic rounded to 12 significant digits. Very small probabilities can round to zero. For very large k, cumulative probabilities use log-space binomial sums so they remain stable near zero or one. Inputs and calculations stay in your browser.