commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdigg...@apache.org
Subject cvs commit: jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment Variance.java Mean.java FirstMoment.java
Date Tue, 15 Jul 2003 03:36:36 GMT
mdiggory    2003/07/14 20:36:36

  Modified:    math/src/java/org/apache/commons/math/stat/univariate/moment
                        Variance.java Mean.java FirstMoment.java
  Log:
  minor javadoc cleanup
  
  Revision  Changes    Path
  1.7       +10 -13    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Variance.java	9 Jul 2003 20:04:10 -0000	1.6
  +++ Variance.java	15 Jul 2003 03:36:36 -0000	1.7
  @@ -53,13 +53,7 @@
    */
   package org.apache.commons.math.stat.univariate.moment;
   
  -import org
  -    .apache
  -    .commons
  -    .math
  -    .stat
  -    .univariate
  -    .AbstractStorelessUnivariateStatistic;
  +import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
   
   /**
    *
  @@ -84,7 +78,8 @@
           this.moment = m2;
       }
       /**
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
  +     * @see org.apache.commons.math.stat.univariate.
  +     * StorelessUnivariateStatistic#increment(double)
        */
       public void increment(double d) {
           if (incMoment) {
  @@ -93,7 +88,8 @@
       }
   
       /**
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
  +     * @see org.apache.commons.math.stat.univariate.
  +     * StorelessUnivariateStatistic#getValue()
        */
       public double getResult() {
           if (n < moment.n) {
  @@ -111,7 +107,8 @@
       }
   
       /**
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     * @see org.apache.commons.math.stat.univariate.
  +     * StorelessUnivariateStatistic#clear()
        */
       public void clear() {
           if (incMoment) {
  @@ -122,7 +119,6 @@
       }
   
       /*UnvariateStatistic Approach */
  -
       Mean mean = new Mean();
   
       /**
  @@ -140,7 +136,8 @@
        * @param length processing at this point in the array
        * @return the result, Double.NaN if no values for an empty array 
        * or 0.0 for a single value set.  
  -     * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[],
int, int)
  +     * @see org.apache.commons.math.stat.univariate.
  +     * UnivariateStatistic#evaluate(double[], int, int)
        */
       public double evaluate(double[] values, int begin, int length) {
   
  
  
  
  1.7       +7 -4      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Mean.java	9 Jul 2003 20:04:10 -0000	1.6
  +++ Mean.java	15 Jul 2003 03:36:36 -0000	1.7
  @@ -53,6 +53,7 @@
    */
   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;
   
   /**
  @@ -60,7 +61,7 @@
    * arithmetic mean </a> of the available values.
    * @version $Revision$ $Date$
    */
  -public class Mean extends Sum {
  +public class Mean extends AbstractStorelessUnivariateStatistic {
   
       /** first moment of values that have been added */
       protected FirstMoment moment = null;
  @@ -100,6 +101,9 @@
       public double getResult() {
           return moment.m1;
       }
  +
  +    /*UnvariateStatistic Approach */
  +    Sum sum = new Sum();
       
       /**
        * Returns the <a href="http://www.xycoon.com/arithmetic_mean.htm">
  @@ -112,9 +116,8 @@
        */
       public double evaluate(double[] values, int begin, int length) {
           if (test(values, begin, length)) {
  -            return super.evaluate(values, begin, length) / ((double) length);
  +            return sum.evaluate(values) / ((double) length);
           }
           return Double.NaN;
       }
  -
   }
  
  
  
  1.5       +30 -18    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FirstMoment.java	9 Jul 2003 20:04:10 -0000	1.4
  +++ FirstMoment.java	15 Jul 2003 03:36:36 -0000	1.5
  @@ -71,45 +71,57 @@
   
       /** first moment of values that have been added */
       protected double m1 = Double.NaN;
  -    
  -    /** temporary internal state made available for higher order moments */
  +
  +    /** 
  +     * temporary internal state made available for
  +     * higher order moments 
  +     */
       protected double dev = 0.0;
  -    
  -    /** temporary internal state made available for higher order moments */
  +
  +    /** 
  +     * temporary internal state made available for
  +     * higher order moments 
  +     */
       protected double v = 0.0;
  -    
  -    /** temporary internal state made available for higher order moments */
  +
  +    /** 
  +     * temporary internal state made available for
  +     * higher order moments 
  +     */
       protected double n0 = 0.0;
  -    
  +
       /**
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
  +     * @see org.apache.commons.math.stat.univariate.
  +     * StorelessUnivariateStatistic#increment(double)
        */
       public void increment(double d) {
           if (n < 1) {
  -             m1 = 0.0;
  +            m1 = 0.0;
           }
  -        
  +
           n++;
           dev = d - m1;
  -        n0 = (double)n;
  +        n0 = (double) n;
           v = dev / n0;
   
  -        m1 += v;                   
  +        m1 += v;
       }
  -    
  +
       /**
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
  +     * @see org.apache.commons.math.stat.univariate.
  +     * StorelessUnivariateStatistic#clear()
        */
       public void clear() {
           m1 = Double.NaN;
           n = 0;
           dev = 0.0;
           v = 0.0;
  -        n0 = 0.0;  
  +        n0 = 0.0;
       }
  -    
  +
       /**
  -     * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
  +     * @see org.apache.commons.math.stat.univariate.
  +     * StorelessUnivariateStatistic#getValue()
        */
       public double getResult() {
           return m1;
  
  
  

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


Mime
View raw message