[Rd] Bug in qbinom? (PR#511)

Thomas Lumley thomas@biostat.washington.edu
Fri, 7 Apr 2000 09:10:59 -0700 (PDT)


On Fri, 7 Apr 2000 dtrenkler@nts6.oec.uni-osnabrueck.de wrote:

> n_10;p_0.5;jjx_0:n;qbinom(pbinom(jjx,n,p),n,p) #  This one works as
> expected
> 
> n_100;p_0.5;jjx_0:n;qbinom(pbinom(jjx,n,p),n,p)  # This one causes
> severe problems


In qbinom  we calculate an estimate y based on a Cornish-Fisher expansion
and then search up or down to the right number.  However, for p=1-1e-16 or
thereabouts we get

y=83931130944911952

which is bigger than 1/machine epsilon.  Thus y=y-1 and searching up or
down doesnt work.  A crude solution is to just treat this as p=1, but it
would be better to search up or down in bigger steps.

	-thomas


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