---
title: "Number of samples to get a specific s"
canonical: "https://modelassist.epixanalytics.com/space/EA/26574989/Number%20of%20samples%20to%20get%20a%20specific%20s"
format: markdown
---
Consider the situation where we are sampling without replacement from a population *M* with *D* items with the characteristic of interest until we have *s* items with the required characteristic. The distribution of the number of trials we will need to get *s* success can be easily calculated in the same manner as we developed the [Negative Binomial](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575213/) distribution. The probability of observing (*s*-1) successes in (*x*-1) trials (i.e. we have had (x-1) - (s-1) = x -s failures) is given by direct application of the Hypergeometric distribution:

![image](media://35550a07-a287-4e24-a579-cdf573760b50)

  


> Macro (mathblock)

  


The probability *p* of then observing a success in the next trial (the *x*th trial), is simply the number of *D* items remaining (=*D*-(*s*-1)= D-s+1) divided by the size of the population remaining (= *M*-(*x*-1)=M-x+1):

![image](media://a17109fc-2f79-4219-98b1-4d53104467dd)

  


> Macro (mathblock)

  


and the probability of needing exactly *x* trials to obtain *s* success, where trials are stopped at the *s*th success, is then the product of these two probabilities:

![image](media://b6370727-0a2c-4d9b-8d54-03a1e74abd58)

  


> Macro (mathblock)

  


This is the probability mass function for the [Inverse Hypergeometric](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575210/) distribution InvHyperGeo(*s,D,M*) and is analogous to the [Negative Binomial](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575213/) distribution for the [binomial process](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26574972/) and the [Gamma](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575231/) distribution for the [Poisson process](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26574979/). So:

  


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

  


For a population *M* that is large compared to *s*, [the Inverse Hypergeometric distribution is closely approximated](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575263/) by the Negative Binomial:

  


InvHypergeo(*s,D,M*) *»* NegBinomial(*D*/*M,s*)

  


and if the probability *D*/*M* is very small:

  


InvHypergeo(*s,D,M*) *»* Gamma(s,*M*/*D,s*)

  


The four figures below show examples of the Inverse Hypergeometric distribution. In the first figure you can see the probability mass function of the number of trials needed for getting 4 successes when drawing samples from a population 50 in which 5 individuals have the characteristic you are interested in. We leave to you the task to explain in words the figures 2 – 4.

  


![image](media://1fcbda38-536b-4022-8528-7d5cfc4305da)

  


An Inverse Hypergeometric distribution is sometimes called a *Negative Hypergeometric* distribution.

  


  


  


---