R-alpha: Bug & Patch in dbeta.c (0.50 - PreR 7)

Thomas Lumley thomas@biostat.washington.edu
Tue, 15 Apr 1997 13:02:55 -0700 (PDT)


On Tue, 15 Apr 1997, Martin Maechler wrote:

> dbeta(1, a,b)  would return 1 instead of 0.

Shouldn't it be 1 for b=1, Inf for b<1 and 0 for b>1 at x=1 (and similar
behaviour at x=0)?

ie 
double dbeta(double x, double a, double b)
{
        if (a <= 0.0 || b <= 0.0)
                DOMAIN_ERROR;
        if (x < 0)
                return 0.0;
        if (x > 1.0)
                return 0.0;
        return MATH_CHECK(pow(x, a - 1) * pow(1.0 - x, b - 1.0) / beta(a,
b));
}




Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

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