Given a container of
n_{1} objects of type
1 and
n_{2} objects of type
2, the probability of drawing
k objects of type
1 when a total of
n objects are drawn at random without replacement is
f(k) =  C^{n1}_{k} C^{n2}_{nk} / C^{n1+n2}_{n}  for k = 0,...,min(n_{1},n)  0  elsewhere 


The cumulative hypergeometric distribution function is therefore given
where
f is given above.
 double Hypergeometric_Cumulative_Distribution( int n1, int n2, int n, int k )
This function returns F(k) where F(k) is described above.
 double Hypergeometric_Point_Distribution( int n1, int n2, int n, int k )
This function returns f(k) where f(k) is described above.
 void Hypergeometric_Distribution_Tables( int n1, int n2, int n, double* pr, double* cumulative )
This function returns f(k) where f(k) is described above for k = 0,...,n in the array pr and returns F(k) where F(k) is described above for k = 0,...,n in the array cumulative.
C source code is available for these routines: