Hi guys!

I have a problem calling the numpy.random.hypergeometric function with certain values. It seems like if the values hit in some certain range the program stalls and never finishes. I get no errors or anything and also a wxpython GUI that i have calling this function crashes with no error messages.

My operating system is Vista, Python version 2.6 and the latest NumPy version(and SciPy).

Any idea what causes this?

Here's an example:

from numpy.random import hypergeometric

print hypergeometric(10000, 10000, 10000) #Works fine
print hypergeometric(100000, 1000000, 100000) #Works fine
print hypergeometric(10000000, 1000000000, 1000000) #Works fine

print hypergeometric(1000000, 10000000, 100000) #Doesn't work
6 Years
Discussion Span
Last Post by justaguy101

Interesting, you must have hit a gap in the algorithm. I tested it out and came up with these results ...

# numpy.random.hypergeometric(ngood, nbad, nsample, size=None)

import numpy as np

# these work fine
print np.random.hypergeometric(10000, 10000, 10000)
print np.random.hypergeometric(100000, 1000000, 100000)
print np.random.hypergeometric(10000000, 1000000000, 1000000)

# these freeze up
#print np.random.hypergeometric(1000000, 10000000, 100000)
#print np.random.hypergeometric(1000000/10, 10000000/10, 100000/10)
#print np.random.hypergeometric(1000000*10, 10000000*10, 100000*10)
#print np.random.hypergeometric(1000000*100, 10000000*100, 100000*100)

# this works again
# would it give meaningful data?
print np.random.hypergeometric(1000000/100, 10000000/100, 100000/100)*100

Thanks for testing, at least now i know it's not anything related to versions or system.

I'm actually using that hypergeometric function to get multivariate hypergeometric distribution. I guess i have to come up with some sort of a work-around...

Do you have any idea if there is some other maths libraries with statistical functions like that?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.