Regularized incomplete beta function + continued fraction

Regularized beta function is the CDF of beta distribution. In ms_xls (msoffice 2010) there is a standard method BETA.DIST(x, a, b, TRUE) to calculate the CDF of beta distribution. Now the problem is, this (BETA.DIST()) giving me correct values till the point x >= (a+1) / (a+b+2) but if x < (a+1) / (a+b+2) its not giving me the correct values.

For the underlying calculation of incomplete beta (please refer to http://astronu.jinr.ru/wiki/upload/d...RecipesinC.pdf ) of section 6.4. Here it saying

if x<(a+1) / (a+b+2) use continued fraction directly but if x>=(a+1) / (a+b+2) use continued fraction after using symmetric transformation.

DETA.DIST() of xls always calculate CDF (cumulative distribution function) assuming that x >= (a+1) / (a+b+2) (because when x >= (a+1) / (a+b+2) I am getting exactly same value from my system and xls). Now the question / doubt is why there is a correction when x<(a+1) / (a+b+2) (this is not in xls BETA.DIST()). Or is it that incomplete beta is no more a CDF of beta distribution when x < (a+1) / (a+b+2).

Thanks in advance for your reply.

Regards

Deepak

////// This method is copied from "NumericalRecipesinC"//////////// section 6.4

Returns the incomplete beta function Ix(a, b).

{

float betacf(float a, float b, float x);

float gammln(float xx);

void nrerror(char error_text[]);

float bt;

if (x < 0.0 || x > 1.0) nrerror("Bad x in routine betai");

if (x == 0.0 || x == 1.0)

bt=0.0;

else Factors in front of the continued fraction.

bt=exp(gammln(a+b)-gammln(a)-gammln(b)+a*log(x)+b*log(1.0-x));

if (x < (a+1.0)/(a+b+2.0)) Use continued fraction directly.

return bt*betacf(a,b,x)/a;

else Use continued fraction after making the symmetry transformation.

return 1.0-bt*betacf(b,a,1.0-x)/b;

}