Program: 180742
Project: 180742
Buggy source:
private void gatherFitnessStats(Map<GenerationStatField,Object> stats,List<CandidateProgram<TYPE>> pop){
  if (stats.containsKey(GenerationStatField.FITNESS_AVE) || stats.containsKey(GenerationStatField.FITNESS_STDEV) || stats.containsKey(GenerationStatField.FITNESS_MAX)|| stats.containsKey(GenerationStatField.FITNESS_MIN)|| stats.containsKey(GenerationStatField.FITNESS_MEDIAN)|| stats.containsKey(GenerationStatField.BEST_PROGRAM)|| stats.containsKey(GenerationStatField.FITNESS_CI_95)) {
    double[] fitnesses=new double[pop.size()];
    for (int i=0; i < pop.size(); i++) {
      fitnesses[i]=pop.get(i).getFitness();
    }
    int maxIndex=-1;
    int minIndex=-1;
    double stdev=-1;
    if (stats.containsKey(GenerationStatField.FITNESS_AVE)) {
      stats.put(GenerationStatField.FITNESS_AVE,Double.toString(ave(fitnesses)));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_STDEV)) {
      stdev=stdev(fitnesses);
      stats.put(GenerationStatField.FITNESS_STDEV,Double.toString(stdev));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_MAX)) {
      maxIndex=maxIndex(fitnesses);
      stats.put(GenerationStatField.FITNESS_MAX,Double.toString(fitnesses[maxIndex]));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_MIN)) {
      stats.put(GenerationStatField.FITNESS_MIN,Double.toString(min(fitnesses)));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_MEDIAN)) {
      stats.put(GenerationStatField.FITNESS_MEDIAN,Double.toString(median(fitnesses)));
    }
    if (stats.containsKey(GenerationStatField.BEST_PROGRAM)) {
      if (minIndex == -1) {
        minIndex=minIndex(fitnesses);
      }
      stats.put(GenerationStatField.BEST_PROGRAM,pop.get(minIndex));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_CI_95)) {
      if (stdev == -1) {
        stdev=stdev(fitnesses);
      }
      double ci=1.96 * (stdev / Math.sqrt(fitnesses.length));
      stats.put(GenerationStatField.FITNESS_CI_95,Double.toString(ci));
    }
  }
}

Fixed version (ground truth):
private void gatherFitnessStats(Map<GenerationStatField,Object> stats,List<CandidateProgram<TYPE>> pop){
  if (stats.containsKey(GenerationStatField.FITNESS_AVE) || stats.containsKey(GenerationStatField.FITNESS_STDEV) || stats.containsKey(GenerationStatField.FITNESS_MAX)|| stats.containsKey(GenerationStatField.FITNESS_MIN)|| stats.containsKey(GenerationStatField.FITNESS_MEDIAN)|| stats.containsKey(GenerationStatField.BEST_PROGRAM)|| stats.containsKey(GenerationStatField.FITNESS_CI_95)) {
    double[] fitnesses=new double[pop.size()];
    for (int i=0; i < pop.size(); i++) {
      fitnesses[i]=pop.get(i).getFitness();
    }
    int maxIndex=-1;
    int minIndex=-1;
    double stdev=-1;
    if (stats.containsKey(GenerationStatField.FITNESS_AVE)) {
      stats.put(GenerationStatField.FITNESS_AVE,new Double(ave(fitnesses)));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_STDEV)) {
      stdev=stdev(fitnesses);
      stats.put(GenerationStatField.FITNESS_STDEV,new Double(stdev));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_MAX)) {
      maxIndex=maxIndex(fitnesses);
      stats.put(GenerationStatField.FITNESS_MAX,new Double(fitnesses[maxIndex]));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_MIN)) {
      stats.put(GenerationStatField.FITNESS_MIN,new Double(min(fitnesses)));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_MEDIAN)) {
      stats.put(GenerationStatField.FITNESS_MEDIAN,new Double(median(fitnesses)));
    }
    if (stats.containsKey(GenerationStatField.BEST_PROGRAM)) {
      if (minIndex == -1) {
        minIndex=minIndex(fitnesses);
      }
      stats.put(GenerationStatField.BEST_PROGRAM,pop.get(minIndex));
    }
    if (stats.containsKey(GenerationStatField.FITNESS_CI_95)) {
      if (stdev == -1) {
        stdev=stdev(fitnesses);
      }
      double ci=1.96 * (stdev / Math.sqrt(fitnesses.length));
      stats.put(GenerationStatField.FITNESS_CI_95,new Double(ci));
    }
  }
}