[Numpy-discussion] numpy.random.hypergeometric - strange results

joep josef.pktd@gmail....
Thu Sep 25 15:18:06 CDT 2008


In my fuzz testing of scipy stats, I get sometimes a test failure. I
think there is something
wrong with numpy.random.hypergeometric for some cases:

Josef

>>> import numpy.random as mtrand
>>> mtrand.hypergeometric(3,17,12,size=10)   # there are only 3 good balls in urn
array([16, 17, 16, 16, 15, 16, 17, 16, 17, 16])
>>> mtrand.hypergeometric(17,3,12,size=10)   #negative result
array([-3, -4, -3, -4, -3, -3, -4, -4, -5, -4])
>>> mtrand.hypergeometric(4,3,12,size=10)

>>> np.version.version
'1.2.0rc2'

I did not find any clear pattern when trying out different parameter
values:

>>> mtrand.hypergeometric(10,10,12,size=10)
array([5, 6, 4, 4, 8, 5, 4, 6, 7, 4])
>>> mtrand.hypergeometric(10,10,20,size=10)
array([10, 10, 10, 10, 10, 10, 10, 10, 10, 10])
>>> mtrand.hypergeometric(10,10,19,size=10)
array([10,  9,  9,  9,  9,  9, 10,  9,  9,  9])
>>> mtrand.hypergeometric(10,10,5,size=10)
array([3, 5, 2, 2, 1, 2, 2, 4, 3, 1])
>>> mtrand.hypergeometric(10,2,5,size=10)
array([4, 5, 4, 5, 5, 5, 4, 3, 4, 4])
>>> mtrand.hypergeometric(2,10,5,size=10)
array([0, 2, 1, 0, 2, 2, 1, 1, 1, 1])

>>> mtrand.hypergeometric(17,3,12,size=10)
array([-5, -3, -4, -4, -4, -3, -4, -4, -3, -3])
>>> mtrand.hypergeometric(3,17,12,size=10)
array([15, 16, 17, 16, 15, 16, 15, 15, 17, 17])
>>> mtrand.hypergeometric(18,3,12,size=10)
array([-5, -6, -6, -4, -4, -4, -5, -3, -5, -5])

>>> mtrand.hypergeometric(18,3,5,size=10)
array([4, 5, 5, 5, 5, 5, 4, 5, 4, 3])
>>> mtrand.hypergeometric(18,3,19,size=10)
array([1, 1, 2, 1, 1, 1, 1, 3, 1, 1])


More information about the Numpy-discussion mailing list