public static double regularizedIncBeta(double x,double alpha,double beta){
  if (alpha <= 0.0 || beta <= 0.0 || Double.isNaN(alpha) || Double.isNaN(beta) || Double.isNaN(x)) {
    return Double.NaN;
  }
  if (x <= 0.0) {
    return 0.0;
  }
  if (x >= 1.0) {
    return 1.0;
  }
  if (alpha > SWITCH && beta > SWITCH) {
    return regularizedIncBetaQuadrature(alpha,beta,x);
  }
  double bt=Math.exp(-logBeta(alpha,beta) + alpha * Math.log(x) + beta * Math.log1p(-x));
  if (x < (alpha + 1.0) / (alpha + beta + 2.0)) {
    return bt * regularizedIncBetaCF(alpha,beta,x) / alpha;
  }
 else {
    return 1.0 - bt * regularizedIncBetaCF(beta,alpha,1.0 - x) / beta;
  }
}

public static double regularizedIncBeta ( double x , double alpha , double beta ) { if ( alpha <= 0.0 || beta <= 0.0 || Double . isNaN ( alpha ) || Double . isNaN ( beta ) || Double . isNaN ( x ) ) { return Double . NaN ; } if ( x <= 0.0 ) { return 0.0 ; } if ( x >= 1.0 ) { return 1.0 ; } if ( alpha > SWITCH && beta > SWITCH ) { return regularizedIncBetaQuadrature ( alpha , beta , x ) ; } double bt = Math . exp ( - logBeta ( alpha , beta ) + alpha * Math . log ( x ) + beta * Math . log1p ( - x ) ) ; if ( x < ( alpha + 1.0 ) / ( alpha + beta + 2.0 ) ) { return bt * regularizedIncBetaCF ( alpha , beta , x ) / alpha ; } else { return 1.0 - bt * regularizedIncBetaCF ( beta , alpha , 1.0 - x ) / beta ; } }
computes the regularized incomplete beta function i_x ( a , b ) which is also the cdf of the beta distribution . based on the book " numerical recipes "
