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.
////// 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);
if (x < 0.0 || x > 1.0) nrerror("Bad x in routine betai");
if (x == 0.0 || x == 1.0)
else Factors in front of the continued fraction.
if (x < (a+1.0)/(a+b+2.0)) Use continued fraction directly.
else Use continued fraction after making the symmetry transformation.