R-beta: Bug in dhyper (and phyper)

Goran Brostrom gb at stat.umu.se
Fri Apr 3 00:47:43 CEST 1998



I think I have found a bug in the function dhyper (R-0.61.2):

R> dhyper(0,3,3,0)
Warning: NAs produced in function "dhyper"
[1] NA

Documentation:

"Usage

dhyper(x, N1, N2, n)

.......

The hypergeometric distribution is used for sampling without replacement. 
It has density 

  p(x) = Choose(N1, x) Choose(N2, n-x) / Choose(N1+N2, n)

for x = 0,...,n"

R> choose(3,0) * choose(3,0) / choose(6,0)
[1] 1

This result is correct, and obviously dhyper is implemented in some way 
not consistent with the documentation.

Also note the spelling error of 'choose' in the documentation.

---
Goran Brostrom                         phone : +46 90 7865223
Department of Statistics                              7865213 (secr)
Umea University                        fax   :        7866614
S-90187 Umea, Sweden                   e-mail: gb at stat.umu.se

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list