standarddeviationcalculator.net SD Calculator

Negative binomial distribution calculator

Share this page

Favorites

    No favorites yet. Press Favorite on any page to keep it here.

    Methodology

    Enter the number of successes r you are waiting for and the success probability p, then choose whether X counts failures or trials. The calculator gives the probability of exactly, at most or at least k, with the working.

    A whole number, 1 or more.

    P(X = 4) 0.124416
    P(X ≤ k)0.580096
    P(X ≥ k)0.54432
    P(X < k)0.45568
    P(X > k)0.419904
    Mean4.5
    Variance11.25
    Standard deviation3.3541
    Median4
    Mode2 and 3 (tied)
    Mean formular(1 − p) / p
    00.020.040.060.080.10.120.14 0246810121416182022

    Each bar is P(X = k). Solid bars are the values included in the answer.

    Probability table
    Values 0 to 22 (the rest carry almost no probability)
    kP(X = k)P(X ≤ k)P(X ≥ k)
    00.0640.0641
    10.11520.17920.936
    20.138240.317440.8208
    30.138240.455680.68256
    40.1244160.5800960.54432
    50.1045090.6846050.419904
    60.08360760.7682130.315395
    70.06449730.832710.231787
    80.04837290.8810830.16729
    90.03547350.9165570.118917
    100.02554090.9420980.0834433
    110.01811080.9602080.0579024
    120.01267760.9728860.0397916
    130.008776790.9816630.027114
    140.006018370.9876810.0183372
    150.004092490.9917740.0123188
    160.002762430.9945360.00822636
    170.001852450.9963890.00546393
    180.001234970.9976230.00361147
    190.0008189790.9984420.0023765
    200.0005405260.9989830.00155752
    210.0003552030.9993380.001017
    220.0002324970.9995710.000661794
    Show the working, step by step
    1. Probability of exactly k:

      P(X = k) = C(k + r − 1, k) pr (1 − p)k P(X = 4) = C(6, 4) × 0.43 × 0.64 = 15 × 0.064 × 0.1296 = 0.124416

    Negative binomial distribution formulas

    Y = failures before the r-th success (k = 0, 1, 2, …):

    P(Y = k) = C(k + r − 1, k) pr (1 − p)k mean = r(1 − p)/p variance = r(1 − p)/p²

    X = trials up to and including the r-th success (k = r, r + 1, …):

    P(X = k) = C(k − 1, r − 1) pr (1 − p)k−r mean = r/p variance = r(1 − p)/p²

    The binomial coefficient counts where the first r − 1 successes can fall. The last trial must be the r-th success.

    Negative binomial distribution: worked example

    A basketball player makes 40% of free throws. She keeps shooting until she has made 3. What is the probability that she misses exactly 4 times along the way?

    P(Y = 4) = C(6, 4) × 0.4³ × 0.6⁴ = 15 × 0.064 × 0.1296 = 0.124416

    Four misses means 7 shots in total, so in the trials convention the same answer is P(X = 7) = C(6, 2) × 0.4³ × 0.6⁴ = 0.124416. The cumulative probability of at most 4 misses adds the terms for 0 to 4 misses:

    P(Y ≤ 4) = 0.064 + 0.1152 + 0.13824 + 0.13824 + 0.124416 = 0.580096

    On average she misses 3 × 0.6/0.4 = 4.5 times (7.5 shots in total), with variance 3 × 0.6/0.16 = 11.25 and standard deviation 3.3541. The mode is a tie. (r − 1)(1 − p)/p = 3 is a whole number, so 2 and 3 misses are equally likely, each with probability 0.13824.

    Reading the result

    The chart is skewed right. A long run of misses is unlikely but possible, and the tail goes on without limit. The solid bars are the values counted in your answer. The median here is 4 misses, because P(Y ≤ 3) = 0.45568 and P(Y ≤ 4) = 0.580096 straddle one half.

    Where it is used

    Besides waiting-time questions (how many sales calls until the third sale, how many patients to screen before enrolling r who qualify), the negative binomial is the standard model for count data that vary more than a Poisson allows. In ecology, epidemiology and insurance the variance of counts is often several times the mean. The negative binomial's extra parameter absorbs that clustering, where a Poisson model would understate the uncertainty.

    Common mistakes

    • Mixing the conventions. If your answer is off by exactly r in the mean, you have counted failures where the question counts trials, or the reverse.
    • Using C(k, r) instead of C(k − 1, r − 1). The last trial is fixed as a success, so only the earlier trials are arranged.
    • Confusing it with the binomial. The binomial fixes the trials and counts successes. The negative binomial fixes the successes and counts trials.
    Negative binomial distribution calculator: the worked example on this page, with its result and chart
    Negative binomial distribution calculator: the worked example above, at a glance.

    Common questions

    What does the negative binomial distribution count?

    How long it takes to reach a fixed number of successes r in independent trials with success probability p. It is counted either as the number of failures before the r-th success (0, 1, 2, …) or as the total number of trials (r, r + 1, …). The geometric distribution is the special case r = 1.

    Which convention does my software use?

    R's dnbinom(x, size = r, prob = p), SciPy's nbinom and Excel's NEGBINOM.DIST all count failures. Many textbooks and exam boards count trials. Convert with trials = failures + r. The variance r(1 − p)/p² is the same in both.

    How is the cumulative probability calculated?

    By adding the terms, or through the identity P(Y ≤ k) = Ip(r, k + 1), the regularised incomplete beta function, which is what the calculator uses. Equivalently, having at most k failures before the r-th success means at least r successes in the first r + k trials, a binomial tail.

    Why is it used for overdispersed counts?

    Count data whose variance is larger than the mean cannot be Poisson, which forces them to be equal. The negative binomial has variance mean + mean²/r, so it fits bunched counts such as insurance claims, hospital visits or species abundance. In that role r need not be a whole number, but this calculator keeps r whole, as in the trials interpretation.