Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Negative Binomial Distribution Explorer

How to use
  1. Drag r and p under Parameters: r from 1 to 20 target successes, p from 0.01 to 0.99. Bars, statistics and every calculator result update at once. Learn more about the parameter sliders
  2. Statistics shows Expected Value, Variance, Std Deviation and Mode for the current parameters; Show Formulas prints the rule under each card. Learn more about the statistics panel
  3. PMF, the first tab above the chart, draws one bar per value k with height P(X=k)P(X = k); the red line marks E[X]E[X]. Learn more about the PMF display
  4. CDF replots the same values as the running total P(X≤k)P(X \le k), climbing from 0 to 1. Learn more about CDF values
  5. Table lists every k with P(X=k)P(X = k) and P(X≤k)P(X \le k) to six decimals. Learn more about the Table tab
  6. In the Probability Calculator, tap P(X = k), P(X < k), P(X ≤ k), P(X > k) or P(X ≥ k) and type k; the box below shows the probability to six decimals. Learn more about point probabilities
  7. Tap a range tab, P(a ≤ X ≤ b), P(a < X < b), P(a ≤ X < b) or P(a < X ≤ b), and type a and b; the four differ in which endpoints count. Learn more about range probabilities
  8. Key Properties in the right column: tap a row's ▼ to open its explanation, one at a time; Real-World Applications below lists typical uses. Learn more about key properties and applications


Modify Parameters and See Results

Number of trials until r successes

Parameters

Target Successes (r)
5

The number of successes we are waiting to achieve

Success Probability (p)
0.30

The probability of success on each trial

Failure Probability (q = 1-p)
0.70

The probability of failure on each trial

Expected Trials (E[X])
16.67

Average number of trials needed to get 5 successes

Statistics

Expected Value
16.6667
Variance
38.8889
Std Deviation
6.2361
Mode
14

Probability Calculator

Key Properties

Real-World Applications

  • Number of coin flips until getting 5 heads
  • Number of sales calls until closing 3 deals
  • Number of product inspections until finding 10 defects
  • Number of free throw attempts until making 20 baskets
  • Number of patients treated until 8 successful recoveries







Setting Distribution Parameters

DemoParameters and statistics
Step 0 of 4
Adjust r (number of successes) to specify how many successes you're waiting to achieve. The slider ranges from 1 (equivalent to geometric distribution) to 20 successes, covering typical application scenarios.

Set p (success probability) using the bottom slider from 0.01 to 0.99. This defines the likelihood of success on each individual trial, with higher p meaning you'll reach r successes more quickly.

The visualization updates immediately to show how these parameters affect the distribution shape. Higher r values create more bell-shaped distributions, while r = 1 gives the characteristic geometric decay.

Reading the Statistics Panel

The Statistics panel sits in the left column, under Parameters. Its four cards show Expected Value, Variance and Std Deviation to four decimals, and Mode as a whole number of trials. Every card recomputes on each slider move, so the panel always describes the bars in the middle column; the red E[X]E[X] line on the chart sits at the Expected Value number.

Show Formulas prints the rule under each card: E[X]=r/pE[X] = r/p, Var(X)=r(1−p)/p2\text{Var}(X) = r(1-p)/p^2, σ=r(1−p)/p2\sigma = \sqrt{r(1-p)/p^2} and Mode=⌊(r−1)(1−p)/p⌋+r\text{Mode} = \lfloor (r-1)(1-p)/p \rfloor + r. The button then reads Hide Formulas. The numbers are the same either way; the formulas only show where they come from.

At the opening values, r=5r = 5, p=0.3p = 0.3, the cards read 16.6667, 38.8889, 6.2361 and 14. Mode 14 sits below the Expected Value 16.6667 because the bars have a long right tail. At r=10r = 10, p=0.5p = 0.5 the cards read 20.0000, 20.0000, 4.4721 and 19.

The Parameters cards above the panel repeat each value with its symbol and a one-line meaning: Target Successes (r), Success Probability (p), Failure Probability (q = 1-p) and Expected Trials (E[X]). For where the formulas come from, see Distribution Statistics and Properties.

