code: private static double approxBinomialCdf(int k, double p, int n) {
          //use an approximation as described at http://www.math.ucla.edu/~tom/distributions/binomial.html
          double Z = p;
          double A=k+1;
          double B=n-k;
          double S=A+B;
          double BT=Math.exp(ContinuousDistributions.logGamma(S)-ContinuousDistributions.logGamma(B)-ContinuousDistributions.logGamma(A)+A*Math.log(Z)+B*Math.log(1-Z));
          
          double probabilitySum;
          if (Z<(A+1)/(S+2)) {
              probabilitySum=BT*ContinuousDistributions.betinc(Z,A,B);
          } 
          else {
              probabilitySum=1.0-BT*ContinuousDistributions.betinc(1.0-Z,B,A);
          }
          probabilitySum=1.0-probabilitySum;
  
          return probabilitySum;
      }
docs: Returns the a good approximation of cumulative probability of k of a specific number of tries n and probability p
  
  @param k
  @param p
  @param n
  @return