Changed getN() to return long. Changed evalutate() to return NaN if sample size is less than 3 (consistent w/ getResult()).
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9360c37834
commit
5895dba6f5
|
@ -34,7 +34,7 @@ import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatis
|
|||
* one of the threads invokes the <code>increment()</code> or
|
||||
* <code>clear()</code> method, it must be synchronized externally.
|
||||
*
|
||||
* @version $Revision: 1.24 $ $Date: 2004/07/04 09:02:36 $
|
||||
* @version $Revision: 1.25 $ $Date: 2004/07/10 17:02:43 $
|
||||
*/
|
||||
public class Skewness extends AbstractStorelessUnivariateStatistic implements Serializable {
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class Skewness extends AbstractStorelessUnivariateStatistic implements Se
|
|||
/**
|
||||
* @see org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getN()
|
||||
*/
|
||||
public double getN() {
|
||||
public long getN() {
|
||||
return moment.getN();
|
||||
}
|
||||
|
||||
|
@ -139,11 +139,8 @@ public class Skewness extends AbstractStorelessUnivariateStatistic implements Se
|
|||
// Initialize the skewness
|
||||
double skew = Double.NaN;
|
||||
|
||||
if (test(values, begin, length)) {
|
||||
if (test(values, begin, length) && length > 2 ){
|
||||
Mean mean = new Mean();
|
||||
if (length <= 2) {
|
||||
skew = 0.0;
|
||||
} else {
|
||||
// Get the mean and the standard deviation
|
||||
double m = mean.evaluate(values, begin, length);
|
||||
|
||||
|
@ -171,9 +168,6 @@ public class Skewness extends AbstractStorelessUnivariateStatistic implements Se
|
|||
// Calculate skewness
|
||||
skew = (n0 / ((n0 - 1) * (n0 - 2))) * accum3;
|
||||
}
|
||||
}
|
||||
|
||||
return skew;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue