# [SciPy-user] How to call hypergeometric cdf

Arnar Flatberg arnar.flatberg@gmail....
Thu Feb 14 05:49:42 CST 2008

```Hi list

I am having some troubles understanding how to call the hypergeometric
distribution from the stats module.
The probability mass function works great (stats.hypergeom.pmf),
however the cdf (and cf, ppf and isf) complains on the way it is
called.
Am I calling the cdf correct? I find the documentation a little bit sparse :-)

Setup:
Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
>>> import scipy
>>> scipy.__version__
'0.6.0'

Example:
#----------------
import scipy
from scipy import stats

# Hypergeometric example paramters
m = 5 # number of white balls in urn
n = 5 # number of black balls in urn
N = 5 # number of balls drawn from urn
x = 4 # number of white balls in drawn
# x = scipy.arange(1,5)

# the pmf works:
stats.hypergeom.pmf(x, m+n, m, N)

# the cdf does not
stats.hypergeom.cdf(x, m+n, m, N)
#------------------

/usr/lib/python2.5/site-packages/scipy/stats/distributions.py in
cdf(self, k, *args, **kwds)
3546         place(output,cond2*(cond0==cond0), 1.0)
3547         goodargs = argsreduce(cond, *((k,)+args))
-> 3548         place(output,cond,self._cdf(*goodargs))
3549         return output
3550

/usr/lib/python2.5/site-packages/scipy/stats/distributions.py in
_cdf(self, x, *args)
3455     def _cdf(self, x, *args):
3456         k = floor(x)
-> 3457         return self._cdfvec(k,*args)
3458
3459     def _sf(self, x, *args):

/usr/lib/python2.5/site-packages/numpy/lib/function_base.py in
__call__(self, *args)
949         if self.nin:
950             if (nargs > self.nin) or (nargs < self.nin_wo_defaults):
--> 951                 raise ValueError, "mismatch between python
function inputs"\
952                       " and received arguments"
953

<type 'exceptions.ValueError'>: mismatch between python function
inputs and received arguments

Thanks,

Arnar
```