public static Double calculateAverageBurnRate(List<Datapoint> dpList){
  if (dpList.size() <= 1) {
    return null;
  }
  Datapoint oldestDatapoint=dpList.get(0);
  Datapoint latestDatapoint=dpList.get(dpList.size() - 1);
  for (  Datapoint datapoint : dpList.subList(1,dpList.size() - 1)) {
    if (latestDatapoint.getAverage() > oldestDatapoint.getAverage()) {
      break;
    }
    oldestDatapoint=datapoint;
  }
  double averageBurnRate=(latestDatapoint.getAverage() - oldestDatapoint.getAverage()) / getDateDifference(oldestDatapoint.getTimestamp(),latestDatapoint.getTimestamp(),TimeUnit.HOURS);
  averageBurnRate=(averageBurnRate < 0 ? 0 : averageBurnRate);
  return averageBurnRate;
}

public static Double calculateAverageBurnRate ( List < Datapoint > dpList ) { if ( dpList . size ( ) <= 1 ) { return null ; } Datapoint oldestDatapoint = dpList . get ( 0 ) ; Datapoint latestDatapoint = dpList . get ( dpList . size ( ) - 1 ) ; for ( Datapoint datapoint : dpList . subList ( 1 , dpList . size ( ) - 1 ) ) { if ( latestDatapoint . getAverage ( ) > oldestDatapoint . getAverage ( ) ) { break ; } oldestDatapoint = datapoint ; } double averageBurnRate = ( latestDatapoint . getAverage ( ) - oldestDatapoint . getAverage ( ) ) / getDateDifference ( oldestDatapoint . getTimestamp ( ) , latestDatapoint . getTimestamp ( ) , TimeUnit . HOURS ) ; averageBurnRate = ( averageBurnRate < 0 ? 0 : averageBurnRate ) ; return averageBurnRate ; }
calculate the average burn rate , given a list of datapoints from amazon aws .
