The Inverse Hypergeometric distribution was derived in the previous topic as a probability distribution, predicting the number of trials one needs to take to get s success. However, it can equally be derived as a distribution of uncertainty about the number of trials *x* one must have taken if one knows *s*, *M*, *D* using Bayes' Theorem and a Uniform (i.e. uninformed) prior on *x*. So:

*n* = InvHypergeo(*s*,*D*,*M*)

In the case where you do *not* know that the trials had stopped with the *s*th success, we can still apply Bayes' Theorem with a uniform prior for *x* and a likelihood function given by a hypergeometric probability:

l(X \mid x)=\frac{\left( \begin{array}{c} D \\ s \end{array} \right) \left( \begin{array}{c} M-D \\ x-s \end{array} \right)}{\left( \begin{array}{c} M \\ x \end{array} \right) } \propto \frac{ \left( \begin{array}{c} M-D \\ x-s \end{array} \right)}{\left( \begin{array}{c} M \\ x \end{array} \right) } |

which, with a Uniform prior, is also the posterior distribution:

f(x)\propto \frac{x!(M-x)!}{(x-s)!(M-D-x+s)!} |

The equation above has dropped out all the terms that are not a function of x and so can be normalized out of the equation. The uncertainty distribution for x does not equate to a standard distribution, so it needs to be manually normalized. However, it is easier just to work with the equation above and normalize in the spreadsheet. The figure below shows an example of such a calculation where the final distribution is in Cell G18. Note that if one uses Crystal Ball's Custom distribution to create a Discrete distribution as shown in this spreadsheet, it is actually unnecessary to normalize the probabilities, since software like Crystal Ball automatically normalizes them to sum to unity.