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/moment StandardDeviation.java
Date Wed, 01 Sep 2004 15:54:39 GMT
psteitz     2004/09/01 08:54:39

  Modified:    math/src/java/org/apache/commons/math/stat/univariate/moment
                        StandardDeviation.java
  Log:
  Made assumption about precomputed mean explicit in javadoc.  Added missing method.
  
  Revision  Changes    Path
  1.23      +32 -1     jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/StandardDeviation.java
  
  Index: StandardDeviation.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/StandardDeviation.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- StandardDeviation.java	18 Jul 2004 04:42:02 -0000	1.22
  +++ StandardDeviation.java	1 Sep 2004 15:54:39 -0000	1.23
  @@ -133,6 +133,11 @@
        * <p>
        * Returns 0 for a single-value (i.e. length = 1) sample.
        * <p>
  +     * The formula used assumes that the supplied mean value is the arithmetic
  +     * mean of the sample data, not a known population parameter.  This method
  +     * is supplied only to save computation when the mean has already been
  +     * computed.
  +     * <p>
        * Throws <code>IllegalArgumentException</code> if the array is null.
        * <p>
        * Does not change the internal state of the statistic.
  @@ -148,5 +153,31 @@
       public double evaluate(final double[] values, final double mean,
               final int begin, final int length)  {
           return Math.sqrt(variance.evaluate(values, mean, begin, length));
  +    }
  +    
  +    /**
  +     * Returns the Standard Deviation of the entries in the input array, using
  +     * the precomputed mean value.  Returns
  +     * <code>Double.NaN</code> if the designated subarray is empty.
  +     * <p>
  +     * Returns 0 for a single-value (i.e. length = 1) sample.
  +     * <p>
  +     * The formula used assumes that the supplied mean value is the arithmetic
  +     * mean of the sample data, not a known population parameter.  This method
  +     * is supplied only to save computation when the mean has already been
  +     * computed.
  +     * <p>
  +     * Throws <code>IllegalArgumentException</code> if the array is null.
  +     * <p>
  +     * Does not change the internal state of the statistic.
  +     * 
  +     * @param values the input array
  +     * @param mean the precomputed mean value
  +     * @return the standard deviation of the values or Double.NaN if length = 0
  +     * @throws IllegalArgumentException if the array is null or the array index
  +     *  parameters are not valid
  +     */
  +    public double evaluate(final double[] values, final double mean)  {
  +        return Math.sqrt(variance.evaluate(values, mean));
       }
   }
  
  
  

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