[Rd] rhyper has too high variance (PR#7314)

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Oct 27 12:12:16 CEST 2004


murdoch at stats.uwo.ca writes:

> On Tue, 26 Oct 2004 13:38:21 +0200 (CEST), oehl_list at gmx.de wrote :
> 
> >
> >Dear all,
> >
> >it looks like rhyper() gives wrong results compared to theory and compared
> >to sample() and rghyper(SuppDists).
> 
> I agree, these results look wrong.  The mean also seems high:

Yup, and inconsistent with phyper and dhyper (which is a good thing I
suppose)

> mean(rhyper(1e5,100,60,50))
[1] 31.47707
> sum(phyper(0:50,100,60,50,lower=F))
[1] 31.25
> sum(0:50*dhyper(0:50,100,60,50))
[1] 31.25

Looks like the effect is not due to the choice of random number
generator:

> RNGkind("Super-Duper")
> mean(rhyper(1e5,100,60,50))
[1] 31.45755



-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-devel mailing list