[Numpy-discussion] random.hypergeometric bug

Robert Kern robert.kern@gmail....
Mon Dec 3 00:43:59 CST 2007


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


More information about the Numpy-discussion mailing list