Understanding the PMF Display

DemoPMF, CDF and Table tabs
Step 0 of 4
The PMF bars start at k = r (the minimum possible trial number) since you need at least r trials to get r successes. Each bar shows P(X = k), the probability that the rth success occurs exactly on trial k.

The distribution's shape depends heavily on r. For r = 1, you see pure exponential decay. As r increases, the distribution becomes more symmetric and bell-shaped, eventually approximating a normal distribution for large r.

The mode (peak) occurs near r/p, which also represents the mean. This is where the rth success is most likely to occur, balancing the competing effects of needing more trials versus decreasing probability of longer sequences.

Interpreting CDF Values

The CDF shows P(X ≤ k), the probability that you achieve r successes within the first k trials. The curve starts at 0 for k < r and approaches 1 as k increases.

The steepness of the CDF curve around the mean indicates concentration. A steep curve means most probability mass is concentrated near the expected value r/p, while a gradual curve indicates higher variability.

Unlike the binomial CDF which always reaches exactly 1 at n trials, the negative binomial CDF approaches 1 asymptotically since theoretically you could need infinitely many trials (though this becomes vanishingly unlikely).

Using the Table Tab

Table is the third tab above the chart, after PMF and CDF. It replaces the chart with three columns, k, P(X = k) and P(X ≤ k), one row per value on the chart's axis, every value to six decimals. The rows follow the sliders: move one and the whole table recomputes.

Use it where the chart is too small to read. At the opening values, r=5r = 5, p=0.3p = 0.3, the table runs from k=5k = 5 to k=50k = 50. Row 5 is 0.002430, the chance that the first five trials are all successes; the table stops at k=50k = 50 with P(X≤50)=0.999828P(X \le 50) = 0.999828, so a sliver of probability lies beyond the last row.

The P(X ≤ k) column is the CDF as numbers, and each P(X = k) entry is one bar of the PMF chart. Subtract two neighbouring P(X ≤ k) rows to recover a P(X = k) entry. For a value the table does not list, or a range of values, use the Probability Calculator below the chart.

The Explorer at Its Opening Parameters

With r=5r = 5 and p=0.3p = 0.3 the bars start at k=5k = 5 — five successes need at least five trials — and run to the window edge at k=50k = 50. The peak is at k=14k = 14 with P=0.0701P = 0.0701, while the red mean line sits at E[X]=r/p=16.67E[X] = r/p = 16.67.

The plotted bars sum to 0.9998280.999828.
0.0000.0150.0300.0450.0600.075591317212529333741454950Value (k)Probability P(X = k)E[X]=16.670.0000.2000.4000.6000.8001.00591317212529333741454950Value (k)Cumulative Probability P(X ≤ k)E[X]=16.67
Negative binomial, r = 5, p = 0.3: PMF above, CDF below

Support starts at k = 5 and the peak has moved to k = 14, left of the mean at 16.67. Setting r = 1 would collapse this to the geometric exactly.

The mode is ⌊(r−1)/p⌋+1=14\lfloor (r-1)/p \rfloor + 1 = 14, not the mean. The two differ because the distribution is still right skewed, though far less so than the geometric — waiting for five successes averages out some of the randomness of waiting for one.

Setting r=1r = 1 would collapse this to the geometric case exactly. Raising rr pushes the whole distribution right and makes it more symmetric, since a sum of rr independent waiting times concentrates around its mean.

The variance is r(1−p)/p2=38.9r(1-p)/p^2 = 38.9, so σ=6.24\sigma = 6.24. Note that this is 5\sqrt{5} times the geometric's σ\sigma at the same pp — variances of independent waits add, standard deviations do not.

Calculating Point Probabilities

DemoPoint and cumulative probabilities
Step 0 of 4
Enter trial number k in the P(X = k) row of the Probability Calculator to compute P(X = k) using the negative binomial formula: C(k-1, r-1) × p^r × (1-p)^(k-r).

