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 Kurtosis.java
Date Sun, 21 Mar 2004 00:22:26 GMT
psteitz     2004/03/20 16:22:26

  Modified:    math/src/java/org/apache/commons/math/stat/univariate/moment
                        Kurtosis.java
  Log:
  Corrected javadoc, minor improvment to computation.
  
  Revision  Changes    Path
  1.18      +15 -18    jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java
  
  Index: Kurtosis.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Kurtosis.java	4 Mar 2004 04:25:09 -0000	1.17
  +++ Kurtosis.java	21 Mar 2004 00:22:26 -0000	1.18
  @@ -17,15 +17,17 @@
   
   import java.io.Serializable;
   
  -import org
  -    .apache
  -    .commons
  -    .math
  -    .stat
  -    .univariate
  -    .AbstractStorelessUnivariateStatistic;
  +import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
   
   /**
  + * Computes <a href="http://en.wikipedia.org/wiki/Kurtosis">Kurtosis</a>.
  + * <p>
  + * We use the following (unbiased) formula to define kurtosis:
  + *  <p>
  + *  kurtosis = { [n(n+1) / (n -1)(n - 2)(n-3)] sum[(x_i - mean)^4] / std^4 } - [3(n-1)^2
/ (n-2)(n-3)]
  + *  <p>
  + *  where n is the number of values, mean is the {@link Mean} and std is the {@link StandardDeviation}
  + * 
    * @version $Revision$ $Date$
    */
   public class Kurtosis extends AbstractStorelessUnivariateStatistic implements Serializable
{
  @@ -119,16 +121,10 @@
       Mean mean = new Mean();
   
       /**
  -     * Returns the kurtosis for this collection of values. Kurtosis is a
  -     * measure of the "peakedness" of a distribution.  This algorithm uses a
  -     * corrected two pass algorithm of the following
  -     * <a href="http://lib-www.lanl.gov/numerical/bookcpdf/c14-1.pdf">
  -     * corrected two pass formula (14.1.8)</a>, and also referenced in:
  +     * Returns the kurtosis for this collection of values.  
        * <p>
  -     * "Algorithms for Computing the Sample Variance: Analysis and
  -     * Recommendations", Chan, T.F., Golub, G.H., and LeVeque, R.J.
  -     * 1983, American Statistician, vol. 37, pp. 242?247.
  -     * </p>
  +     * See {@link Kurtosis} for the definition used in the computation.
  +     * 
        * @param values Is a double[] containing the values
        * @param begin processing at this point in the array
        * @param length the number of elements to include
  @@ -169,8 +165,9 @@
                   // standard deviation
                   double accum3 = 0.0;
                   for (int i = begin; i < begin + length; i++) {
  -                    accum3 += Math.pow((values[i] - m) / stdDev, 4.0);
  +                    accum3 += Math.pow((values[i] - m), 4.0);
                   }
  +                accum3 /= Math.pow(stdDev, 4.0d);
   
                   // Get N
                   double n0 = length;
  
  
  

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