}
public static double incompleteBetaFunction(final double a, final double b, final double x, final double accuracy,
final Integer maxIteration) {
final GammaFunction gf = new GammaFunction();
QL.require(a > 0.0 , "a must be greater than zero"); // QA:[RG]::verified // TODO: message
QL.require(b > 0.0 , "b must be greater than zero"); // QA:[RG]::verified // TODO: message
if (x == 0.0)
return 0.0;
else if (x == 1.0)
return 1.0;
else
if (x<0.0 || x>1.0)
throw new ArithmeticException("x must be in [0,1]");
final double result = Math.exp(gf.logValue(a+b) - gf.logValue(a) - gf.logValue(b) + a*Math.log(x) + b*Math.log(1.0-x));
if (x < (a+1.0)/(a+b+2.0))
return result * betaContinuedFraction(a, b, x, accuracy, maxIteration)/a;
else
return 1.0 - result * betaContinuedFraction(b, a, 1.0-x, accuracy, maxIteration)/b;