Of course ! (--- silly me) S-plus actually always returns 0 here; but your solution is mathematically correct where S is NOT! The "bad" thing about R is only that we still don't have IEEE arithmetic. Will get 'NA' instead of 'Inf' ... Thomas Lumley :
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));
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 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 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-