PROBABILITY WORKSHEETS

Converting a total-trial stopping count to negative-binomial failures

The negative-binomial calculator counts failures before the required number of successes, not total trials. This guide shows how to convert a stopping trial into the failure count the k field expects.

What the k field counts

A negative-binomial setup repeats independent trials with a fixed success probability p until the r-th success arrives. Two different counts are natural: the total number of trials made, and the number of failures that came before the final success. The Negative Binomial Calculator here uses the second. Its k field means failures before r successes, and its formula is P(K = k) = C(k + r − 1, k) × p^r × (1 − p)^k. Many textbooks and statistical packages define the distribution on total trials instead, so a number copied from a problem statement can describe a different quantity than the field expects. Reading the label on the field before typing is the whole difference between a correct and an incorrect probability.

Converting a stopping trial into failures

Total trials equal successes plus failures, and the process stops on the r-th success, so exactly r of the trials are successes. Therefore failures = total trials − r. If the second success arrives on trial 3, then r = 2 and k = 3 − 2 = 1. With p = 0.5 the calculator returns 0.25. You can verify that by hand: of the first two trials, exactly one must be a success, which happens in two of four equally likely patterns, and the third trial must then be a success with probability 0.5. That gives 0.5 × 0.5 = 0.25. The binomial coefficient C(2, 1) = 2 in the formula counts those two patterns.

What happens if the total is typed as k

Entering 3 in the k field instead of 1 changes the event completely. With r = 2, k = 3 asks for three failures before the second success, which means five trials in total, with the fifth being the second success. The formula gives C(4, 3) × 0.5² × 0.5³ = 4 × 0.03125 = 0.125. The two results, 0.25 and 0.125, are both valid probabilities, and neither looks suspicious on its own. That is the danger: the mistake produces a plausible number. The only protection is to write down what you mean before entering it, either "second success on trial 3" or "three failures before the second success", and convert if necessary.

A different example: the third success on trial six

Take a fair coin with p = 0.5 and ask for the probability that the third head appears on flip 6. Here r = 3 and total trials = 6, so k = 3. The formula gives C(5, 3) × 0.5³ × 0.5³ = 10 × 0.015625 = 0.15625. The coefficient 10 counts the ways to place the first two heads among the first five flips. Notice that the answer for the third success on flip 6 differs from that for flip 5 or flip 7, and that the probabilities over all possible stopping trials add to 1. The calculator handles one specific k at a time, so each stopping trial needs its own run.

Matching the field to other sources

Statistical software conventions vary. Some libraries parameterize the negative binomial by the number of failures, some by the number of trials, and some swap the roles of success and failure so that p refers to the stopping event. A textbook may call the same quantity "the number of trials needed to get r successes" while a package documents "the number of failures before r successes". When comparing a result from this page with a result from elsewhere, check three things: what is counted, which outcome has probability p, and whether the distribution starts at 0 or at r. The worked cases here make the shift of exactly r between the two conventions concrete.

Edge cases: r = 1 and k = 0

The setting r = 1 reduces the distribution to the geometric one: the probability of k failures before the first success is (1 − p)^k × p. With p = 0.5 and k = 0 the first trial is already a success, with probability 0.5. When k = 0 for any r, every trial up to r must succeed, so the probability is p^r. For p = 0.5 and r = 2, that is 0.25, which is the same as the chance of two heads in the first two flips. These limits are good sanity checks on the output, since they can be computed without any binomial coefficient.

Choosing p and r from a real description

The calculator assumes each trial succeeds with the same probability p and that trials do not influence each other. A description such as "we stop interviewing after the second qualified candidate" fits only if the chance that a candidate qualifies is the same for every interview. When the trial outcomes depend on one another, or the probability changes as the process continues, the negative-binomial formula does not apply. The page treats p and r as given inputs and does not estimate p from data, so the result is conditional on the stated model.

Keeping total trials and failures labeled

In a worksheet or report, store both numbers: total trials used and failures before the final success. Their difference is r, so either one can be recovered from the other, but only if r is also recorded. Label the column that feeds the k field as failures, and the column that comes from the data collection as trials. A short conversion line such as "k = trials − r" next to the input prevents a repeat of the 0.25 versus 0.125 discrepancy. The illustration uses a coin with p = 0.5 and does not predict any real sampling process.

Summing over stopping points

Because the process must stop at some trial, the probabilities over all possible failure counts add to 1. With r = 2 and p = 0.5, the first few values are 0.25 for k = 0, 0.25 for k = 1, 0.1875 for k = 2, 0.125 for k = 3 and 0.078125 for k = 4. Those five terms already total 0.890625, and the remaining terms for larger k supply the other 0.109375. Running the calculator for several k values and adding them is a direct way to build a cumulative probability, such as the chance that the second success arrives within the first four trials, which is the sum for k = 0, 1 and 2, or 0.6875. The calculator reports the single-value probability, so the accumulation is done by the reader. The same idea answers questions about waiting for a success within a fixed number of trials: add the failure counts that fit inside the limit, remembering that k failures before the second success means k + 2 trials in total.

Reproduce the checks

Second success on trial three

Open the Negative Binomial Calculator and enter:

Success probability
0.5
Required successes
2
Successes / event count
1

Expected output:

Pmf

0.25

One failure plus two successes gives three total trials.

Three failures before the second success

Open the Negative Binomial Calculator and enter:

Success probability
0.5
Required successes
2
Successes / event count
3

Expected output:

Pmf

0.125

This is a different stopping event.

References and implementation scope

The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.

Sources

Related tasks