commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank Max.java
Date Fri, 18 Jun 2004 13:24:06 GMT
psteitz     2004/06/18 06:24:06

  Modified:    math/src/java/org/apache/commons/math/stat/univariate/rank
                        Max.java
  Log:
  Made increment and evaluate methods consistent wrt NaN values, improved javadoc, formatting.
  
  Revision  Changes    Path
  1.17      +15 -15    jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java
  
  Index: Max.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Max.java	27 Apr 2004 16:42:33 -0000	1.16
  +++ Max.java	18 Jun 2004 13:24:06 -0000	1.17
  @@ -17,16 +17,17 @@
   
   import java.io.Serializable;
   
  -import org
  -    .apache
  -    .commons
  -    .math
  -    .stat
  -    .univariate
  -    .AbstractStorelessUnivariateStatistic;
  +import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
   
   /**
    * Returns the maximum of the available values.
  + * <p>
  + * <ul>
  + * <li>The result is <code>NaN</code> iff all values are <code>NaN</code>

  + * (i.e. <code>NaN</code> values have no impact on the value of the statistic).</li>
  + * <li>If any of the values equals <code>Double.POSITIVE_INFINITY</code>,

  + * the result is <code>Double.POSITIVE_INFINITY.</code></li>
  + * </ul>
    * 
    * @version $Revision$ $Date$
    */
  @@ -35,17 +36,19 @@
       /** Serializable version identifier */
       static final long serialVersionUID = -5593383832225844641L;    
       
  -    /** */
  +    /** Number of values that have been added */
       private long n = 0;
           
  -    /** */
  +    /** Current value of the statistic */
       private double value = Double.NaN;
   
       /**
        * @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
        */
       public void increment(final double d) {
  -        value = Double.isNaN(value) ? d : Math.max(value, d);
  +        if (d > value || Double.isNaN(value)) {
  +            value = d;
  +        }
           n++;
       }
   
  @@ -76,10 +79,7 @@
        * 
        * @see org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[],
int, int)
        */
  -    public double evaluate(
  -        final double[] values,
  -        final int begin,
  -        final int length) {
  +    public double evaluate(final double[] values, final int begin, final int length) {
           double max = Double.NaN;
           if (test(values, begin, length)) {
               max = values[begin];
  
  
  

---------------------------------------------------------------------
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