code: public static double sigLevelByApproxRand(double[] A, double[] B, int iterations) {
      if (A.length == 0)
        throw new IllegalArgumentException("Input arrays must not be empty!");
      if (A.length != B.length)
        throw new IllegalArgumentException("Input arrays must have equal length!");
      if (iterations <= 0)
        throw new IllegalArgumentException("Number of iterations must be positive!");
      double testStatistic = absDiffOfMeans(A, B, false); // not randomized
      int successes = 0;
      for (int i = 0; i < iterations; i++) {
        double t =  absDiffOfMeans(A, B, true); // randomized
        if (t >= testStatistic) successes++;
      }
      return (double) (successes + 1) / (double) (iterations + 1);
    }
docs: Takes a pair of arrays, A and B, which represent corresponding
  outcomes of a pair of random variables: say, results for two different
  classifiers on a sequence of inputs.  Returns the estimated
  probability that the difference between the means of A and B is not
  significant, that is, the significance level.  This is computed by
  "approximate randomization".  The test statistic is the absolute
  difference between the means of the two arrays.  A randomized test
  statistic is computed the same way after initially randomizing the
  arrays by swapping each pair of elements with 50% probability.  For
  the given number of iterations, we generate a randomized test
  statistic and compare it to the actual test statistic.  The return
  value is the proportion of iterations in which a randomized test
  statistic was found to exceed the actual test statistic.
  
  @param A Outcome of one r.v.
  @param B Outcome of another r.v.
  @return Significance level by randomization