protected static double regularizedIncBetaCF(double alpha,double beta,double x){
  final double FPMIN=Double.MIN_VALUE / NUM_PRECISION;
  double qab=alpha + beta;
  double qap=alpha + 1.0;
  double qam=alpha - 1.0;
  double c=1.0;
  double d=1.0 - qab * x / qap;
  if (Math.abs(d) < FPMIN) {
    d=FPMIN;
  }
  d=1.0 / d;
  double h=d;
  for (int m=1; m < 10000; m++) {
    int m2=2 * m;
    double aa=m * (beta - m) * x / ((qam + m2) * (alpha + m2));
    d=1.0 + aa * d;
    if (Math.abs(d) < FPMIN) {
      d=FPMIN;
    }
    c=1.0 + aa / c;
    if (Math.abs(c) < FPMIN) {
      c=FPMIN;
    }
    d=1.0 / d;
    h*=d * c;
    aa=-(alpha + m) * (qab + m) * x / ((alpha + m2) * (qap + m2));
    d=1.0 + aa * d;
    if (Math.abs(d) < FPMIN) {
      d=FPMIN;
    }
    c=1.0 + aa / c;
    if (Math.abs(c) < FPMIN) {
      c=FPMIN;
    }
    d=1.0 / d;
    double del=d * c;
    h*=del;
    if (Math.abs(del - 1.0) <= NUM_PRECISION) {
      break;
    }
  }
  return h;
}

protected static double regularizedIncBetaCF ( double alpha , double beta , double x ) { final double FPMIN = Double . MIN_VALUE / NUM_PRECISION ; double qab = alpha + beta ; double qap = alpha + 1.0 ; double qam = alpha - 1.0 ; double c = 1.0 ; double d = 1.0 - qab * x / qap ; if ( Math . abs ( d ) < FPMIN ) { d = FPMIN ; } d = 1.0 / d ; double h = d ; for ( int m = 1 ; m < 10000 ; m ++ ) { int m2 = 2 * m ; double aa = m * ( beta - m ) * x / ( ( qam + m2 ) * ( alpha + m2 ) ) ; d = 1.0 + aa * d ; if ( Math . abs ( d ) < FPMIN ) { d = FPMIN ; } c = 1.0 + aa / c ; if ( Math . abs ( c ) < FPMIN ) { c = FPMIN ; } d = 1.0 / d ; h *= d * c ; aa = - ( alpha + m ) * ( qab + m ) * x / ( ( alpha + m2 ) * ( qap + m2 ) ) ; d = 1.0 + aa * d ; if ( Math . abs ( d ) < FPMIN ) { d = FPMIN ; } c = 1.0 + aa / c ; if ( Math . abs ( c ) < FPMIN ) { c = FPMIN ; } d = 1.0 / d ; double del = d * c ; h *= del ; if ( Math . abs ( del - 1.0 ) <= NUM_PRECISION ) { break ; } } return h ; }
returns the regularized incomplete beta function i_x ( a , b ) includes the continued fraction way of computing , based on the book " numerical recipes " .
