Estimation of the number of trials n made after having observed s successes with probability p

The problem

Consider the situation where we have observed s successes and know the probability of success p, but would like to know how many trials were actually done to have observed those successes. We wish to estimate a value that is fixed, so we require a distribution that represents our uncertainty about what the true value is. There are two possible situations: we either know that the trials stopped on the sth success or we do not.


If we know that the trials stopped on the sth success, we can model our uncertainty about the true value of n as:

                n = NegBin(s,p) + s

If, on the other hand, we do not know that the last trial was a success (though it could have been), then our uncertainty about n is modelled as:

                n = NegBin(s+1,p) + s

Both of these formulae result from a Bayesian analysis with Uniform priors for n.


Let x be the number of failures that were carried out before the sth success. We will use a uniform prior for x, i.e. p(x) = c, and, from the binomial distribution, the likelihood function is the probability that at the (s+x-1)th trial there had been (s-1) successes and then the (s+x)th trial was a success, which is just the Negative Binomial probability mass function:


Since we are using a uniform prior (assuming no prior knowledge), and the equation for l(X|x) comes directly from a distribution (so it must sum to unity) we can dispense with the formality of normalizing the posterior distribution to one, and observe:


i.e. that x = NegBin(s,p).

In the second case, we do not know that the last trial was a success, only that in however many trials were completed, there were just s successes. We have the same Uniform prior for the number of failures, but our likelihood function is just the binomial probability mass function, i.e.:


Since this does not have the form of a probability mass function of a distribution, we need to complete the Bayesian analysis, so:


The denominator sum turns out to equal 1/p. This can be easily seen by substituting s = a-1, which gives:


If the exponent for p were equal to a instead of (a-1), we would have the probability mass function of the Negative Binomial distribution, which would then sum to unity, so our denominator must sum to 1/p.

The posterior distribution then reduces to:

which is just a NegBin(s+1,p) distribution.



Monte Carlo simulation in Excel. Learn more

Spreadsheet risk analysis modeling


Adding risk and uncertainty to your project schedule. Learn more

Project risk analysis


Enterprise Risk Management software (ERM)

Learn more about our enterprise risk analysis management software tool, Pelican

Enterprise risk management software introduction


For Microsoft Excel

Download your free copy of ModelRisk Basic today. Professional quality risk modeling software and no catches

Download ModelRisk Basic now


For Primavera & Microsoft Project

Download your free copy of Tamara Basic today. Professional quality project risk software and no catches.

Download Tamara Basic now