Hypergeometric distribution

Travis E. Oliphant oliphant.travis at ieee.org
Tue Jan 3 07:36:30 CET 2006

Raven wrote:
> Thanks Steven for your very interesting post.
> This was a critical instance from my problem:
>>>>from scipy import comb
> inf
> The scipy.stats.distributions.hypergeom function uses the scipy.comb
> function, so it returned nan since it tries to divide an infinite. I
> did not tried to write a self-made function using standard python as I
> supposed that the scipy functions reached python's limits but I was
> wrong, what a fool :-)

Notice the keyword for the comb function (in scipy) lets you use it to 
compute exact values.   SciPy does not just automatically use the long 
integer because this will always slow you down.

comb(N, k, exact=0)

Combinations of N things taken k at a time.

If exact==0, then floating point precision is used, otherwise
exact long integer is computed.

   - Array arguments accepted only for exact=0 case.
   - If k > N, N < 0, or k < 0, then a 0 is returned.

-Travis Oliphant

More information about the Python-list mailing list