From p.dalgaard@biostat.ku.dk  Fri Mar 24 16:29:06 2000
From: p.dalgaard@biostat.ku.dk (p.dalgaard@biostat.ku.dk)
Date: Fri, 24 Mar 2000 17:29:06 +0100 (MET)
Subject: [Rd] quantiles of the hypergeometric distribution (PR#502)
Message-ID: <200003241629.RAA05692@pubhealth.ku.dk>

Thomas Lumley <thomas@biostat.washington.edu> writes:

> As phyper seems to work we could just start at the Normal approximation to
> qhyper and search for x such  that phyper(x)=p. Since it's a discrete
> distribution this shouldn't take that long.

Or apply the same fixup:

        sum += (small_N ? term : exp(term));
        ...
        if(small_N) term *= (NR / xr) * (xb / NB);
        else    term += log((NR / xr) * (xb / NB));

which is pretty obviously not optimized for speed, but certainly
avoids the multiply-by-zero effect.

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

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] quantiles of the hypergeometric distribution (PR#502)
p.dalgaard@biostat.ku.dk