Home > Probability theory and statistics > Stochastic processes > The Binomial process > Estimation of the number of trials n made after having observed s successes with probability p
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 s^{th} success or we do not.
Results
If we know that the trials stopped on the s^{th} success, we can model our uncertainty about the true value of n as:
n = NegBinomial(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 modeled as:
n = NegBinomial(p, s+1)  1
Both of these formulae result from a Bayesian analysis with Uniform priors for n.
Derivations
Let x be the number of trials that were needed to obtain the s^{th} 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 (x1)^{th} trial there had been (s1) successes and then the x^{th} trial was a success, which is just the Negative Binomial probability mass function:
LaTeX Math Block 

...

 
\( l(X \mid x)=\left( \begin{array}{c} x1 \\ xs \end{array} \right) p^{s}(1p)^{xs} \) 
...
Since we are using a uniform prior (assuming no prior knowledge), and the equation for l(Xx) 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:
LaTeX Math Block  


 
\( p(x)=\left( \begin{array}{c} x1 \\ xs \end{array} \right) p^{s}(1p)^{xs} \) 
...
i.e. that x = NegBinomial(p,s).
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 trials, but our likelihood function is just the binomial probability mass function, i.e.:
LaTeX Math Block 

...

...
 
\( l(X \mid x)=\left( \begin{array}{c} x \\ s \end{array} \right) p^{s}(1p)^{xs} \) 
...
Since this does not have the form of a probability mass function of a known distribution, we need to complete the Bayesian analysis, so:
LaTeX Math Block 

...

 
f \big(x \mid X \big)= \frac{\left( \begin{array}{c} x \\ s \end{array} \right) p^{s}\big(1p\big)^{xs}}{\displaystyle\sum_{i=s}^{\infty}\left( \begin{array}{c} i \\ s \end{array} \right) p^{s}(1p)^{is}} 
...
Look at the denominator, and substituting j = i+1 gives:
LaTeX Math Block  


since
...
 
\displaystyle\sum_{i=s}^{\infty}\left( \begin{array}{c} i \\ s \end{array} \right) p^{s}(1p)^{is} = \displaystyle\sum_{j=s+1}^{\infty}\left( \begin{array}{c} j1 \\ s \end{array} \right) p^{s}(1p)^{js1}=\bigg( \frac{1}{p}\bigg).\displaystyle\sum_{j=s+1}^{\infty}\left( \begin{array}{c} j1 \\ s \end{array} \right) p^{s+1}(1p)^{js1}=\bigg(\frac{1}{p}\bigg) 
since
LaTeX Math Block  

 
\left( \begin{array}{c} j1 \\ s \end{array} \right) p^{s+1}(1p)^{js1} 
is the probability mass function for the NegBinomial(s+1,p) distribution for j and therefore sums to 1. The posterior distribution then reduces to:
LaTeX Math Block  


...
 
f(x \mid X)=\left( \begin{array}{c} x \\ s \end{array} \right) p^{s+1}(1p)^{xs} 
For x = y  1:
LaTeX Math Block  

 
f(y \mid X)=\left( \begin{array}{c} y1 \\ s \end{array} \right) p^{s+1}(1p)^{ys1} 
i.e. y = NegBinomial(p,s+1), and therefore x = NegBinomial(p,s+1) 1 distribution.
...
.
...