mdiggory 2003/07/09 09:24:18
Modified: math/src/java/org/apache/commons/math/stat/univariate/moment
FourthMoment.java GeometricMean.java
FirstMoment.java Mean.java ThirdMoment.java
Kurtosis.java Variance.java Skewness.java
StandardDeviation.java SecondMoment.java
math/src/java/org/apache/commons/math/stat/univariate/summary
SumOfSquares.java Product.java Sum.java
SumOfLogs.java
math/src/java/org/apache/commons/math/stat/univariate
UnivariateStatistic.java
AbstractUnivariateStatistic.java
StorelessUnivariateStatistic.java
AbstractStorelessUnivariateStatistic.java
math/src/java/org/apache/commons/math/stat/univariate/rank
Max.java Min.java
Log:
In cases where "getResult" contains a statistical calculation, it now
checks if the internal state of the underlying statistic has changed
and only recalculates if this is true. this way muliple calls to getResult
when the staistic has not been incremented are less expensive
because it is only returning a property value.
Revision Changes Path
1.5 +1 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/FourthMoment.java
Index: FourthMoment.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/FourthMoment.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FourthMoment.java 8 Jul 2003 03:44:11 -0000 1.4
+++ FourthMoment.java 9 Jul 2003 16:24:16 -0000 1.5
@@ -95,7 +95,7 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return m4;
}
1.7 +16 -8
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/GeometricMean.java
Index: GeometricMean.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/GeometricMean.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GeometricMean.java 8 Jul 2003 03:44:12 -0000 1.6
+++ GeometricMean.java 9 Jul 2003 16:24:16 -0000 1.7
@@ -60,9 +60,12 @@
*
*/
public class GeometricMean extends SumOfLogs {
-
- private int n = 0;
+
+ protected int n = 0;
+
+ private double geoMean = Double.NaN;
+ private double lastSum = 0.0;
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
*/
@@ -74,8 +77,12 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
- return Math.exp( super.getValue() / (double)n );
+ public double getResult() {
+ if (lastSum != super.getResult() || n == 1) {
+ lastSum = super.getResult();
+ geoMean = Math.exp(lastSum / (double) n);
+ }
+ return geoMean;
}
/**
@@ -83,9 +90,11 @@
*/
public void clear() {
super.clear();
+ lastSum = 0.0;
+ geoMean = Double.NaN;
n = 0;
}
-
+
/**
* Returns the geometric mean for this collection of values
* @param values Is a double[] containing the values
@@ -96,9 +105,8 @@
* @see
org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int,
int)
*/
public double evaluate(double[] values, int begin, int length) {
- return Math.exp(super.evaluate(values, begin, length) / (double) length );
+ return Math.exp(
+ super.evaluate(values, begin, length) / (double) length);
}
-
-
}
1.3 +3 -3
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/FirstMoment.java
Index: FirstMoment.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/FirstMoment.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FirstMoment.java 8 Jul 2003 03:44:12 -0000 1.2
+++ FirstMoment.java 9 Jul 2003 16:24:16 -0000 1.3
@@ -88,7 +88,7 @@
n0 = (double)n;
v = dev / n0;
- m1 += v;
+ m1 += v;
}
/**
@@ -99,13 +99,13 @@
n = 0;
dev = 0.0;
v = 0.0;
- n0 = 0.0;
+ n0 = 0.0;
}
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return m1;
}
1.5 +3 -3
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Mean.java
Index: Mean.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Mean.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Mean.java 8 Jul 2003 03:44:12 -0000 1.4
+++ Mean.java 9 Jul 2003 16:24:16 -0000 1.5
@@ -102,16 +102,16 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return moment.m1;
}
-
+
/*UnvariateStatistic Approach */
Sum sum = new Sum();
/**
* Returns the <a href=http://www.xycoon.com/arithmetic_mean.htm>
- * arithmetic mean </a> of the available values
+ * arithmetic mean </a> of the available values.
* @param values Is a double[] containing the values
* @param begin processing at this point in the array
* @param length processing at this point in the array
1.5 +1 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/ThirdMoment.java
Index: ThirdMoment.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/ThirdMoment.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ThirdMoment.java 8 Jul 2003 03:44:12 -0000 1.4
+++ ThirdMoment.java 9 Jul 2003 16:24:16 -0000 1.5
@@ -95,7 +95,7 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return m3;
}
1.5 +37 -22
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java
Index: Kurtosis.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Kurtosis.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Kurtosis.java 8 Jul 2003 03:44:12 -0000 1.4
+++ Kurtosis.java 9 Jul 2003 16:24:16 -0000 1.5
@@ -70,6 +70,10 @@
protected boolean incMoment = true;
+ private double kurtosis = Double.NaN;
+
+ private int n = 0;
+
public Kurtosis() {
moment = new FourthMoment();
}
@@ -91,23 +95,31 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
-
- if (moment.n <= 0) {
- return Double.NaN;
+ public double getResult() {
+ if (n < moment.n) {
+ if (moment.n <= 0) {
+ kurtosis = Double.NaN;
+ }
+
+ double variance =
+ (moment.n < 1) ? 0.0 : moment.m2 / (double) (moment.n - 1);
+
+ if (moment.n <= 3 || variance < 10E-20) {
+ kurtosis = 0.0;
+ } else {
+ kurtosis =
+ (moment.n0 * (moment.n0 + 1) * moment.m4
+ - 3 * moment.m2 * moment.m2 * moment.n1)
+ / (moment.n1
+ * moment.n2
+ * moment.n3
+ * variance
+ * variance);
+ }
+ n = moment.n;
}
-
- double variance =
- (moment.n < 1) ? 0.0 : moment.m2 / (double) (moment.n - 1);
-
- if (moment.n <= 3 || variance < 10E-20) {
- return 0.0;
- }
-
- return (moment.n0 * (moment.n0 + 1) * moment.m4
- - 3 * moment.m2 * moment.m2 * moment.n1)
- / (moment.n1 * moment.n2 * moment.n3 * variance * variance);
-
+
+ return kurtosis;
}
/**
@@ -117,6 +129,8 @@
if (incMoment) {
moment.clear();
}
+ kurtosis = Double.NaN;
+ n = 0;
}
/*UnvariateStatistic Approach */
@@ -125,12 +139,13 @@
/**
* 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/>
- * "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/>
+ * <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>
+ * "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>
* Returns the kurtosis for this collection of values. Kurtosis is a
* measure of the "peakedness" of a distribution.
* @param values Is a double[] containing the values
1.5 +21 -8
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java
Index: Variance.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Variance.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Variance.java 8 Jul 2003 03:44:12 -0000 1.4
+++ Variance.java 9 Jul 2003 16:24:16 -0000 1.5
@@ -71,6 +71,10 @@
protected boolean incMoment = true;
+ protected double variance = Double.NaN;
+
+ protected int n = 0;
+
public Variance() {
moment = new SecondMoment();
}
@@ -91,13 +95,19 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
- if (moment.n <= 0) {
- return Double.NaN;
- } else if (moment.n <= 1) {
- return 0.0;
+ public double getResult() {
+ if (n < moment.n) {
+ if (moment.n <= 0) {
+ variance = Double.NaN;
+ } else if (moment.n <= 1) {
+ variance = 0.0;
+ } else {
+ variance = moment.m2 / (moment.n0 - 1);
+ }
+ n = moment.n;
}
- return moment.m2 / (moment.n0 - 1);
+
+ return variance;
}
/**
@@ -107,6 +117,8 @@
if (incMoment) {
moment.clear();
}
+ variance = Double.NaN;
+ n = 0;
}
/*UnvariateStatistic Approach */
@@ -117,11 +129,12 @@
* Returns the variance of the available values. This 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/>
+ * corrected two pass formula (14.1.8)</a>, and also referenced in:
+ * <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>
* @param values Is a double[] containing the values
* @param begin processing at this point in the array
* @param length processing at this point in the array
1.5 +31 -16
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java
Index: Skewness.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/Skewness.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Skewness.java 8 Jul 2003 03:44:12 -0000 1.4
+++ Skewness.java 9 Jul 2003 16:24:17 -0000 1.5
@@ -71,6 +71,10 @@
protected boolean incMoment = true;
+ protected double skewness = Double.NaN;
+
+ private int n = 0;
+
public Skewness() {
moment = new ThirdMoment();
}
@@ -92,20 +96,28 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
- if (moment.n <= 0) {
- return Double.NaN;
- }
-
- double variance =
- (moment.n < 1) ? 0.0 : moment.m2 / (double) (moment.n - 1);
-
- if (moment.n <= 2 || variance < 10E-20) {
- return 0.0;
+ public double getResult() {
+ if (n < moment.n) {
+ if (moment.n <= 0) {
+ skewness = Double.NaN;
+ }
+
+ double variance =
+ (moment.n < 1) ? 0.0 : moment.m2 / (double) (moment.n - 1);
+
+ if (moment.n <= 2 || variance < 10E-20) {
+ skewness = 0.0;
+ } else {
+ skewness =
+ (moment.n0 * moment.m3)
+ / (moment.n1
+ * moment.n2
+ * Math.sqrt(variance)
+ * variance);
+ }
+ n = moment.n;
}
-
- return (moment.n0 * moment.m3)
- / (moment.n1 * moment.n2 * Math.sqrt(variance) * variance);
+ return skewness;
}
/**
@@ -115,8 +127,10 @@
if (incMoment) {
moment.clear();
}
+ skewness = Double.NaN;
+ n = 0;
}
-
+
/*UnvariateStatistic Approach */
Mean mean = new Mean();
@@ -124,11 +138,12 @@
/**
* 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/>
+ * corrected two pass formula (14.1.8)</a>, and also referenced in:
+ * <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/>
+ * </p>
* Returns the skewness of a collection of values. Skewness is a
* measure of the assymetry of a given distribution.
* @param values Is a double[] containing the values
1.5 +25 -19
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/StandardDeviation.java
Index: StandardDeviation.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/StandardDeviation.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StandardDeviation.java 8 Jul 2003 03:44:12 -0000 1.4
+++ StandardDeviation.java 9 Jul 2003 16:24:17 -0000 1.5
@@ -59,42 +59,48 @@
*/
public class StandardDeviation extends Variance {
- public StandardDeviation(){
+ protected double std = Double.NaN;
+
+ private double lastVar = 0.0;
+
+ public StandardDeviation() {
super();
}
-
- public StandardDeviation(SecondMoment m2){
+
+ public StandardDeviation(SecondMoment m2) {
super(m2);
}
-
+
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#increment(double)
*/
public void increment(double d) {
- super.increment(d);
+ super.increment(d);
}
-
+
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
-
- double var = super.getValue();
-
- if(Double.isNaN(var)){
- return Double.NaN;
- }else if (var == 0.0){
- return 0.0;
+ public double getResult() {
+ if (lastVar != super.getResult()) {
+ lastVar = super.getResult();
+ if (Double.isNaN(lastVar)) {
+ std = Double.NaN;
+ } else if (lastVar == 0.0) {
+ std = 0.0;
+ } else {
+ std = Math.sqrt(lastVar);
+ }
}
-
- return Math.sqrt(var);
+ return std;
}
-
+
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#clear()
*/
public void clear() {
super.clear();
+ lastVar = 0.0;
}
/**
@@ -108,8 +114,8 @@
*/
public double evaluate(double[] values, int begin, int length) {
double var = super.evaluate(values, begin, length);
-
- if(Double.isNaN(var)){
+
+ if (Double.isNaN(var)) {
return Double.NaN;
}
1.5 +2 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/SecondMoment.java
Index: SecondMoment.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/moment/SecondMoment.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SecondMoment.java 8 Jul 2003 03:44:12 -0000 1.4
+++ SecondMoment.java 9 Jul 2003 16:24:17 -0000 1.5
@@ -80,6 +80,7 @@
/* increment and return m2 */
m2 += n1 * dev * v;
+
}
/**
@@ -94,7 +95,7 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return m2;
}
1.5 +1 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/SumOfSquares.java
Index: SumOfSquares.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/SumOfSquares.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SumOfSquares.java 8 Jul 2003 03:44:12 -0000 1.4
+++ SumOfSquares.java 9 Jul 2003 16:24:18 -0000 1.5
@@ -85,7 +85,7 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return value;
}
1.5 +1 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/Product.java
Index: Product.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/Product.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Product.java 8 Jul 2003 03:44:12 -0000 1.4
+++ Product.java 9 Jul 2003 16:24:18 -0000 1.5
@@ -85,7 +85,7 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return value;
}
1.5 +1 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/Sum.java
Index: Sum.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/Sum.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Sum.java 8 Jul 2003 03:44:12 -0000 1.4
+++ Sum.java 9 Jul 2003 16:24:18 -0000 1.5
@@ -85,7 +85,7 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return value;
}
1.5 +1 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/SumOfLogs.java
Index: SumOfLogs.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/summary/SumOfLogs.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SumOfLogs.java 8 Jul 2003 03:44:12 -0000 1.4
+++ SumOfLogs.java 9 Jul 2003 16:24:18 -0000 1.5
@@ -87,7 +87,7 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return value;
}
1.3 +0 -2
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/UnivariateStatistic.java
Index: UnivariateStatistic.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/UnivariateStatistic.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UnivariateStatistic.java 7 Jul 2003 02:15:19 -0000 1.2
+++ UnivariateStatistic.java 9 Jul 2003 16:24:18 -0000 1.3
@@ -54,8 +54,6 @@
package org.apache.commons.math.stat.univariate;
/**
- * @author Mark Diggory
- *
* UnivariateStatistic interface provides methods to evaluate
* double[] based content using a particular algorithm.
*
1.3 +0 -2
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/AbstractUnivariateStatistic.java
Index: AbstractUnivariateStatistic.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/AbstractUnivariateStatistic.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractUnivariateStatistic.java 7 Jul 2003 02:15:19 -0000 1.2
+++ AbstractUnivariateStatistic.java 9 Jul 2003 16:24:18 -0000 1.3
@@ -57,8 +57,6 @@
* Abstract Implementation for UnivariateStatistics.
* Provides the ability to extend polymophically so that
* indiviual statistics do not need to implement these methods.
- *
- * @author Mark Diggory
*/
public abstract class AbstractUnivariateStatistic
implements UnivariateStatistic {
1.4 +7 -26
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/StorelessUnivariateStatistic.java
Index: StorelessUnivariateStatistic.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/StorelessUnivariateStatistic.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StorelessUnivariateStatistic.java 8 Jul 2003 03:44:12 -0000 1.3
+++ StorelessUnivariateStatistic.java 9 Jul 2003 16:24:18 -0000 1.4
@@ -55,9 +55,11 @@
/**
* StorelessUnivariate interface provides methods to increment and access
- * the internal state of the Statistic.
- *
- * @author Mark Diggory
+ * the internal state of the Statistic. A StorelessUnivariateStatistic does
+ * not require that a double[] storage structure be maintained with the values
+ * in it. As such only a subset of known statistics can actually be implmented
+ * using it. If a Statistic cannot be implemented in a Storeless approach it
+ * should implement the UnivariateStatistic interface directly instead.
*/
public interface StorelessUnivariateStatistic extends UnivariateStatistic {
@@ -65,42 +67,21 @@
* Increments the internal state of the Storagless
* Implementation.
* @param d is the value to increment the state by.
- * @return the new state of this Statistic. Returns
- * the same value as <code>getValue()</code>, Double.NaN if it
- * has been cleared or just instantiated.
*/
public void increment(double d);
/**
* Returns the current state of the statistic after the
* last increment.
- * @return values of the statistic, Double.NaN if it
+ * @return value of the statistic, Double.NaN if it
* has been cleared or just instantiated.
*/
- public double getValue();
+ public double getResult();
/**
* Clears all the internal state of the Statistic
*/
public void clear();
-
- /**
- * Returns the behavior of this statistic when evaluating
- * double[]'s using <code>evaluate(double[], int, int)</code> and
- * <code>evaluate(double[])</code> methods.
- * @return the state
- */
- //public boolean isClearOnEval();
-
- /**
- * Sets the behavior of this statistic when evaluating
- * double[]'s using <code>evaluate(double[], int, int)</code> and
- * <code>evaluate(double[])</code> methods. if true, the internal state
- * will be cleared between evaluations, otherwise it will be
- * incrimented.
- * @param b true | false
- */
- //public void setClearOnEval(boolean b);
}
1.3 +6 -5
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/AbstractStorelessUnivariateStatistic.java
Index: AbstractStorelessUnivariateStatistic.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/AbstractStorelessUnivariateStatistic.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractStorelessUnivariateStatistic.java 7 Jul 2003 02:15:19 -0000 1.2
+++ AbstractStorelessUnivariateStatistic.java 9 Jul 2003 16:24:18 -0000 1.3
@@ -57,9 +57,8 @@
*
* Abstract Implementation for StorelessUnivariateStatistics.
* Provides the ability to extend polymophically so that
- * indiviual statistics do not need to implement these methods
- *
- * @author Mark Diggory
+ * indiviual statistics do not need to implement these methods unless
+ * there are better algorithms for handling the calculation.
*/
public abstract class AbstractStorelessUnivariateStatistic
extends AbstractUnivariateStatistic
@@ -67,7 +66,9 @@
/**
* This implements the AbstractUnivariateStatistic impl to funnel
- * calculation off to the instantanious increment method.
+ * calculation off to the instantanious increment method. In most cases of
+ * StorelessUnivariateStatistic this is never really used because more
+ * efficient algorithms are available for that statistic.
* @see
org.apache.commons.math.stat.univariate.UnivariateStatistic#evaluate(double[], int,
int)
*/
public double evaluate(double[] values, int begin, int length) {
@@ -77,6 +78,6 @@
increment(values[i]);
}
}
- return getValue();
+ return getResult();
}
}
1.5 +1 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java
Index: Max.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Max.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Max.java 8 Jul 2003 03:44:12 -0000 1.4
+++ Max.java 9 Jul 2003 16:24:18 -0000 1.5
@@ -85,7 +85,7 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return value;
}
1.5 +1 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Min.java
Index: Min.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/univariate/rank/Min.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Min.java 8 Jul 2003 03:44:12 -0000 1.4
+++ Min.java 9 Jul 2003 16:24:18 -0000 1.5
@@ -85,7 +85,7 @@
/**
* @see
org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic#getValue()
*/
- public double getValue() {
+ public double getResult() {
return value;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]