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

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.