From p.dalgaard@biostat.ku.dk  Fri Mar 24 16:32:37 2000
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 24 Mar 2000 17:32:37 +0100
Subject: [Rd] quantiles of the hypergeometric distribution (PR#502)
In-Reply-To: Thomas Lumley's message of "Fri, 24 Mar 2000 08:10:38 -0800 (PST)"
References: <Pine.GSO.4.21.0003240807090.2323-100000@mail.biostat.washington.edu>
Message-ID: <x2r9d0wcpm.fsf@blueberry.kubism.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)
Peter Dalgaard BSA