[SciPy-dev] possible bug in numpy.random.zipf

Alan Jackson alan@ajackson....
Tue Jul 8 19:46:53 CDT 2008


I think I may have found a bug in numpy.random.zipf

As I was documenting the zipf function, I started playing with it to create
some examples. It's pretty cool, actually. I had never heard of it
before.

To my surprise, it started giving occasional very large negative numbers as
results whenever the 'a' parameter was less than 1.5. It appears that
there is some numerical instability for parameters less than 1.5.

In [44]: min(np.random.zipf(1.4, 1000))
Out[44]: 1

In [45]: min(np.random.zipf(1.4, 1000))
Out[45]: -2147483648

In [46]: min(np.random.zipf(1.4, 1000))
Out[46]: 1

In [47]: min(np.random.zipf(1.4, 1000))
Out[47]: 1

In [48]: min(np.random.zipf(1.4, 1000))
Out[48]: 1

In [49]: min(np.random.zipf(1.4, 1000))
Out[49]: 1

The minimum value should never be less than 1, I think.

-- 
-----------------------------------------------------------------------
| Alan K. Jackson            | To see a World in a Grain of Sand      |
| alan@ajackson.org          | And a Heaven in a Wild Flower,         |
| www.ajackson.org           | Hold Infinity in the palm of your hand |
| Houston, Texas             | And Eternity in an hour. - Blake       |
-----------------------------------------------------------------------


More information about the Scipy-dev mailing list