From p.dalgaard at biostat.ku.dk  Fri May  2 01:20:06 2003
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard BSA)
Date: Fri May  2 00:16:35 2003
Subject: [Rd] qbeta hang (PR#2894)
In-Reply-To: <200305012044.h41Ki02b017789@pubhealth.ku.dk>
References: <200305012044.h41Ki02b017789@pubhealth.ku.dk>
Message-ID: <x265oujomh.fsf@biostat.ku.dk>

terra@gnome.org writes:

> Full_Name: Morten Welinder
> Version: 1.6.1
> OS: Solaris/sparc
> Submission from: (NULL) (65.213.85.144)
> 
> 
> qbeta(0.1, 1e-8, 0.5, TRUE, FALSE) seems to hang for me.

confirmed on 1.7.0 Solaris 9, gcc 3.0.3 (standard build, so -O2, I assume)

Morten: the gcc version is often crucial in these cases.

However, the exact same thing is happening on Linux. The immediate
cause is that n = fmax2(lneps/log(y), 4.0) gets large when y is in the
vicinity of 1-1e-8, so the loop in src/nmath/pbeta.c:101 gets a rather
high count. The algorithm isn't really stuck, it just takes a very
long time. On the fastest machine that I have available:

> system.time(qbeta(0.1, 1e-8, 0.5, TRUE, FALSE))
[1] 75.58  0.00 75.58  0.00  0.00


It's not really that surprising:

> pbeta(1e-5, 1e-8, 0.5,, TRUE, FALSE)
[1] 0.9999999
> pbeta(1e-10, 1e-8, 0.5,, TRUE, FALSE)
[1] 0.9999998
> pbeta(1e-200, 1e-8, 0.5,, TRUE, FALSE)
[1] 0.9999954
> pbeta(1e-309, 1e-8, 0.5,, TRUE, FALSE)
[1] 0.999993
> pbeta(1e-400, 1e-8, 0.5,, TRUE, FALSE)
[1] 0

and you're trying to solve pbeta(x, 1e-8, 0.5,, TRUE, FALSE) == 0.1


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


[Rd] qbeta hang (PR#2894)
Peter Dalgaard BSA