code: public static double betaCdf(double x, double a, double b) {
          if(x<0 || a<=0 || b<=0) {
              throw new IllegalArgumentException("All the parameters must be positive.");
          }
          
          double Bcdf = 0.0;
          
          if(x==0) {
              return Bcdf;
          }
          else if (x>=1) {
              Bcdf=1.0;
              return Bcdf;
          }
          
          double S= a + b;
  
          double BT = Math.exp(logGamma(S)-logGamma(b)-logGamma(a)+a*Math.log(x)+b*Math.log(1-x));
          if (x<(a+1.0)/(S+2.0)) {
              Bcdf=BT*betinc(x,a,b);
          } 
          else {
              Bcdf=1.0-BT*betinc(1.0-x,b,a);
          }
  
          return Bcdf;
      }
docs: Calculates the probability from 0 to X under Beta Distribution
  
  @param x
  @param a
  @param b
  @return