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/07 04:15:20 UTC

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

mdiggory    2003/07/06 19:15:20

  Modified:    math/src/java/org/apache/commons/math/stat/univariate/moment
                        FourthMoment.java GeometricMean.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
                        UnivariateStatistic.java
                        AbstractUnivariateStatistic.java
                        StorelessUnivariateStatistic.java
                        AbstractStorelessUnivariateStatistic.java
               math/src/java/org/apache/commons/math/stat/univariate/rank
                        Max.java Min.java Percentile.java
  Log:
  Addition of optimal array based evaluations available in StatUtils. These are not delegates to StatUtils, they are implementations.
  
  Revision  Changes    Path
  1.2       +6 -26     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FourthMoment.java	5 Jul 2003 18:23:51 -0000	1.1
  +++ FourthMoment.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -53,31 +53,11 @@
    */
   package org.apache.commons.math.stat.univariate.moment;
   
  -import org
  -    .apache
  -    .commons
  -    .math
  -    .stat
  -    .univariate
  -    .AbstractStorelessUnivariateStatistic;
  -
   /**
    * @author Mark Diggory
    *
    */
  -public class FourthMoment extends AbstractStorelessUnivariateStatistic {
  -
  -    /** count of values that have been added */
  -    protected int n = 0;
  -
  -    /** first moment of values that have been added */
  -    protected double m1 = Double.NaN;
  -
  -    /** second moment of values that have been added */
  -    protected double m2 = Double.NaN;
  -
  -    /** third moment of values that have been added */
  -    protected double m3 = Double.NaN;
  +public class FourthMoment extends ThirdMoment {
   
       /** fourth moment of values that have been added */
       protected double m4 = Double.NaN;
  @@ -122,11 +102,11 @@
       }
   
       /**
  -    * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  -    */
  -    protected void internalClear() {
  -        n = 0;
  -        m1 = m2 = m3 = m4 = Double.NaN;
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     */
  +    public void clear() {
  +        super.clear();
  +        m4 = Double.NaN;
       }
   
   }
  
  
  
  1.2       +25 -11    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GeometricMean.java	5 Jul 2003 18:23:51 -0000	1.1
  +++ GeometricMean.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -53,40 +53,54 @@
    */
   package org.apache.commons.math.stat.univariate.moment;
   
  +import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
   import org.apache.commons.math.stat.univariate.summary.SumOfLogs;
   
   /**
    * @author Mark Diggory
    *
    */
  -public class GeometricMean extends SumOfLogs {
  +public class GeometricMean extends AbstractStorelessUnivariateStatistic {
    
  -    protected double geomean = Double.NaN;
  +    private SumOfLogs sumLog = new SumOfLogs();
       
  -    protected int n = 0;
  +    private double value = Double.NaN;
  +    
  +    private int n = 0;
       
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public double increment(double d) {
           n++;
  -        super.increment(d);
  -        geomean = Math.exp( sumLog / (double)n );
  -        return geomean;
  +        sumLog.increment(d);
  +        value = Math.exp( sumLog.increment(d) / (double)n );
  +        return value;
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return geomean;
  +        return value;
       }
   
       /**
  -    * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  -    */
  -    protected void internalClear() {
  -        geomean = Double.NaN;
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     */
  +    public void clear() {
  +        value = Double.NaN;
  +        sumLog.clear();
           n = 0;
       }
  +    
  +    /**
  +     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
  +     */
  +    public double evaluate(double[] values, int begin, int length) {
  +        return Math.exp(sumLog.evaluate(values, begin, length) / (double) length );
  +    }
  +
  +
  +
   }
  
  
  
  1.2       +23 -11    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Mean.java	5 Jul 2003 18:23:51 -0000	1.1
  +++ Mean.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -54,32 +54,43 @@
   package org.apache.commons.math.stat.univariate.moment;
   
   import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
  +import org.apache.commons.math.stat.univariate.summary.Sum;
   
   /**
    * @author Mark Diggory
    */
   public class Mean extends AbstractStorelessUnivariateStatistic {
   
  +
       /** count of values that have been added */
  -    private int n = 0;
  +    protected int n = 0;
   
       /** first moment of values that have been added */
  -    private double m1 = Double.NaN;
  +    protected double m1 = Double.NaN;
  +    
  +    private Sum sum = new Sum();
       
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public double increment(double d) {
           if (n < 1) {
  -            m1 = 0.0;
  +             m1 = 0.0;
           }
  +         
           n++;
  -
           m1 += (d - m1) / ((double) n);
  -
           return m1;
       }
  -
  +    
  +    /**
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     */
  +    public void clear() {
  +        m1 = Double.NaN;
  +        n = 0;
  +    }
  +    
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
  @@ -88,11 +99,12 @@
       }
   
       /**
  -    * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  -    */
  -    protected void internalClear() {
  -        m1 = Double.NaN;
  -        n = 0;
  +     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
  +     */
  +    public double evaluate(double[] values, int begin, int length) {
  +        if(test(values,begin,length))
  +            return sum.evaluate(values, begin, length) / ((double) length);
  +        return Double.NaN;
       }
   
   }
  
  
  
  1.2       +7 -16     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ThirdMoment.java	5 Jul 2003 18:23:51 -0000	1.1
  +++ ThirdMoment.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -53,22 +53,11 @@
    */
   package org.apache.commons.math.stat.univariate.moment;
   
  -import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
  -
   /**
    * @author Mark Diggory
    *
    */
  -public class ThirdMoment extends AbstractStorelessUnivariateStatistic{
  -
  -    /** count of values that have been added */
  -    protected int n = 0;
  -
  -    /** first moment of values that have been added */
  -    protected double m1 = Double.NaN;
  -
  -    /** second moment of values that have been added */
  -    protected double m2 = Double.NaN;
  +public class ThirdMoment extends SecondMoment{
   
       /** third moment of values that have been added */
       protected double m3 = Double.NaN;
  @@ -82,6 +71,7 @@
           }
           
           n++;
  +        
           double dev = d - m1;
           double v = dev / ((double) n);
           double v2 = v * v;
  @@ -108,10 +98,11 @@
       }
   
       /**
  -     * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
        */
  -    protected void internalClear() {
  -        n = 0;
  -        m1 = m2 = m3 = Double.NaN;
  +    public void clear() {
  +        super.clear();
  +        m3 = Double.NaN;
       }
  +
   }
  
  
  
  1.2       +57 -7     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Kurtosis.java	5 Jul 2003 18:23:51 -0000	1.1
  +++ Kurtosis.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -58,7 +58,7 @@
    */
   public class Kurtosis extends FourthMoment {
   
  -    protected double kurtosis = Double.NaN;
  +    private double kurtosis = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
  @@ -83,13 +83,63 @@
       public double getValue() {
           return kurtosis;
       }
  -
  +    
       /**
  -    * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  -    */
  -    protected void internalClear() {
  -        super.internalClear();
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     */
  +    public void clear() {
  +        super.clear();
           kurtosis = Double.NaN;
       }
  -    
  +
  +    /**
  +        * Returns the kurtosis for this collection of values. Kurtosis is a 
  +        * measure of the "peakedness" of a distribution.
  +        * @param values Is a double[] containing the values
  +        * @param begin processing at this point in the array
  +        * @param length processing at this point in the array
  +        * @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 mean = super.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] - mean), 2.0);
  +               accum2 += (values[i] - mean);
  +           }
  +        
  +           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] - mean) / 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.2       +41 -6     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Variance.java	5 Jul 2003 18:23:51 -0000	1.1
  +++ Variance.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -53,23 +53,33 @@
    */
   package org.apache.commons.math.stat.univariate.moment;
   
  +import org
  +    .apache
  +    .commons
  +    .math
  +    .stat
  +    .univariate
  +    .AbstractStorelessUnivariateStatistic;
  +
   /**
    * @author Mark Diggory
    *
    */
   public class Variance extends SecondMoment {
   
  -    protected double variance = Double.NaN;
  +    private double variance = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public double increment(double d) {
           super.increment(d);
  -        variance = (n <= 1) ? 0.0 : m2 / (double) (n - 1);
  +
  +        variance = (n < 1) ? 0.0 : m2 / (double)(n - 1);
  +        
           return variance;
       }
  -
  +    
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
  @@ -78,10 +88,35 @@
       }
   
       /**
  -     * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
        */
  -    protected void internalClear() {
  -        super.internalClear();
  +    public void clear() {
  +        super.clear();
           variance = Double.NaN;
       }
  +    
  +    /* (non-Javadoc)
  +     * @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 = super.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);
  +        }
  +        return var;
  +    }
  +
  +
  +
   }
  
  
  
  1.2       +52 -5     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Skewness.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ Skewness.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -59,7 +59,7 @@
    */
   public class Skewness extends ThirdMoment {
   
  -    protected double skewness = Double.NaN;
  +    private double skewness = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
  @@ -87,11 +87,58 @@
       }
   
       /**
  -    * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  -    */
  -    protected void internalClear() {
  -        super.internalClear();
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     */
  +    public void clear() {
  +        super.clear();
           skewness = Double.NaN;
       }
   
  +    /**
  +      * Returns the skewness of a collection of values.  Skewness is a 
  +      * measure of the assymetry of a given distribution. 
  +      * @param values Is a double[] containing the values
  +      * @param begin processing at this point in the array
  +      * @param length processing at this point in the array
  +      * @return the skewness 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 skewness
  +         double skew = Double.NaN;
  +
  +         // Get the mean and the standard deviation
  +         double mean = super.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] - mean), 2.0);
  +             accum2 += (values[i] - mean);
  +         }
  +         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] - mean) / stdDev, 3.0);
  +         }
  +
  +         // Get N
  +         double n = length;
  +
  +         // Calculate skewness
  +         skew = (n / ((n - 1) * (n - 2))) * accum3;
  +
  +         return skew;
  +     }
  +     
   }
  
  
  
  1.2       +25 -12    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardDeviation.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ StandardDeviation.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -53,35 +53,48 @@
    */
   package org.apache.commons.math.stat.univariate.moment;
   
  +import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
  +
   /**
    * @author Mark Diggory
    *
    */
  -public class StandardDeviation extends Variance {
  +public class StandardDeviation extends AbstractStorelessUnivariateStatistic {
   
  -    protected double std = Double.NaN;
  +    private double value = Double.NaN;
  +    
  +    private Variance var = new Variance();
       
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public double increment(double d) {
  -        std = Math.sqrt(super.increment(d));
  -        return std;
  +        var.increment(d);
  +        value = Math.sqrt(var.getValue());
  +        return value;
       }
       
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return std;
  +        return value;
       }
  -
  +    
       /**
  -    * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  -    */
  -    protected void internalClear() {
  -        super.internalClear();
  -        std = Double.NaN;
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     */
  +    public void clear() {
  +        var.clear();
  +        value = Double.NaN;
       }
  -    
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
  +     */
  +    public double evaluate(double[] values, int begin, int length) {
  +        double tmp = var.evaluate(values, begin, length);
  +        return tmp != 0.0 ? Math.sqrt(tmp) : 0.0;
  +    }
  +
   }
  
  
  
  1.2       +21 -19    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SecondMoment.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ SecondMoment.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -53,19 +53,19 @@
    */
   package org.apache.commons.math.stat.univariate.moment;
   
  -import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
  +import org
  +    .apache
  +    .commons
  +    .math
  +    .stat
  +    .univariate
  +    .AbstractStorelessUnivariateStatistic;
   
   /**
    * @author Mark Diggory
    *
    */
  -public class SecondMoment extends AbstractStorelessUnivariateStatistic {
  -
  -    /** count of values that have been added */
  -    protected int n = 0;
  -
  -    /** first moment of values that have been added */
  -    protected double m1 = Double.NaN;
  +public class SecondMoment extends Mean {
   
       /** second moment of values that have been added */
       protected double m2 = Double.NaN;
  @@ -75,31 +75,33 @@
        */
       public double increment(double d) {
           if (n < 1) {
  -            m2 = m1 = 0.0;
  +            m1 = m2 = 0.0;
           }
   
           n++;
  -        
  +
           double dev = d - m1;
           double v = dev / ((double) n);
  -        m1 += v;
  -        m2 += (n - 1) * dev * v;
   
  +        m2 += ((double)(n - 1)) * dev * v;
  +        m1 += v;
  +        
           return m2;
       }
   
       /**
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
        */
  -    public double getValue() {
  -        return m2;
  +    public void clear() {
  +        super.clear();
  +        m2 = Double.NaN;
       }
   
       /**
  -     * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
  -    protected void internalClear() {
  -        m2 = Double.NaN;
  -        n = 0;
  +    public double getValue() {
  +        return m2;
       }
  +
   }
  
  
  
  1.2       +23 -9     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SumOfSquares.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ SumOfSquares.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -70,33 +70,47 @@
       /**
        * The currently running sumSq
        */
  -    protected double sumSq = Double.NaN;
  +    private double value = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public double increment(double d) {
  -        if (init) {
  -            init = false;
  -            sumSq = d * d;
  +        if (Double.isNaN(value )) {
  +            value = d * d;
           } else {
  -            sumSq += d * d;
  +            value += d * d;
           }
  -        return sumSq;
  +        return value;
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return sumSq;
  +        return value;
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
        */
  -    protected void internalClear() {
  -        sumSq = Double.NaN;
  +    public void clear() {
  +        value = Double.NaN;
  +    }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
  +     */
  +    public double evaluate(double[] values, int begin, int length) {
  +        double sumSq = Double.NaN;
  +        if (test(values, begin, length)) {
  +            sumSq = 0.0;
  +            for (int i = begin; i < begin + length; i++) {
  +                sumSq += Math.pow(values[i], 2.0);
  +            }
  +        }
  +        return sumSq;
       }
  +   
   
   }
  
  
  
  1.2       +24 -10    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Product.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ Product.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -69,33 +69,47 @@
       /**
        * The current Running Product.
        */
  -    double product = Double.NaN;
  +    private double value = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public double increment(double d) {
  -        if (init) {
  -            init = false;
  -            product = d;
  +        if (Double.isNaN(value)) {
  +            value = d;
           } else {
  -            product *= d;
  +            value *= d;
           }
   
  -        return product;
  +        return value;
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return product;
  +        return value;
       }
   
       /**
  -     * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
        */
  -    protected void internalClear() {
  -        product = Double.NaN;
  +    public void clear() {
  +        value = Double.NaN;
       }
  +
  +    /**
  +     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
  +     */
  +    public double evaluate(double[] values, int begin, int length) {
  +        double product = Double.NaN;
  +        if (test(values, begin, length)) {
  +            product = 1.0;
  +            for (int i = begin; i < begin + length; i++) {
  +                product *= values[i];
  +            }
  +        }
  +        return product;
  +    }
  +
   }
  
  
  
  1.2       +25 -10    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Sum.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ Sum.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -70,33 +70,48 @@
       /**
        * The currently running sum.
        */
  -    protected double sum = Double.NaN;
  +    private double value = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public double increment(double d) {
  -        if (init) {
  -            init = false;
  -            sum = d;
  +        if (Double.isNaN(value )) {
  +            value  = d;
           } else {
  -            sum += d;
  +            value  += d;
           }
  -        return sum;
  +        return value ;
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return sum;
  +        return value;
  +    }
  +    
  +    /**
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     */
  +    public void clear() {
  +        value = Double.NaN;
       }
   
       /**
  -     * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  +     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
        */
  -    protected void internalClear() {
  -        sum = Double.NaN;
  +    public double evaluate(double[] values, int begin, int length) {
  +        double sum = Double.NaN;
  +        if (test(values, begin, length)) {
  +            sum = 0.0;
  +            for (int i = begin; i < begin + length; i++) {
  +                sum += values[i];
  +            }
  +        }
  +        return sum;
       }
  +
  +
   
   }
  
  
  
  1.2       +24 -11    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SumOfLogs.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ SumOfLogs.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -68,35 +68,48 @@
   public class SumOfLogs extends AbstractStorelessUnivariateStatistic {
   
       /**
  -     * The currently running sumLog
  +     * The currently running value
        */
  -    protected double sumLog = Double.NaN;
  +    private double value = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public double increment(double d) {
  -        if (init) {
  -            sumLog = Math.log(d);
  -            init = false;
  +        if (Double.isNaN(value )) {
  +            value = Math.log(d);
           } else {
  -            sumLog += Math.log(d);
  +            value += Math.log(d);
           }
   
  -        return sumLog;
  +        return value;
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  -        return sumLog;
  +        return value;
       }
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
        */
  -    protected void internalClear() {
  -        sumLog = Double.NaN;
  +    public void clear() {
  +        value = Double.NaN;
  +    }
  +    
  +    /**
  +     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
  +     */
  +    public double evaluate(double[] values, int begin, int length) {
  +        double sumLog = Double.NaN;
  +        if (test(values, begin, length)) {
  +            sumLog = 0.0;
  +            for (int i = begin; i < begin + length; i++) {
  +                sumLog += Math.log(values[i]);
  +            }
  +        }
  +        return sumLog;
       }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.2       +1 -1      jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/UnivariateStatistic.java
  
  Index: UnivariateStatistic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/UnivariateStatistic.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnivariateStatistic.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ UnivariateStatistic.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -78,6 +78,6 @@
        * @return the result of the evaluation or Double.NaN 
        * if the array is empty
        */
  -    public double evaluate(double[] d, int begin, int length); 
  +    public double evaluate(double[] values, int begin, int length); 
   
   }
  
  
  
  1.2       +10 -5     jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/AbstractUnivariateStatistic.java
  
  Index: AbstractUnivariateStatistic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/AbstractUnivariateStatistic.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractUnivariateStatistic.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ AbstractUnivariateStatistic.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -69,15 +69,15 @@
        * 
        * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[])
        */
  -    public double evaluate(double[] d) {
  -        return evaluate(d, 0, d.length);
  +    public double evaluate(double[] values) {
  +        return evaluate(values, 0, values.length);
       }
   
       /**
  -     * Subclasses of AbstractUnivariateStatistc need to implementation this method.
  +     * Subclasses of AbstractUnivariateStatistc need to implement this method.
        * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
        */
  -    public abstract double evaluate(double[] d, int start, int length);
  +    public abstract double evaluate(double[] values, int begin, int length);
   
       /**
        * this protected test method used by all methods to verify the content 
  @@ -86,7 +86,7 @@
        * @param begin processing at this point in the array
        * @param length processing at this point in the array
        */
  -    protected void test(double[] values, int begin, int length) {
  +    protected boolean test(double[] values, int begin, int length) {
   
           if (length > values.length)
               throw new IllegalArgumentException("length > values.length");
  @@ -96,6 +96,11 @@
   
           if (values == null)
               throw new IllegalArgumentException("input value array is null");
  +
  +        if (values.length == 0 || length == 0)
  +            return false;
  +
  +        return true;
   
       }
   }
  
  
  
  1.2       +3 -2      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StorelessUnivariateStatistic.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ StorelessUnivariateStatistic.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -79,6 +79,7 @@
        */
       public double getValue();
   
  +
       /**
        * Clears all the internal state of the Statistic
        */
  @@ -90,7 +91,7 @@
        * <code>evaluate(double[])</code> methods.
        * @return the state
        */
  -    public boolean isClearOnEval();
  +    //public boolean isClearOnEval();
   
       /**
        * Sets the behavior of this statistic when evaluating
  @@ -100,6 +101,6 @@
        * incrimented.
        * @param b true | false
        */
  -    public void setClearOnEval(boolean b);
  +    //public void setClearOnEval(boolean b);
   
   }
  
  
  
  1.2       +5 -44     jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/AbstractStorelessUnivariateStatistic.java
  
  Index: AbstractStorelessUnivariateStatistic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/AbstractStorelessUnivariateStatistic.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractStorelessUnivariateStatistic.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ AbstractStorelessUnivariateStatistic.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -65,57 +65,18 @@
       extends AbstractUnivariateStatistic
       implements StorelessUnivariateStatistic {
   
  -    protected boolean clearOnEval = true;
  -
  -    protected boolean init = true;
  -    
       /**
        * This implements the AbstractUnivariateStatistic impl to funnel 
        * calculation off to the instantanious increment method.
        * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
        */
  -    public double evaluate(double[] d, int start, int length) {
  -
  -        if (clearOnEval)
  +    public double evaluate(double[] values, int begin, int length) {
  +        if (this.test(values, begin, length)) {
               this.clear();
  -
  -        for (int i = start; i < start + length; i++) {
  -            increment(d[i]);
  +            for (int i = begin; i < begin + length; i++) {
  +                increment(values[i]);
  +            }
           }
  -
           return getValue();
       }
  -
  -    /**
  -     * Implement this delegated internalClear()
  -     * to cleanup the state of your implementation on clear().
  -     */
  -    protected abstract void internalClear();
  -    
  -    /**
  -     * This implementation is finalized so the implementor does not have to manage
  -     * clearing its state. They just need to implement their delegated internalClear()
  -     * to cleanup the state of their implementation on clear().
  -     * 
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  -     */
  -    public final void clear(){
  -        init = true;
  -        internalClear();
  -    }
  -    
  -    /**
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#isClearOnEval()
  -     */
  -    public boolean isClearOnEval() {
  -        return clearOnEval;
  -    }
  -
  -    /**
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#setClearOnEval(boolean)
  -     */
  -    public void setClearOnEval(boolean b) {
  -        clearOnEval = b;
  -    }
  -
   }
  
  
  
  1.2       +27 -7     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Max.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ Max.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -53,14 +53,20 @@
    */
   package org.apache.commons.math.stat.univariate.rank;
   
  -import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
  +import org
  +    .apache
  +    .commons
  +    .math
  +    .stat
  +    .univariate
  +    .AbstractStorelessUnivariateStatistic;
   
   /**
    * @author Mark Diggory
    */
   public class Max extends AbstractStorelessUnivariateStatistic {
   
  -    double value = Double.NaN;
  +    private double value = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
  @@ -70,16 +76,30 @@
       }
   
       /**
  +         * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +         */
  +    public void clear() {
  +        value = Double.NaN;
  +    }
  +
  +    /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
           return value;
       }
   
  -    /**
  -     * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  +    /* (non-Javadoc)
  +     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
        */
  -    protected void internalClear() {
  -        value = Double.NaN;
  +    public double evaluate(double[] values, int begin, int length) {
  +        double max = Double.NaN;
  +        if (test(values, begin, length)) {
  +            max = values[begin];
  +            for (int i = begin; i < begin + length; i++) {
  +                max = (max > values[i]) ? max : values[i];
  +            }
  +        }
  +        return max;
       }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.2       +28 -7     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Min.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ Min.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -53,23 +53,37 @@
    */
   package org.apache.commons.math.stat.univariate.rank;
   
  -import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
  +import org
  +    .apache
  +    .commons
  +    .math
  +    .stat
  +    .univariate
  +    .AbstractStorelessUnivariateStatistic;
   
   /**
    * @author Mark Diggory
    */
   public class Min extends AbstractStorelessUnivariateStatistic {
   
  -    double value = Double.NaN;
  +    private double value = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public double increment(double d) {
  -        return value = Double.isNaN(value) ? d : Math.min(value, d);
  +        value = Double.isNaN(value) ? d : Math.min(value, d);
  +        return value;
       }
   
       /**
  +     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     */
  +    public void clear() {
  +        value = Double.NaN;
  +    }
  +    
  +    /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
        */
       public double getValue() {
  @@ -77,9 +91,16 @@
       }
   
       /**
  -     * @see org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic#internalClear()
  +     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
        */
  -    protected void internalClear() {
  -        value = Double.NaN;
  +    public double evaluate(double[] values, int begin, int length) {
  +        double min = Double.NaN;
  +        if (test(values, begin, length)) {
  +            min = values[begin];
  +            for (int i = begin; i < begin + length; i++) {
  +                min = (min < values[i]) ? min : values[i];
  +            }
  +        }
  +        return min;
       }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.2       +11 -11    jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java
  
  Index: Percentile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Percentile.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Percentile.java	5 Jul 2003 18:23:52 -0000	1.1
  +++ Percentile.java	7 Jul 2003 02:15:19 -0000	1.2
  @@ -86,36 +86,36 @@
        * Evaluates the double[] top the specified percentile. 
        * This does not alter the interal percentile state of the 
        * statistic.
  -     * @param d Is a double[] containing the values
  +     * @param values Is a double[] containing the values
        * @param p Is the percentile to evaluate to.
        * @return the result of the evaluation or Double.NaN 
        * if the array is empty
        */
  -    public double evaluate(double[] d, double p) {
  -        return evaluate(d, 0,d.length, p);
  +    public double evaluate(double[] values, double p) {
  +        return evaluate(values, 0,values.length, p);
       }
       
       /**
        * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int, int)
        */
  -    public double evaluate(double[] d, int start, int length) {
  -        return evaluate(d, start, length, percentile);
  +    public double evaluate(double[] values, int start, int length) {
  +        return evaluate(values, start, length, percentile);
       }
   
       /**
        * Evaluates the double[] top the specified percentile. 
        * This does not alter the interal percentile state of the 
        * statistic.
  -     * @param d Is a double[] containing the values
  +     * @param values Is a double[] containing the values
        * @param begin processing at this point in the array
        * @param length processing at this point in the array
        * @param p Is the percentile to evaluate to.* 
        * @return the result of the evaluation or Double.NaN 
        * if the array is empty
        */
  -    public double evaluate(double[] d, int start, int length, double p) {
  +    public double evaluate(double[] values, int begin, int length, double p) {
   
  -        test(d,start,length);
  +        test(values,begin,length);
           
           if ((p > 100) || (p <= 0)) {
               throw new IllegalArgumentException("invalid percentile value");
  @@ -125,14 +125,14 @@
               return Double.NaN;
           }
           if (n == 1) {
  -            return d[start]; // always return single value for n = 1
  +            return values[begin]; // always return single value for n = 1
           }
           double pos = p * (n + 1) / 100;
           double fpos = Math.floor(pos);
           int intPos = (int) fpos;
           double dif = pos - fpos;
           double[] sorted = new double[length];
  -        System.arraycopy(d, start,sorted, 0, length);
  +        System.arraycopy(values, begin,sorted, 0, length);
           Arrays.sort(sorted);
           
           if (pos < 1) {
  @@ -158,7 +158,7 @@
       /**
        * The default internal state of this percentile can be set.
        * This will setthat value.
  -     * @param d a value between 0 <= p <= 100
  +     * @param p a value between 0 <= p <= 100
        */
       public void setPercentile(double p) {
           percentile = p;
  
  
  

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


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

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
I completely missed this because I did'nt have a test in place for 
GeometricMean, the stat itself was very buggy and I improved it now and 
added a test.

-Mark

Mark R. Diggory wrote:

> opse, thank you for catching that, it was not my intent. It should 
> have just been:
>
> value = Math.exp( sumLog.increment(d) / (double)n );
>
> Anton Tagunov wrote:
>
>> Hello, Mark!
>>
>> mao>   +        sumLog.increment(d);
>> mao>   +        value = Math.exp( sumLog.increment(d) / (double)n );
>>
>> Has this double subLog.increment(d) been intentional?
>> ;-)
>>
>> -Anton
>


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


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

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
opse, thank you for catching that, it was not my intent. It should have 
just been:

value = Math.exp( sumLog.increment(d) / (double)n );

Anton Tagunov wrote:
> Hello, Mark!
> 
> mao>   +        sumLog.increment(d);
> mao>   +        value = Math.exp( sumLog.increment(d) / (double)n );
> 
> Has this double subLog.increment(d) been intentional?
> ;-)
> 
> -Anton
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


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


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

Posted by Anton Tagunov <at...@mail.cnt.ru>.
Hello, Mark!

mao>   +        sumLog.increment(d);
mao>   +        value = Math.exp( sumLog.increment(d) / (double)n );

Has this double subLog.increment(d) been intentional?
;-)

-Anton


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