Program: 117178
Project: 117178
Buggy source:
protected TreeNode createNode(Dataset dataset,int limit,double[] stats){
  boolean stdIs0=getStats(dataset.instances,stats);
  final double totalWeights=stats[0];
  final double sum=stats[1];
  final double weightedMean=stats[2];
  if (stats[0] < limit || stdIs0) {
    RegressionTreeLeaf node=new RegressionTreeLeaf(weightedMean);
    return node;
  }
  double bestEval=Double.POSITIVE_INFINITY;
  List<IntDoublePair> splits=new ArrayList<>();
  List<Attribute> attributes=dataset.instances.getAttributes();
  int[] a=perm.permute().getPermutation();
  Set<Integer> selected=new HashSet<>(numFeatures);
  for (int i=0; i < numFeatures; i++) {
    selected.add(a[i]);
  }
  for (int i=0; i < attributes.size(); i++) {
    Attribute attribute=attributes.get(i);
    if (!selected.contains(i)) {
      continue;
    }
    int attIndex=attribute.getIndex();
    List<IntDoublePair> sortedList=dataset.sortedLists.get(i);
    List<Double> uniqueValues=new ArrayList<>(sortedList.size());
    List<DoublePair> histogram=new ArrayList<>(sortedList.size());
    getHistogram(dataset.instances,sortedList,uniqueValues,totalWeights,sum,histogram);
    if (uniqueValues.size() > 1) {
      DoublePair split=split(uniqueValues,histogram,totalWeights,sum);
      if (split.v2 <= bestEval) {
        IntDoublePair splitPoint=new IntDoublePair(attIndex,split.v1);
        if (split.v2 < bestEval) {
          splits.clear();
          bestEval=split.v2;
        }
        splits.add(splitPoint);
      }
    }
  }
  if (bestEval < Double.POSITIVE_INFINITY) {
    Random rand=Random.getInstance();
    IntDoublePair splitPoint=splits.get(rand.nextInt(splits.size()));
    int attIndex=splitPoint.v1;
    TreeNode node=new TreeInteriorNode(attIndex,splitPoint.v2);
    stats[3]=bestEval + totalWeights * weightedMean * weightedMean;
    return node;
  }
 else {
    RegressionTreeLeaf node=new RegressionTreeLeaf(weightedMean);
    return node;
  }
}

Fixed version (ground truth):
protected TreeNode createNode(Dataset dataset,int limit,double[] stats){
  boolean stdIs0=getStats(dataset.instances,stats);
  final double totalWeights=stats[0];
  final double sum=stats[1];
  final double weightedMean=stats[2];
  if (stats[0] < limit || stdIs0) {
    RegressionTreeLeaf node=new RegressionTreeLeaf(weightedMean);
    return node;
  }
  double bestEval=Double.POSITIVE_INFINITY;
  List<IntDoublePair> splits=new ArrayList<>();
  List<Attribute> attributes=dataset.instances.getAttributes();
  int[] a=perm.permute().getPermutation();
  Set<Integer> selected=new HashSet<>(numFeatures);
  for (int i=0; i < numFeatures; i++) {
    selected.add(a[i]);
  }
  for (int j=0; j < attributes.size(); j++) {
    int attIndex=attributes.get(j).getIndex();
    if (!selected.contains(j)) {
      continue;
    }
    String attName=attributes.get(j).getName();
    List<IntDoublePair> sortedList=dataset.sortedLists.get(attName);
    List<Double> uniqueValues=new ArrayList<>(sortedList.size());
    List<DoublePair> histogram=new ArrayList<>(sortedList.size());
    getHistogram(dataset.instances,sortedList,uniqueValues,totalWeights,sum,histogram);
    if (uniqueValues.size() > 1) {
      DoublePair split=split(uniqueValues,histogram,totalWeights,sum);
      if (split.v2 <= bestEval) {
        IntDoublePair splitPoint=new IntDoublePair(attIndex,split.v1);
        if (split.v2 < bestEval) {
          splits.clear();
          bestEval=split.v2;
        }
        splits.add(splitPoint);
      }
    }
  }
  if (bestEval < Double.POSITIVE_INFINITY) {
    Random rand=Random.getInstance();
    IntDoublePair splitPoint=splits.get(rand.nextInt(splits.size()));
    int attIndex=splitPoint.v1;
    TreeNode node=new TreeInteriorNode(attIndex,splitPoint.v2);
    stats[3]=bestEval + totalWeights * weightedMean * weightedMean;
    return node;
  }
 else {
    RegressionTreeLeaf node=new RegressionTreeLeaf(weightedMean);
    return node;
  }
}