[Rd] quantiles of the hypergeometric distribution (PR#502)
Torsten Hothorn
hothorn@ci.tuwien.ac.at
Fri, 24 Mar 2000 14:40:13 +0100 (CET)
> Hello!
>
> I use R-version 1.0.0
> To get the 0.95 quantile of the hypergeometric
> distribution with the parameters m=45000,n=5000 and
> k=600 I use the R-command
>
> > qhyper(0.95,45000,5000,600).
>
>
> The value obtained is 600. However, the true value
> is 552.
Well,
had a short look. The problem arises in qhyper.c at line 56:
term = exp(lfastchoose(NR, xr) + lfastchoose(NB, xb) - lfastchoose(N, n));
The expression inside the exp() function gives -1415.411856 and exp()
returns 0. So term and sum in
while(sum < p && xr < xend) {
xr++;
NB++;
term *= (NR / xr) * (xb / NB);
sum += term;
xb--;
NR--;
}
are 0 all the time and xend = 600 is returned.
R-Core: How to fix this?
Torsten
*****************************************************************
* *
* Torsten Hothorn, Statistician *
* at the moment: Institut fuer Statistik, TU Wien *
* Tel: 0043 1 58801 10772 *
* Fax: 0043 1 58801 10798 *
* *
*****************************************************************
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._