Corrected javadoc, minor improvment to computation.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141132 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f5ae32413a
commit
f630d0f9ae
|
@ -17,16 +17,18 @@ package org.apache.commons.math.stat.univariate.moment;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org
|
import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic;
|
||||||
.apache
|
|
||||||
.commons
|
|
||||||
.math
|
|
||||||
.stat
|
|
||||||
.univariate
|
|
||||||
.AbstractStorelessUnivariateStatistic;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version $Revision: 1.17 $ $Date: 2004/03/04 04:25:09 $
|
* 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: 1.18 $ $Date: 2004/03/21 00:22:26 $
|
||||||
*/
|
*/
|
||||||
public class Kurtosis extends AbstractStorelessUnivariateStatistic implements Serializable {
|
public class Kurtosis extends AbstractStorelessUnivariateStatistic implements Serializable {
|
||||||
|
|
||||||
|
@ -119,16 +121,10 @@ public class Kurtosis extends AbstractStorelessUnivariateStatistic implements Se
|
||||||
Mean mean = new Mean();
|
Mean mean = new Mean();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the kurtosis for this collection of values. Kurtosis is a
|
* Returns the kurtosis for this collection of values.
|
||||||
* 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:
|
|
||||||
* <p>
|
* <p>
|
||||||
* "Algorithms for Computing the Sample Variance: Analysis and
|
* See {@link Kurtosis} for the definition used in the computation.
|
||||||
* Recommendations", Chan, T.F., Golub, G.H., and LeVeque, R.J.
|
*
|
||||||
* 1983, American Statistician, vol. 37, pp. 242?247.
|
|
||||||
* </p>
|
|
||||||
* @param values Is a double[] containing the values
|
* @param values Is a double[] containing the values
|
||||||
* @param begin processing at this point in the array
|
* @param begin processing at this point in the array
|
||||||
* @param length the number of elements to include
|
* @param length the number of elements to include
|
||||||
|
@ -169,8 +165,9 @@ public class Kurtosis extends AbstractStorelessUnivariateStatistic implements Se
|
||||||
// standard deviation
|
// standard deviation
|
||||||
double accum3 = 0.0;
|
double accum3 = 0.0;
|
||||||
for (int i = begin; i < begin + length; i++) {
|
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
|
// Get N
|
||||||
double n0 = length;
|
double n0 = length;
|
||||||
|
|
Loading…
Reference in New Issue