Your Equation

Library / Probability distributions / PRD-45

Probability distributions

Failures before a target: exact probability

Probability of exactly x failures before the rth success in independent trials that each succeed with probability p.

Ref
PRD-45
Rev
v1
Field
Probability distributions
Result
P

The probability of exactly x failures before the rth success is C(x + r − 1, x) p^r (1 − p)^x. The count x is of failures only; the total number of trials is x + r. This is the negative binomial distribution, a count model that is more spread out than a Poisson count of the same mean.

Probability of exactly x failures before the rth success in independent trials that each succeed with probability p.

Calculator

Solve for
110
0.050.95
020
  • Expected failures, r(1 − p)/p4.5
  • Total trials for these failures, x + r5
  • Probability of no failures, p^r0.064

What drives the result

Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.

Probability of exactly x failures () current value 0.1382
pSuccess probability pKey driver
6.77e-40.207
rTarget number of successes r
0.002080.144
xFailures x
5.41e-4
  • The chance of exactly 2 failures before 3 successes at p = 0.4 is 13.8 %.
  • That sequence takes 5 trials in total, against an average of 7.5.
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing ()Local stepChange in result
p Success probability p0.05 to 0.95 6.769e-40.20710.2065+10%+15.9 %
r Target number of successes r1 to 10 0.0020760.1440.1419+1 −33.3 %
x Failures x0 to 20 5.405e-40.13820.1377+1 −2.22e-14 %

Sweep of Failures x

Failures xProbability of exactly x failures
00.064
2.50.1405
50.1045
7.50.05603
100.02554
12.50.01056
150.004092
17.50.001514
205.405e-4

Sweep one variable

Probability of exactly x failures ()Hover, touch, or use the arrow keys on the chart
00.050.10.15 05101520 Failures x now 0.1382

Variables and how each one contributes

P

Probability of exactly x failures

Result ·

What the equation gives you. Everything else feeds it.

r

Target number of successes r

· typical 1 to 10

The target number of successes (a whole number, at least 1). A larger target needs more failures along the way on average. Raising it by 1 (to 4) moves the result by −33.3 %, from 0.1382 to 0.09216.

p

Success probability p

· typical 0.05 to 0.95

The probability of success on each trial (0 to 1). Trials are independent. A higher success probability cuts the number of failures sharply. Raising it by 0.05 (to 0.45) moves the result by +19.6 %, from 0.1382 to 0.1654.

x

Failures x

· typical 0 to 20

The number of failures before the target is reached (a whole number, 0 or more). Moves the failure count at which the probability is read. Raising it by 1 (to 3) moves the result by −2.22×10−14 %, from 0.1382 to 0.1382.

Worked example with the values above

  1. Ways to arrange the failures among the first x + r − 1 trials: C(4, 2) = 6.
  2. Probability factors: p^r = 0.064 and (1 − p)^x = 0.36.
  3. P = 0.13824.

Assumptions and limits

  • Independent trials with the same success probability p, run until the rth success.
  • r is a whole number and 0 < p < 1.

Common mistakes

  • Forgetting that x counts failures only: the total number of trials is x + r.
  • Assuming a constant p when it drifts, for example when attempts improve with practice.
  • Using a Poisson model for counts that are more spread out than their mean.

Statistics and uncertainty

The inputs are parameters, usually fitted to data, and their estimation error carries into the result. The probability or density is a smooth function of the parameters, so the sweep chart shows how sensitive it is: where the curve is steep, a small error in a parameter makes a large difference. The formula treats the parameters as exact, so it gives no confidence interval on its own.

Where it is used

  • Counting failed attempts before a target number of passes in testing.
  • Overdispersed count data, where the variance exceeds the mean.

Maths you need

  • Combinations: ways of choosing items, C(n, k)
  • Independent trials: each outcome unaffected by the others

Related formulas

Practise this formula