Program: 32982
Project: 32982
Buggy source:
static List<Interval> generateIntervals(RegTreeConfig regTreeConfig,Vector featureValues,double[] probs,double[] labels,Splitter.GlobalStats globalStats){
  FeatureStats featureStats=new FeatureStats(featureValues,probs,labels,globalStats);
  int numIntervals=regTreeConfig.getNumSplitIntervals();
  List<Interval> intervals=new ArrayList<>(numIntervals);
  double maxFeature=featureStats.getMax();
  double minFeature=featureStats.getMin();
  if (maxFeature == Double.NEGATIVE_INFINITY) {
    return intervals;
  }
  if (minFeature == Double.POSITIVE_INFINITY) {
    return intervals;
  }
  if (minFeature == maxFeature) {
    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);
  }
  if (featureStats.getNonZeroBinaryCount() > 0) {
    for (    Vector.Element element : featureValues.nonZeroes()) {
      int i=element.index();
      double featureValue=element.get();
      double label=labels[i];
      if (!Double.isNaN(featureValue) && probs[i] != 0) {
        int intervalIndex=getIntervalIndex(featureValue,minFeature,intervalLength,numIntervals);
        Interval interval=intervals.get(intervalIndex);
        double probability=probs[i];
        double oldProbCount=interval.getProbabilisticCount();
        interval.setProbabilisticCount(oldProbCount + probability);
        double oldWeightedLabelSum=interval.getWeightedSum();
        interval.setWeightedSum(oldWeightedLabelSum + label * probability);
      }
    }
  }
  if (featureStats.getZeroBinaryCount() > 0) {
    int intervalIndex=getIntervalIndex(0,minFeature,intervalLength,numIntervals);
    Interval interval=intervals.get(intervalIndex);
    double oldProbCount=interval.getProbabilisticCount();
    interval.setProbabilisticCount(oldProbCount + featureStats.getZeroProbCount());
    double oldWeightedLabelSum=interval.getWeightedSum();
    interval.setWeightedSum(oldWeightedLabelSum + featureStats.getZeroWeightedLabelSum());
  }
  for (  Interval interval : intervals) {
    interval.setPercentage(interval.getProbabilisticCount() / globalStats.getProbabilisticCount());
  }
  if (featureStats.getNanBinaryCount() > 0) {
    for (    Interval interval : intervals) {
      double oldCount=interval.getProbabilisticCount();
      interval.setProbabilisticCount(oldCount + interval.getPercentage() * featureStats.getNanProbCount());
      double oldSum=interval.getWeightedSum();
      interval.setWeightedSum(oldSum + interval.getPercentage() * featureStats.getNanWeightedLabelSum());
    }
  }
  return intervals;
}

Fixed version (ground truth):
static List<Interval> generateIntervals(RegTreeConfig regTreeConfig,Vector featureValues,double[] probs,double[] labels,Splitter.GlobalStats globalStats){
  FeatureStats featureStats=new FeatureStats(featureValues,probs,labels,globalStats);
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + featureStats);
  }
  int numIntervals=regTreeConfig.getNumSplitIntervals();
  List<Interval> intervals=new ArrayList<>(numIntervals);
  double maxFeature=featureStats.getMax();
  double minFeature=featureStats.getMin();
  if (maxFeature == Double.NEGATIVE_INFINITY) {
    return intervals;
  }
  if (minFeature == Double.POSITIVE_INFINITY) {
    return intervals;
  }
  if (minFeature == maxFeature) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + intervals.size());
    }
    return intervals;
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + minFeature);
    logger.debug("String_Node_Str" + maxFeature);
  }
  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);
  }
  if (featureStats.getNonZeroBinaryCount() > 0) {
    for (    Vector.Element element : featureValues.nonZeroes()) {
      int i=element.index();
      double featureValue=element.get();
      double label=labels[i];
      if (!Double.isNaN(featureValue) && probs[i] != 0) {
        int intervalIndex=getIntervalIndex(featureValue,minFeature,intervalLength,numIntervals);
        Interval interval=intervals.get(intervalIndex);
        double probability=probs[i];
        double oldProbCount=interval.getProbabilisticCount();
        interval.setProbabilisticCount(oldProbCount + probability);
        double oldWeightedLabelSum=interval.getWeightedSum();
        interval.setWeightedSum(oldWeightedLabelSum + label * probability);
      }
    }
  }
  if (featureStats.getZeroBinaryCount() > 0) {
    int intervalIndex=getIntervalIndex(0,minFeature,intervalLength,numIntervals);
    Interval interval=intervals.get(intervalIndex);
    double oldProbCount=interval.getProbabilisticCount();
    interval.setProbabilisticCount(oldProbCount + featureStats.getZeroProbCount());
    double oldWeightedLabelSum=interval.getWeightedSum();
    interval.setWeightedSum(oldWeightedLabelSum + featureStats.getZeroWeightedLabelSum());
  }
  for (  Interval interval : intervals) {
    interval.setPercentage(interval.getProbabilisticCount() / globalStats.getProbabilisticCount());
  }
  if (featureStats.getNanBinaryCount() > 0) {
    for (    Interval interval : intervals) {
      double oldCount=interval.getProbabilisticCount();
      interval.setProbabilisticCount(oldCount + interval.getPercentage() * featureStats.getNanProbCount());
      double oldSum=interval.getWeightedSum();
      interval.setWeightedSum(oldSum + interval.getPercentage() * featureStats.getNanWeightedLabelSum());
    }
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + intervals.size());
  }
  return intervals;
}