Program: 33066
Project: 33066
Buggy source:
private static List<Interval> generateIntervals(RegTreeConfig regTreeConfig,Vector featureValues,double[] probs,double[] labels){
  int numDataPoints=featureValues.size();
  int numIntervals=regTreeConfig.getNumSplitIntervals();
  double maxFeature=Double.NEGATIVE_INFINITY;
  double minFeature=Double.POSITIVE_INFINITY;
  double numExisting=0;
  for (int i=0; i < numDataPoints; i++) {
    double featureValue=featureValues.get(i);
    if (!Double.isNaN(featureValue) && probs[i] != 0) {
      numExisting+=probs[i];
      if (featureValue > maxFeature) {
        maxFeature=featureValue;
      }
      if (featureValue < minFeature) {
        minFeature=featureValue;
      }
    }
  }
  List<Interval> intervals=new ArrayList<>(numIntervals);
  if (numExisting < 2) {
    return intervals;
  }
  double intervalLength=(maxFeature - minFeature) / numIntervals;
  for (int i=0; i < numIntervals; i++) {
    Interval interval=new Interval();
    double lower=minFeature + i * intervalLength;
    double upper=lower + intervalLength;
    interval.setLower(lower);
    interval.setUpper(upper);
    intervals.add(interval);
  }
  for (int i=0; i < numDataPoints; i++) {
    double featureValue=featureValues.get(i);
    double label=labels[i];
    if (!Double.isNaN(featureValue) && probs[i] != 0) {
      int ceil=(int)Math.ceil((featureValue - minFeature) / intervalLength);
      if (ceil > numIntervals) {
        ceil=numIntervals;
      }
      int intervalIndex;
      if (ceil == 0) {
        intervalIndex=0;
      }
 else {
        intervalIndex=ceil - 1;
      }
      Interval interval=intervals.get(intervalIndex);
      double probability=probs[i];
      double oldCount=interval.getProbabilisticCount();
      interval.setProbabilisticCount(oldCount + probability);
      double oldSum=interval.getWeightedSum();
      interval.setWeightedSum(oldSum + label * probability);
    }
  }
  for (  Interval interval : intervals) {
    interval.setPercentage(interval.getProbabilisticCount() / numExisting);
  }
  for (int i=0; i < numDataPoints; i++) {
    double featureValue=featureValues.get(i);
    double label=labels[i];
    if (Double.isNaN(featureValue)) {
      for (      Interval interval : intervals) {
        double probability=probs[i] * interval.getPercentage();
        double oldCount=interval.getProbabilisticCount();
        interval.setProbabilisticCount(oldCount + probability);
        double oldSum=interval.getWeightedSum();
        interval.setWeightedSum(oldSum + label * probability);
      }
    }
  }
  return intervals;
}

Fixed version (ground truth):
static List<Interval> generateIntervals(RegTreeConfig regTreeConfig,Vector featureValues,double[] probs,double[] labels){
  int numDataPoints=featureValues.size();
  int numIntervals=regTreeConfig.getNumSplitIntervals();
  double maxFeature=Double.NEGATIVE_INFINITY;
  double minFeature=Double.POSITIVE_INFINITY;
  double existingProbCount=0;
  int existingBinaryCount=0;
  for (int i=0; i < numDataPoints; i++) {
    double featureValue=featureValues.get(i);
    if (!Double.isNaN(featureValue) && probs[i] != 0) {
      existingProbCount+=probs[i];
      existingBinaryCount+=1;
      if (featureValue > maxFeature) {
        maxFeature=featureValue;
      }
      if (featureValue < minFeature) {
        minFeature=featureValue;
      }
    }
  }
  List<Interval> intervals=new ArrayList<>(numIntervals);
  if (existingBinaryCount < 2) {
    return intervals;
  }
  double intervalLength=(maxFeature - minFeature) / numIntervals;
  for (int i=0; i < numIntervals; i++) {
    Interval interval=new Interval();
    double lower=minFeature + i * intervalLength;
    double upper=lower + intervalLength;
    interval.setLower(lower);
    interval.setUpper(upper);
    intervals.add(interval);
  }
  for (int i=0; i < numDataPoints; i++) {
    double featureValue=featureValues.get(i);
    double label=labels[i];
    if (!Double.isNaN(featureValue) && probs[i] != 0) {
      int ceil=(int)Math.ceil((featureValue - minFeature) / intervalLength);
      if (ceil > numIntervals) {
        ceil=numIntervals;
      }
      int intervalIndex;
      if (ceil == 0) {
        intervalIndex=0;
      }
 else {
        intervalIndex=ceil - 1;
      }
      Interval interval=intervals.get(intervalIndex);
      double probability=probs[i];
      double oldCount=interval.getProbabilisticCount();
      interval.setProbabilisticCount(oldCount + probability);
      double oldSum=interval.getWeightedSum();
      interval.setWeightedSum(oldSum + label * probability);
    }
  }
  for (  Interval interval : intervals) {
    interval.setPercentage(interval.getProbabilisticCount() / existingProbCount);
  }
  for (int i=0; i < numDataPoints; i++) {
    double featureValue=featureValues.get(i);
    double label=labels[i];
    if (Double.isNaN(featureValue)) {
      for (      Interval interval : intervals) {
        double probability=probs[i] * interval.getPercentage();
        double oldCount=interval.getProbabilisticCount();
        interval.setProbabilisticCount(oldCount + probability);
        double oldSum=interval.getWeightedSum();
        interval.setWeightedSum(oldSum + label * probability);
      }
    }
  }
  return intervals;
}