[Numpy-discussion] random.hypergeometric bug

2007-12-02 Thread Chris
There appears to be a bug in numpy's hypergeometric
random number generator. Here is an example -- if I 
generate 1000 hg samples with 4 draws from a space
with 30 successes and 10 failures:

In [39]: x = hg(30, 10, 4, 1000)

I should get a mean value of:

In [40]: 4*30./40
Out[40]: 3.0

But the sample mean is way to small:

In [41]: mean(x)
Out[41]: 0.996



___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] random.hypergeometric bug

2007-12-02 Thread Robert Kern
Chris wrote:
 There appears to be a bug in numpy's hypergeometric
 random number generator. Here is an example -- if I 
 generate 1000 hg samples with 4 draws from a space
 with 30 successes and 10 failures:
 
 In [39]: x = hg(30, 10, 4, 1000)
 
 I should get a mean value of:
 
 In [40]: 4*30./40
 Out[40]: 3.0
 
 But the sample mean is way to small:
 
 In [41]: mean(x)
 Out[41]: 0.996

Fixed in r4527. My original source for the algorithm was incorrect, it seems.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion