code: public static double studentsCdf(double x, int df) {
          if(df<=0) {
              throw new IllegalArgumentException("The degrees of freedom need to be positive.");
          }
  
          double A = df/2.0;
          double S = A+0.5;
          double Z = df/(df + x*x);
          double BT = Math.exp(logGamma(S)-logGamma(0.5)-logGamma(A)+A*Math.log(Z)+0.5*Math.log(1.0-Z));
          double betacdf;
          if (Z<(A+1.0)/(S+2.0)) {
              betacdf = BT*betinc(Z,A,0.5);
          } 
          else {
              betacdf=1-BT*betinc(1.0-Z,0.5,A);
          }
          
          double tcdf;
          if (x<0) {
              tcdf=betacdf/2.0;
          } 
          else {
              tcdf=1.0-betacdf/2.0;
          }
  
          return tcdf;
      }
docs: Calculates the probability from -INF to X under Student's Distribution
  Ported to PHP from Javascript implementation found at http://www.math.ucla.edu/~tom/distributions/tDist.html
  
  @param x
  @param df
  @return