code: public static double[] getConfidenceInterval(final double alpha, final int df, final int n, final double std, final double mean) {
          // Create T Distribution with df degrees of freedom
          TDistribution tDist = new TDistribution(df);
          // Calculate critical value
          double critVal = tDist.inverseCumulativeProbability(1.0 - alpha);
          // Calculate confidence interval
          double ci = critVal * std / Math.sqrt(n);
          double lower = mean - ci;
          double upper = mean + ci;
          double[] interval = new double[]{lower, upper};
          return interval;
      }
docs: Adapted from https://gist.github.com/gcardone/5536578.
  
  @param alpha probability of incorrectly rejecting the null hypothesis (1
  - confidence_level)
  @param df degrees of freedom
  @param n number of observations
  @param std standard deviation
  @param mean mean
  @return array with the confidence interval: [mean - margin of error, mean
  + margin of error]