guava/src/com/google/common/math/StatsAccumulator.java
public void add(double value) {
    if (count == 0) {
      count = 1;
      mean = value;
      min = value;
      max = value;
      if (!isFinite(value)) {
        sumOfSquaresOfDeltas = NaN;
      }
    } else {
      count++;
      if (isFinite(value) && isFinite(mean)) {
        // Art of Computer Programming vol. 2, Knuth, 4.2.2, (15) and (16)
        double delta = value - mean;
        mean += delta / count;
        sumOfSquaresOfDeltas += delta * (value - mean);
      } else {
        mean = calculateNewMeanNonFinite(mean, value);
        sumOfSquaresOfDeltas = NaN;
      }
      min = Math.min(min, value);
      max = Math.max(max, value);
    }
  }
public void add(double value) {
    if (count == 0) {
      count = 1;
      mean = value;
      min = value;
      max = value;
      if (!isFinite(value)) {
        sumOfSquaresOfDeltas = NaN;
      }
    } else {
      count++;
      if (isFinite(value) && isFinite(mean)) {
        // Art of Computer Programming vol. 2, Knuth, 4.2.2, (15) and (16)
        double delta = value - mean;
        mean += delta / count;
        sumOfSquaresOfDeltas += delta * (value - mean);
      } else {
        mean = calculateNewMeanNonFinite(mean, value);
        sumOfSquaresOfDeltas = NaN;
      }
      min = Math.min(min, value);
      max = Math.max(max, value);
    }
  }
public void add ( double value ) { if ( count == 0 ) { count = 1 ; mean = value ; min = value ; max = value ; if ( ! isFinite ( value ) ) { sumOfSquaresOfDeltas = NaN ; } } else { count ++ ; if ( isFinite ( value ) && isFinite ( mean ) ) { // Art of Computer Programming vol. 2, Knuth, 4.2.2, (15) and (16) double delta = value - mean ; mean += delta / count ; sumOfSquaresOfDeltas += delta * ( value - mean ) ; } else { mean = calculateNewMeanNonFinite ( mean , value ) ; sumOfSquaresOfDeltas = NaN ; } min = Math . min ( min , value ) ; max = Math . max ( max , value ) ; } }
Adds the given value to the dataset.
Adds the given value to the dataset .