Negative Binomial Distribution Calculator

Negative Binomial Distribution Calculator

How many trials โ€” or how many failures โ€” until the r-th success? Enter r and p, pick what to find, and get the exact probability with every step shown.

The r-th success ends the run
The same p on every trial
P(Y = 2) ยท r = 3, p = 0.4
0.1382

P(Y = y)
0.1382
P(Y โ‰ค y)
0.3174
P(Y โ‰ฅ y)
0.8208
Mean (failures)
4.5000
Variance
11.2500
Standard deviation
3.3541

CALCULATION

    PMF chart โ€” failures before the 3rd success

    Each bar is P(Y = y). The red bar is the value you asked about (y = 2).

    A negative binomial distribution calculator finds the probability of waiting a given number of trials โ€” or failures โ€” until the r-th success. Enter the number of successes r and the success probability p, and it returns the exact, at-most and at-least probabilities, the mean, variance and standard deviation, with a PMF chart and a full distribution table.

    How to use the negative binomial calculator

    1. Choose a counting mode. Count failures before r successes (Y) or trials until r successes (X). The two count the same run of trials โ€” X is always Y + r.
    2. Enter r and p. r is the number of successes you are waiting for (a whole number of 1 or more); p is the probability of success on a single trial (between 0 and 1).
    3. Enter the value to find โ€” the number of failures y, or the number of trials x โ€” and pick what to find: the exact probability, at most, or at least.
    4. Read the results. The headline is the probability you asked for. The results grid gives the mean, variance and standard deviation, the ledger shows every step, and the chart highlights the value you asked about.
    5. Try it now. With r = 3 and p = 0.4, the calculator gives P(Y = 2) = 0.1382 and a mean of 4.5 failures (7.5 trials).

    When should you use a negative binomial distribution?

    Use it when you are counting trials until a fixed number of successes, with:

    • A fixed number of successes r to wait for โ€” the run stops at the r-th success.
    • Independent trials with the same success probability p on every trial.
    • Counting the failures (or the trials) before that r-th success.

    Typical cases: how many sales calls until the 3rd sale, how many free throws until the 5th basket, how many patients until the 10th recovery. If you only need one success (r = 1), the geometric distribution calculator is the same thing with a simpler formula. If you are counting successes in a fixed number of trials instead, use the binomial probability calculator. If you are counting rare events in a fixed interval, use the Poisson distribution calculator.

    Trials or failures? Two ways to count the same run

    The negative binomial has two standard parameterisations, and this page lets you switch between them with the toggle above the calculator:

    • Y = failures before the r-th success: Y = 0, 1, 2, โ€ฆ Mean = r(1 โˆ’ p) / p. P(Y = y) = C(y + r โˆ’ 1, y) ร— pr ร— (1 โˆ’ p)y.
    • X = trials until the r-th success: X = r, r + 1, r + 2, โ€ฆ Mean = r / p. P(X = x) = C(x โˆ’ 1, r โˆ’ 1) ร— pr ร— (1 โˆ’ p)x โˆ’ r.
    • The link: X = Y + r. So P(X = 5) = P(Y = 2) when r = 3 โ€” the same event, counted two ways. The variance is the same in both: r(1 โˆ’ p) / pยฒ.

    Trap: mixing the two counts is the #1 error with this distribution. If your answer counts trials, it must be at least r; if it counts failures, it starts at 0. The calculator converts between the two when you switch modes, so check which one you are reading.

    The geometric link: r = 1

    Set r = 1 and the negative binomial becomes the geometric distribution โ€” waiting for a single success. With p = 0.4, P(Y = 2) = 0.6ยฒ ร— 0.4 = 0.144 is the same event as P(X = 3) = 0.144 on the geometric distribution calculator: two failures, then a success on the third trial. Every negative binomial is a sum of r independent geometric waiting times โ€” that is why its mean is r times the geometric mean and its variance is r times the geometric variance.

    Overdispersed counts: negative binomial vs Poisson

    The Poisson distribution has variance equal to its mean. The negative binomial has variance = mean + meanยฒ / r โ€” always larger than the mean. So when your counts vary more than Poisson allows (overdispersion), the negative binomial is the standard fix: it behaves like a Poisson distribution whose rate varies from case to case. If the variance is about the same as the mean, Poisson is fine; if the variance is clearly larger, reach for the negative binomial. Read more in types of probability distributions.

    Worked examples

    Example 1 โ€” r = 3, p = 0.4

    A basketball player makes 40% of her free throws. How many misses before her 3rd make? P(Y = 2) = C(4, 2) ร— 0.4ยณ ร— 0.6ยฒ = 6 ร— 0.064 ร— 0.36 = 0.1382. The same event in trials is P(X = 5) = 0.1382. The mean is 4.5 failures (7.5 trials) and the variance is 11.25. P(X โ‰ค 4 trials) = P(Y โ‰ค 1) = 0.0640 + 0.1152 = 0.1792, and P(X > 8 trials) = P(Y > 5) = 1 โˆ’ 0.6846 = 0.3154.

    Example 2 โ€” the geometric link

    With r = 1 and p = 0.4, the calculator gives P(Y = 2) = 0.6ยฒ ร— 0.4 = 0.144. That is the same event as P(X = 3) = 0.144 on the geometric distribution calculator โ€” two failures, then a success on the third trial. The mean is 1.5 failures (2.5 trials) and the variance is 3.75.

    Example 3 โ€” the test values

    With r = 2 and p = 0.5: P(Y = 1) = C(2, 1) ร— 0.5ยฒ ร— 0.5 = 2 ร— 0.25 ร— 0.5 = 0.25. And with r = 1 and p = 0.25, P(X = 3) = 0.75ยฒ ร— 0.25 = 0.1406 โ€” the geometric value, as expected when r = 1.

    Frequently asked questions

    Trials or failures โ€” which should I use?

    Both count the same run of trials, so pick the one that matches your question. Failures (Y) starts at 0 and its mean is r(1 โˆ’ p)/p; trials (X) starts at r and its mean is r/p. They are linked by X = Y + r, so P(X = 5) = P(Y = 2) when r = 3. The calculator has a toggle that converts between the two, and the variance r(1 โˆ’ p)/pยฒ is the same either way.

    How is the negative binomial related to the geometric distribution?

    The geometric distribution is the negative binomial with r = 1 โ€” waiting for a single success. With p = 0.4, P(Y = 2) = 0.144 in both: two failures then a success on the third trial. More generally, a negative binomial with r successes is the sum of r independent geometric waiting times, which is why its mean and variance are r times the geometric ones.

    Source: all examples on this page were recomputed with Python (scipy.stats), last updated 19 November 2026.

    See all 91 free statistics tools on Empirical Rule Calculators.