The binomial coefficient C(k-1, r-1) counts ways to arrange r-1 successes in the first k-1 trials (the rth success must occur on trial k). The calculator handles this computation even for large values.

Try k = 10, r = 3, p = 0.4. This calculates the probability that your 3rd success occurs exactly on the 10th trial - meaning exactly 2 successes in the first 9 trials, followed by a success on trial 10.

Using Cumulative Calculators

The P(X ≤ k) calculator sums probabilities from r to k, giving the probability of achieving r successes within k trials. This is useful for questions like "What's the chance I'll close 5 sales within 20 calls?"

P(X ≥ k) computes the probability of needing at least k trials, which equals 1 - P(X ≤ k-1). This helps assess risk: "What's the probability I'll need 30 or more trials to get 10 successes?"

The distinction between ≤ and < (or ≥ and >) matters for discrete distributions. P(X < k) excludes k itself and equals P(X ≤ k-1).

Computing Range Probabilities

DemoRange probabilities
Step 0 of 4
Range calculations find P(a ≤ X ≤ b) by computing F(b) - F(a-1), where F is the CDF. This gives the probability that the rth success occurs between trials a and b.

The four boundary options provide flexibility:
• [a, b] includes both a and b
• (a, b) excludes both endpoints
• [a, b) includes a but excludes b
• (a, b] excludes a but includes b

Example: With r = 5, what's P(15 ≤ X ≤ 25)? This is the probability that your 5th success occurs somewhere between trial 15 and trial 25.

Key Properties and Real-World Applications

The right column holds two lists. Key Properties has 5 rows, each ending in ▼: Support: X ∈ {5, 6, 7, ...}, Fixed Number of Successes, Generalizes Geometric Distribution, Independent Trials, Overdispersion vs Poisson. Row titles here are those at the opening values. Tap a row to open its explanation; tap another and the first closes, so one explanation is open at a time; tap the open row to close it.

The support row moves with rr, and Overdispersion vs Poisson quotes the current variance and mean (38.89 and 16.67 at the opening values). Open a row, move a slider, and the numbers in the open explanation follow.

Real-World Applications, below, lists 5 situations the negative binomial distribution models, starting with Number of coin flips until getting 5 heads and Number of sales calls until closing 3 deals. This list is fixed text and does not change with the sliders.

The rows are short summaries. The full treatment is in What is the Negative Binomial Distribution?.

What is the Negative Binomial Distribution?

The negative binomial distribution models the number of trials needed to achieve a fixed number r of successes in a sequence of independent Bernoulli trials. It generalizes the geometric distribution from r = 1 to any positive integer r.

The "negative" terminology comes from an equivalent formulation counting failures before the rth success, but the standard parameterization counts total trials. Each trial has constant success probability p and is independent of all others.

Applications include epidemiology (cases until r infections), insurance (claims until r payouts), and ecology (samples until r species observed). For comprehensive theory, see negative binomial distribution theory page.

Relationship to Geometric Distribution

The geometric distribution is the special case where r = 1. When you only need one success, the negative binomial reduces exactly to the geometric distribution.

For r > 1, the negative binomial can be viewed as the sum of r independent geometric random variables. If X1,X2,...,XrX_1, X_2, ..., X_r are geometric(p), then X1+X2+...+XrX_1 + X_2 + ... + X_r follows a negative binomial distribution.

This connection explains why both distributions share certain properties and why the negative binomial approaches a normal distribution as r increases - it's a sum of independent random variables, invoking the Central Limit Theorem.

Distribution Statistics and Properties

The mean E[X] = r/p represents the expected number of trials to achieve r successes. With r = 5 and p = 0.25, expect 20 trials on average.

The variance equals r(1-p)/p², which grows faster than the mean as p decreases. This variance > mean property distinguishes negative binomial from Poisson and makes it useful for overdispersed count data.

The standard deviation r(1−p)/p2\sqrt{r(1-p)/p²} measures typical deviation from the mean. When r is large, the distribution becomes approximately normal with these parameters.