You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by md...@apache.org on 2003/07/08 05:44:13 UTC

cvs commit: jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank Max.java Min.java

mdiggory    2003/07/07 20:44:12

  Modified:    math/src/java/org/apache/commons/math/stat/univariate/moment
                        FourthMoment.java GeometricMean.java
                        FirstMoment.java Mean.java ThirdMoment.java
                        Kurtosis.java Variance.java Skewness.java
                        StandardDeviation.java SecondMoment.java
               math/src/java/org/apache/commons/math/stat/univariate/summary
                        SumOfSquares.java Product.java Sum.java
                        SumOfLogs.java
               math/src/java/org/apache/commons/math/stat/univariate
                        StorelessUnivariateStatistic.java
               math/src/java/org/apache/commons/math/stat/univariate/rank
                        Max.java Min.java
  Log:
  Its more logical not to have increment return a value, this allows a 
  distict separation between the calculation of moments and the 
  calculation of the actually return value of getVlaue in Storageless 
  approaches. With this benifit it is no longer neccessary to calculate 
  all the statistics moment based statistics on addValue, only the 
  underlying moment itself.
  
  
  Revision  Changes    Path
  1.4       +1 -3      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/FourthMoment.java
  
  Index: FourthMoment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/FourthMoment.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FourthMoment.java	7 Jul 2003 23:06:47 -0000	1.3
  +++ FourthMoment.java	8 Jul 2003 03:44:11 -0000	1.4
  @@ -72,7 +72,7 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (n < 1) {
               m4 = m3 = m2 = m1 = 0.0;
           }
  @@ -90,8 +90,6 @@
                   - (4.0 * v * prevM3)
                   + (6.0 * v2 * prevM2)
                   + ((n0 * n0) - 3 * n1) * (v2 * v2 * n1 * n0);
  -
  -        return m4;
       }
       
       /**
  
  
  
  1.6       +3 -6      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/GeometricMean.java
  
  Index: GeometricMean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/GeometricMean.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GeometricMean.java	7 Jul 2003 23:06:47 -0000	1.5
  +++ GeometricMean.java	8 Jul 2003 03:44:12 -0000	1.6
  @@ -61,23 +61,21 @@
    */
   public class GeometricMean extends SumOfLogs {
    
  -    private double geoMean = Double.NaN;
  -    
       private int n = 0;
       
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           n++;
  -        return geoMean = Math.exp( super.increment(d) / (double)n );
  +        super.increment(d);
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return geoMean;
  +        return Math.exp( super.getValue() / (double)n );
       }
   
       /**
  @@ -85,7 +83,6 @@
        */
       public void clear() {
           super.clear();
  -        geoMean = Double.NaN;
           n = 0;
       }
       
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/FirstMoment.java
  
  Index: FirstMoment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/FirstMoment.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FirstMoment.java	7 Jul 2003 23:06:47 -0000	1.1
  +++ FirstMoment.java	8 Jul 2003 03:44:12 -0000	1.2
  @@ -78,7 +78,7 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (n < 1) {
                m1 = 0.0;
           }
  @@ -88,7 +88,7 @@
           n0 = (double)n;
           v = dev / n0;
   
  -        return m1 += v;                    
  +        m1 += v;                    
       }
       
       /**
  
  
  
  1.4       +1 -3      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Mean.java
  
  Index: Mean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Mean.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Mean.java	7 Jul 2003 23:06:47 -0000	1.3
  +++ Mean.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -84,12 +84,10 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (incMoment) {
               moment.increment(d);
           }
  -
  -        return moment.m1;
       }
   
       /**
  
  
  
  1.4       +1 -2      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/ThirdMoment.java
  
  Index: ThirdMoment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/ThirdMoment.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ThirdMoment.java	7 Jul 2003 23:06:47 -0000	1.3
  +++ ThirdMoment.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -74,7 +74,7 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (n < 1) {
               m3 = m2 = m1 = 0.0;
           }
  @@ -90,7 +90,6 @@
   
           m3 = m3 - (3.0 * v * prevM2) + (n0 * n1 * n2 * v2 * v);
   
  -        return m3;
       }
   
       /**
  
  
  
  1.4       +58 -49    jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java
  
  Index: Kurtosis.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Kurtosis.java	7 Jul 2003 23:06:47 -0000	1.3
  +++ Kurtosis.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -66,8 +66,6 @@
    */
   public class Kurtosis extends AbstractStorelessUnivariateStatistic {
   
  -    private double kurtosis = Double.NaN;
  -
       protected FourthMoment moment = null;
   
       protected boolean incMoment = true;
  @@ -84,29 +82,32 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (incMoment) {
               moment.increment(d);
           }
  -
  -        double variance =
  -            (moment.n < 1) ? 0.0 : moment.m2 / (double) (moment.n - 1);
  -
  -        kurtosis =
  -            (moment.n <= 3 || variance < 10E-20)
  -                ? 0.0
  -                : (moment.n0 * (moment.n0 + 1) * moment.m4
  -                    - 3 * moment.m2 * moment.m2 * moment.n1)
  -                    / (moment.n1 * moment.n2 * moment.n3 * variance * variance);
  -
  -        return kurtosis;
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return kurtosis;
  +
  +        if (moment.n <= 0) {
  +            return Double.NaN;
  +        }
  +
  +        double variance =
  +            (moment.n < 1) ? 0.0 : moment.m2 / (double) (moment.n - 1);
  +
  +        if (moment.n <= 3 || variance < 10E-20) {
  +            return 0.0;
  +        }
  +
  +        return (moment.n0 * (moment.n0 + 1) * moment.m4
  +                - 3 * moment.m2 * moment.m2 * moment.n1)
  +                / (moment.n1 * moment.n2 * moment.n3 * variance * variance);
  +
       }
   
       /**
  @@ -116,7 +117,6 @@
           if (incMoment) {
               moment.clear();
           }
  -        kurtosis = Double.NaN;
       }
   
       /*UnvariateStatistic Approach */
  @@ -139,43 +139,52 @@
       * @return the kurtosis of the values or Double.NaN if the array is empty
       */
       public double evaluate(double[] values, int begin, int length) {
  -        test(values, begin, length);
  +        ;
   
           // Initialize the kurtosis
           double kurt = Double.NaN;
   
  -        // Get the mean and the standard deviation
  -        double m = mean.evaluate(values, begin, length);
  -
  -        // Calc the std, this is implemented here instead of using the 
  -        // standardDeviation method eliminate a duplicate pass to get the mean
  -        double accum = 0.0;
  -        double accum2 = 0.0;
  -        for (int i = begin; i < begin + length; i++) {
  -            accum += Math.pow((values[i] - m), 2.0);
  -            accum2 += (values[i] - m);
  +        if (test(values, begin, length)) {
  +            if (length <= 3) {
  +                kurt = 0.0;
  +            } else {
  +
  +                // Get the mean and the standard deviation
  +                double m = mean.evaluate(values, begin, length);
  +
  +                // Calc the std, this is implemented here instead of using the 
  +                // standardDeviation method eliminate a duplicate pass to get the mean
  +                double accum = 0.0;
  +                double accum2 = 0.0;
  +                for (int i = begin; i < begin + length; i++) {
  +                    accum += Math.pow((values[i] - m), 2.0);
  +                    accum2 += (values[i] - m);
  +                }
  +
  +                double stdDev =
  +                    Math.sqrt(
  +                        (accum - (Math.pow(accum2, 2) / ((double) length)))
  +                            / (double) (length - 1));
  +
  +                // Sum the ^4 of the distance from the mean divided by the 
  +                // standard deviation
  +                double accum3 = 0.0;
  +                for (int i = begin; i < begin + length; i++) {
  +                    accum3 += Math.pow((values[i] - m) / stdDev, 4.0);
  +                }
  +
  +                // Get N
  +                double n = length;
  +
  +                double coefficientOne =
  +                    (n * (n + 1)) / ((n - 1) * (n - 2) * (n - 3));
  +                double termTwo =
  +                    ((3 * Math.pow(n - 1, 2.0)) / ((n - 2) * (n - 3)));
  +
  +                // Calculate kurtosis
  +                kurt = (coefficientOne * accum3) - termTwo;
  +            }
           }
  -
  -        double stdDev =
  -            Math.sqrt(
  -                (accum - (Math.pow(accum2, 2) / ((double) length)))
  -                    / (double) (length - 1));
  -
  -        // Sum the ^4 of the distance from the mean divided by the 
  -        // standard deviation
  -        double accum3 = 0.0;
  -        for (int i = begin; i < begin + length; i++) {
  -            accum3 += Math.pow((values[i] - m) / stdDev, 4.0);
  -        }
  -
  -        // Get N
  -        double n = length;
  -
  -        double coefficientOne = (n * (n + 1)) / ((n - 1) * (n - 2) * (n - 3));
  -        double termTwo = ((3 * Math.pow(n - 1, 2.0)) / ((n - 2) * (n - 3)));
  -
  -        // Calculate kurtosis
  -        kurt = (coefficientOne * accum3) - termTwo;
   
           return kurt;
       }
  
  
  
  1.4       +39 -33    jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java
  
  Index: Variance.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Variance.java	7 Jul 2003 23:06:47 -0000	1.3
  +++ Variance.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -53,46 +53,51 @@
    */
   package org.apache.commons.math.stat.univariate.moment;
   
  -import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
  +import org
  +    .apache
  +    .commons
  +    .math
  +    .stat
  +    .univariate
  +    .AbstractStorelessUnivariateStatistic;
   
   /**
    *
    *
    */
  -public class Variance extends AbstractStorelessUnivariateStatistic{
  -
  -    protected double variance = Double.NaN;
  +public class Variance extends AbstractStorelessUnivariateStatistic {
   
       protected SecondMoment moment = null;
  -    
  +
       protected boolean incMoment = true;
  -    
  -    public Variance(){
  +
  +    public Variance() {
           moment = new SecondMoment();
       }
  -    
  -    public Variance(SecondMoment m2){
  +
  +    public Variance(SecondMoment m2) {
           incMoment = false;
           this.moment = m2;
       }
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (incMoment) {
               moment.increment(d);
           }
  -        
  -        variance = (moment.n < 1) ? 0.0 : moment.m2 / (double)(moment.n - 1);
  -        
  -        return variance;
       }
  -    
  +
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return variance;
  +        if (moment.n <= 0) {
  +            return Double.NaN;
  +        } else if (moment.n <= 1) {
  +            return 0.0;
  +        }
  +        return moment.m2 / (moment.n0 - 1);
       }
   
       /**
  @@ -102,13 +107,12 @@
           if (incMoment) {
               moment.clear();
           }
  -        variance = Double.NaN;
       }
  -    
  +
       /*UnvariateStatistic Approach */
   
       Mean mean = new Mean();
  -    
  +
       /**
        * Returns the variance of the available values. This uses a corrected
        * two pass algorithm of the following 
  @@ -126,24 +130,26 @@
        * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
        */
       public double evaluate(double[] values, int begin, int length) {
  +
           double var = Double.NaN;
  -        if (values.length == 1) {
  -            var = 0;
  -        } else if (values.length > 1) {
  -            double m = mean.evaluate(values, begin, length);
  -            double accum = 0.0;
  -            double accum2 = 0.0;
  -            for (int i = begin; i < begin + length; i++) {
  -                accum += Math.pow((values[i] - m), 2.0);
  -                accum2 += (values[i] - m);
  +
  +        if (test(values, begin, length)) {
  +            if (length == 1) {
  +                var = 0.0;
  +            } else if (length > 1) {
  +                double m = mean.evaluate(values, begin, length);
  +                double accum = 0.0;
  +                double accum2 = 0.0;
  +                for (int i = begin; i < begin + length; i++) {
  +                    accum += Math.pow((values[i] - m), 2.0);
  +                    accum2 += (values[i] - m);
  +                }
  +                var =
  +                    (accum - (Math.pow(accum2, 2) / ((double) length)))
  +                        / (double) (length - 1);
               }
  -            var =
  -                (accum - (Math.pow(accum2, 2) / ((double) length)))
  -                    / (double) (length - 1);
           }
           return var;
       }
  -
  -
   
   }
  
  
  
  1.4       +47 -44    jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java
  
  Index: Skewness.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Skewness.java	7 Jul 2003 23:06:47 -0000	1.3
  +++ Skewness.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -67,8 +67,6 @@
    */
   public class Skewness extends AbstractStorelessUnivariateStatistic {
   
  -    private double skewness = Double.NaN;
  -
       protected ThirdMoment moment = null;
   
       protected boolean incMoment = true;
  @@ -85,28 +83,29 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (incMoment) {
               moment.increment(d);
           }
  -
  -        double variance =
  -            (moment.n < 1) ? 0.0 : moment.m2 / (double) (moment.n - 1);
  -
  -        skewness =
  -            (moment.n <= 2 || variance < 10E-20)
  -                ? 0.0
  -                : (moment.n0 * moment.m3)
  -                    / (moment.n1 * moment.n2 * Math.sqrt(variance) * variance);
  -
  -        return skewness;
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return skewness;
  +        if (moment.n <= 0) {
  +            return Double.NaN;
  +        }
  +
  +        double variance =
  +            (moment.n < 1) ? 0.0 : moment.m2 / (double) (moment.n - 1);
  +
  +        if (moment.n <= 2 || variance < 10E-20) {
  +            return 0.0;
  +        }
  +
  +        return (moment.n0 * moment.m3)
  +                / (moment.n1 * moment.n2 * Math.sqrt(variance) * variance);
       }
   
       /**
  @@ -116,7 +115,6 @@
           if (incMoment) {
               moment.clear();
           }
  -        skewness = Double.NaN;
       }
   
       /*UnvariateStatistic Approach */
  @@ -141,39 +139,44 @@
        */
       public double evaluate(double[] values, int begin, int length) {
   
  -        test(values, begin, length);
  -
           // Initialize the skewness
           double skew = Double.NaN;
   
  -        // Get the mean and the standard deviation
  -        double m = mean.evaluate(values, begin, length);
  +        if (test(values, begin, length)) {
   
  -        // Calc the std, this is implemented here instead of using the 
  -        // standardDeviation method eliminate a duplicate pass to get the mean
  -        double accum = 0.0;
  -        double accum2 = 0.0;
  -        for (int i = begin; i < begin + length; i++) {
  -            accum += Math.pow((values[i] - m), 2.0);
  -            accum2 += (values[i] - m);
  -        }
  -        double stdDev =
  -            Math.sqrt(
  -                (accum - (Math.pow(accum2, 2) / ((double) length)))
  -                    / (double) (length - 1));
  -
  -        // Calculate the skew as the sum the cubes of the distance 
  -        // from the mean divided by the standard deviation.
  -        double accum3 = 0.0;
  -        for (int i = begin; i < begin + length; i++) {
  -            accum3 += Math.pow((values[i] - m) / stdDev, 3.0);
  +            if (length <= 2) {
  +                skew = 0.0;
  +            } else {
  +                // Get the mean and the standard deviation
  +                double m = mean.evaluate(values, begin, length);
  +
  +                // Calc the std, this is implemented here instead of using the 
  +                // standardDeviation method eliminate a duplicate pass to get the mean
  +                double accum = 0.0;
  +                double accum2 = 0.0;
  +                for (int i = begin; i < begin + length; i++) {
  +                    accum += Math.pow((values[i] - m), 2.0);
  +                    accum2 += (values[i] - m);
  +                }
  +                double stdDev =
  +                    Math.sqrt(
  +                        (accum - (Math.pow(accum2, 2) / ((double) length)))
  +                            / (double) (length - 1));
  +
  +                // Calculate the skew as the sum the cubes of the distance 
  +                // from the mean divided by the standard deviation.
  +                double accum3 = 0.0;
  +                for (int i = begin; i < begin + length; i++) {
  +                    accum3 += Math.pow((values[i] - m) / stdDev, 3.0);
  +                }
  +
  +                // Get N
  +                double n = length;
  +
  +                // Calculate skewness
  +                skew = (n / ((n - 1) * (n - 2))) * accum3;
  +            }
           }
  -
  -        // Get N
  -        double n = length;
  -
  -        // Calculate skewness
  -        skew = (n / ((n - 1) * (n - 2))) * accum3;
   
           return skew;
       }
  
  
  
  1.4       +19 -10    jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/StandardDeviation.java
  
  Index: StandardDeviation.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/StandardDeviation.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardDeviation.java	7 Jul 2003 23:06:47 -0000	1.3
  +++ StandardDeviation.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -59,8 +59,6 @@
    */
   public class StandardDeviation extends Variance {
   
  -    private double std = Double.NaN;
  -    
       public StandardDeviation(){
           super();
       }
  @@ -72,17 +70,24 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  -        super.increment(d);
  -        std = (variance != 0.0) ? Math.sqrt(variance) : 0.0;
  -        return std;
  +    public void increment(double d) {
  +        super.increment(d);        
       }
       
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return std;
  +        
  +        double var = super.getValue();
  +        
  +        if(Double.isNaN(var)){
  +            return Double.NaN;
  +        }else if (var == 0.0){
  +            return 0.0;
  +        }
  +        
  +        return Math.sqrt(var);
       }
       
       /**
  @@ -90,7 +95,6 @@
        */
       public void clear() {
           super.clear();
  -        std = Double.NaN;
       }
   
       /**
  @@ -103,8 +107,13 @@
        * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
        */
       public double evaluate(double[] values, int begin, int length) {
  -        double tmp = super.evaluate(values, begin, length);
  -        return tmp != 0.0 ? Math.sqrt(tmp) : 0.0;
  +        double var = super.evaluate(values, begin, length);
  +        
  +        if(Double.isNaN(var)){
  +            return Double.NaN;
  +        }
  +
  +        return var != 0.0 ? Math.sqrt(var) : 0.0;
       }
   
   }
  
  
  
  1.4       +1 -4      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/SecondMoment.java
  
  Index: SecondMoment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/SecondMoment.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SecondMoment.java	7 Jul 2003 23:06:47 -0000	1.3
  +++ SecondMoment.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -68,7 +68,7 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (n < 1) {
               m1 = m2 = 0.0;
           }
  @@ -80,9 +80,6 @@
           
           /* increment and return m2 */
           m2 += n1 * dev * v;
  -        
  -        return m2;
  -        
       }
   
       /**
  
  
  
  1.4       +1 -2      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/SumOfSquares.java
  
  Index: SumOfSquares.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/SumOfSquares.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SumOfSquares.java	7 Jul 2003 23:06:48 -0000	1.3
  +++ SumOfSquares.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -74,13 +74,12 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (Double.isNaN(value )) {
               value = d * d;
           } else {
               value += d * d;
           }
  -        return value;
       }
   
       /**
  
  
  
  1.4       +1 -3      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/Product.java
  
  Index: Product.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/Product.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Product.java	7 Jul 2003 23:06:48 -0000	1.3
  +++ Product.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -74,14 +74,12 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (Double.isNaN(value)) {
               value = d;
           } else {
               value *= d;
           }
  -
  -        return value;
       }
   
       /**
  
  
  
  1.4       +1 -2      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/Sum.java
  
  Index: Sum.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/Sum.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Sum.java	7 Jul 2003 23:06:48 -0000	1.3
  +++ Sum.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -74,13 +74,12 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           if (Double.isNaN(value )) {
               value  = d;
           } else {
               value  += d;
           }
  -        return value ;
       }
   
       /**
  
  
  
  1.4       +5 -4      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/SumOfLogs.java
  
  Index: SumOfLogs.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/SumOfLogs.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SumOfLogs.java	7 Jul 2003 23:06:48 -0000	1.3
  +++ SumOfLogs.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -71,17 +71,17 @@
        */
       private double value = Double.NaN;
   
  +    private boolean init = true;
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  -        if (Double.isNaN(value )) {
  +    public void increment(double d) {
  +        if (init) {
               value = Math.log(d);
  +            init = false;
           } else {
               value += Math.log(d);
           }
  -
  -        return value;
       }
   
       /**
  @@ -96,6 +96,7 @@
        */
       public void clear() {
           value = Double.NaN;
  +        init = true;
       }
       
       /**
  
  
  
  1.3       +1 -1      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/StorelessUnivariateStatistic.java
  
  Index: StorelessUnivariateStatistic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/StorelessUnivariateStatistic.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StorelessUnivariateStatistic.java	7 Jul 2003 02:15:19 -0000	1.2
  +++ StorelessUnivariateStatistic.java	8 Jul 2003 03:44:12 -0000	1.3
  @@ -69,7 +69,7 @@
        * the same value as <code>getValue()</code>, Double.NaN if it
        * has been cleared or just instantiated.
        */
  -    public double increment(double d);
  +    public void increment(double d);
   
       /**
        * Returns the current state of the statistic after the
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java
  
  Index: Max.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Max.java	7 Jul 2003 23:06:48 -0000	1.3
  +++ Max.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -71,8 +71,8 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  -        return value = Double.isNaN(value) ? d : Math.max(value, d);
  +    public void increment(double d) {
  +        value = Double.isNaN(value) ? d : Math.max(value, d);
       }
   
       /**
  
  
  
  1.4       +1 -2      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Min.java
  
  Index: Min.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Min.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Min.java	7 Jul 2003 23:06:48 -0000	1.3
  +++ Min.java	8 Jul 2003 03:44:12 -0000	1.4
  @@ -71,9 +71,8 @@
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
  -    public double increment(double d) {
  +    public void increment(double d) {
           value = Double.isNaN(value) ? d : Math.min(value, d);
  -        return value;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org