Ejemplo n.º 1
0
  public static void main(String[] args) {

    Statistic s = new Statistic("Number Of Trials Until All Matches Found");
    MatchProblem m = new MatchProblem(365);
    int numReplications = 100000;
    for (int i = 1; i <= numReplications; i++) {
      m.initialize();
      s.collect(m.getNumberOfTrialsUntilAllMatch());
    }

    System.out.println(s);
  }
Ejemplo n.º 2
0
 public double computeMetricValue(Statistic stat) {
   double[] data = stat.getSavedData();
   Arrays.sort(data);
   int size = data.length;
   double median = -1;
   if (size % 2 == 0) { // even
     int firstIndex = (size / 2) - 1;
     int secondIndex = firstIndex + 1;
     double firstValue = data[firstIndex];
     double secondValue = data[secondIndex];
     median = (firstValue + secondValue) / 2;
   } else { // odd
     int index = (int) Math.ceil(size / 2);
     median = data[index];
   }
   return median;
 }