From a6b433d2571ac4eef2e36faa4893b92bfeb974e2 Mon Sep 17 00:00:00 2001 From: Phil Steitz Date: Mon, 14 Jun 2004 23:26:54 +0000 Subject: [PATCH] Formatting only. Removed tabs. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141293 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/math/stat/StatUtils.java | 6 +- .../stat/inference/ChiSquareTestImpl.java | 4 +- .../math/stat/inference/TTestImpl.java | 6 +- .../commons/math/stat/inference/package.html | 10 +- .../math/stat/multivariate/package.html | 8 +- .../org/apache/commons/math/stat/package.html | 4 +- .../univariate/DescriptiveStatistics.java | 318 +++++++++--------- .../univariate/DescriptiveStatisticsImpl.java | 14 +- .../stat/univariate/StatisticalSummary.java | 78 ++--- .../stat/univariate/SummaryStatistics.java | 212 ++++++------ .../univariate/SummaryStatisticsImpl.java | 22 +- .../math/stat/univariate/moment/package.html | 4 +- .../commons/math/stat/univariate/package.html | 46 +-- .../math/stat/univariate/rank/package.html | 4 +- .../math/stat/univariate/summary/package.html | 4 +- 15 files changed, 370 insertions(+), 370 deletions(-) diff --git a/src/java/org/apache/commons/math/stat/StatUtils.java b/src/java/org/apache/commons/math/stat/StatUtils.java index a4f41c45d..33ff1018f 100644 --- a/src/java/org/apache/commons/math/stat/StatUtils.java +++ b/src/java/org/apache/commons/math/stat/StatUtils.java @@ -30,7 +30,7 @@ import org.apache.commons.math.stat.univariate.summary.SumOfSquares; * StatUtils provides static implementations of common double[] based * statistical methods. These return a single result value or in some cases, as * identified in the javadoc for each method, Double.NaN. - * @version $Revision: 1.27 $ $Date: 2004/05/24 05:30:33 $ + * @version $Revision: 1.28 $ $Date: 2004/06/14 23:26:53 $ */ public final class StatUtils { @@ -326,11 +326,11 @@ public final class StatUtils { * (positive) length */ public static double sumDifference(final double[] sample1, final double[] sample2) - throws IllegalArgumentException { + throws IllegalArgumentException { int n = sample1.length; if (n != sample2.length || n < 1) { throw new IllegalArgumentException - ("Input arrays must have the same (positive) length."); + ("Input arrays must have the same (positive) length."); } double result = 0; for (int i = 0; i < n; i++) { diff --git a/src/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java b/src/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java index 2c2dc8197..7134a4c7e 100644 --- a/src/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java +++ b/src/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java @@ -22,7 +22,7 @@ import org.apache.commons.math.distribution.ChiSquaredDistribution; /** * Implements Chi-Square test statistics defined in the {@link ChiSquareTest} interface. * - * @version $Revision: 1.5 $ $Date: 2004/06/06 23:14:09 $ + * @version $Revision: 1.6 $ $Date: 2004/06/14 23:26:53 $ */ public class ChiSquareTestImpl implements ChiSquareTest { @@ -119,7 +119,7 @@ public class ChiSquareTestImpl implements ChiSquareTest { for (int col = 0; col < nCols; col++) { expected = (rowSum[row] * colSum[col]) / total; sumSq += (((double) counts[row][col] - expected) * ((double) counts[row][col] - expected)) - / expected; + / expected; } } return sumSq; diff --git a/src/java/org/apache/commons/math/stat/inference/TTestImpl.java b/src/java/org/apache/commons/math/stat/inference/TTestImpl.java index 25a77f148..96216da9b 100644 --- a/src/java/org/apache/commons/math/stat/inference/TTestImpl.java +++ b/src/java/org/apache/commons/math/stat/inference/TTestImpl.java @@ -24,7 +24,7 @@ import org.apache.commons.math.stat.univariate.StatisticalSummary; /** * Implements t-test statistics defined in the {@link TTest} interface. * - * @version $Revision: 1.6 $ $Date: 2004/06/06 22:28:25 $ + * @version $Revision: 1.7 $ $Date: 2004/06/14 23:26:53 $ */ public class TTestImpl implements TTest { @@ -753,7 +753,7 @@ public class TTestImpl implements TTest { double pooledVariance = ((n1 - 1) * v1 + (n2 -1) * v2 ) / (n1 + n2 - 2); return (m1 - m2) / Math.sqrt(pooledVariance * (1d / n1 + 1d / n2)); } else { - return (m1 - m2) / Math.sqrt((v1 / n1) + (v2 / n2)); + return (m1 - m2) / Math.sqrt((v1 / n1) + (v2 / n2)); } } @@ -798,7 +798,7 @@ public class TTestImpl implements TTest { if (equalVariances) { degreesOfFreedom = (double) (n1 + n2 - 2); } else { - degreesOfFreedom= df(v1, v2, n1, n2); + degreesOfFreedom= df(v1, v2, n1, n2); } TDistribution tDistribution = getDistributionFactory().createTDistribution(degreesOfFreedom); diff --git a/src/java/org/apache/commons/math/stat/inference/package.html b/src/java/org/apache/commons/math/stat/inference/package.html index 3ae9666de..b9dbfd56e 100644 --- a/src/java/org/apache/commons/math/stat/inference/package.html +++ b/src/java/org/apache/commons/math/stat/inference/package.html @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - Classes providing hypothesis testing and confidence interval - construction. - + + + Classes providing hypothesis testing and confidence interval + construction. + diff --git a/src/java/org/apache/commons/math/stat/multivariate/package.html b/src/java/org/apache/commons/math/stat/multivariate/package.html index ed6e7dbef..14c422dba 100644 --- a/src/java/org/apache/commons/math/stat/multivariate/package.html +++ b/src/java/org/apache/commons/math/stat/multivariate/package.html @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - Statistical routines involving multivariate data. - + + + Statistical routines involving multivariate data. + diff --git a/src/java/org/apache/commons/math/stat/package.html b/src/java/org/apache/commons/math/stat/package.html index 49dc75021..23acada82 100644 --- a/src/java/org/apache/commons/math/stat/package.html +++ b/src/java/org/apache/commons/math/stat/package.html @@ -14,6 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. --> - - Data storage, manipulation and summary routines. + + Data storage, manipulation and summary routines. diff --git a/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatistics.java b/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatistics.java index 1bc06e5c0..544169418 100644 --- a/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatistics.java +++ b/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatistics.java @@ -34,203 +34,203 @@ import org.apache.commons.math.stat.univariate.summary.SumOfSquares; /** * Abstract factory class for univariate statistical summaries. * - * @version $Revision: 1.6 $ $Date: 2004/06/01 21:34:35 $ + * @version $Revision: 1.7 $ $Date: 2004/06/14 23:26:53 $ */ public abstract class DescriptiveStatistics implements StatisticalSummary, Serializable { /** Serialization UID */ static final long serialVersionUID = 5188298269533339922L; - /** - * Create an instance of a DescriptiveStatistics + /** + * Create an instance of a DescriptiveStatistics * @param cls the type of DescriptiveStatistics object to * create. - * @return a new factory. + * @return a new factory. * @throws InstantiationException is thrown if the object can not be * created. * @throws IllegalAccessException is thrown if the type's default * constructor is not accessible. * @throws ClassNotFoundException if the named * DescriptiveStatistics type can not be found. - */ - public static DescriptiveStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException { - return newInstance(Class.forName(cls)); - } + */ + public static DescriptiveStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException { + return newInstance(Class.forName(cls)); + } - /** - * Create an instance of a DescriptiveStatistics + /** + * Create an instance of a DescriptiveStatistics * @param cls the type of DescriptiveStatistics object to * create. - * @return a new factory. + * @return a new factory. * @throws InstantiationException is thrown if the object can not be * created. * @throws IllegalAccessException is thrown if the type's default * constructor is not accessible. - */ - public static DescriptiveStatistics newInstance(Class cls) throws InstantiationException, IllegalAccessException { - return (DescriptiveStatistics)cls.newInstance(); - } - - /** - * Create an instance of a DescriptiveStatistics - * @return a new factory. - */ - public static DescriptiveStatistics newInstance() { - DescriptiveStatistics factory = null; - try { - DiscoverClass dc = new DiscoverClass(); - factory = (DescriptiveStatistics) dc.newInstance( - DescriptiveStatistics.class, - "org.apache.commons.math.stat.univariate.DescriptiveStatisticsImpl"); - } catch(Exception ex) { + */ + public static DescriptiveStatistics newInstance(Class cls) throws InstantiationException, IllegalAccessException { + return (DescriptiveStatistics)cls.newInstance(); + } + + /** + * Create an instance of a DescriptiveStatistics + * @return a new factory. + */ + public static DescriptiveStatistics newInstance() { + DescriptiveStatistics factory = null; + try { + DiscoverClass dc = new DiscoverClass(); + factory = (DescriptiveStatistics) dc.newInstance( + DescriptiveStatistics.class, + "org.apache.commons.math.stat.univariate.DescriptiveStatisticsImpl"); + } catch(Exception ex) { ex.printStackTrace(); - // ignore as default implementation will be used. - } - return factory; - } - - /** - * This constant signals that a Univariate implementation - * takes into account the contributions of an infinite number of - * elements. In other words, if getWindow returns this - * constant, there is, in effect, no "window". - */ - public static final int INFINITE_WINDOW = -1; + // ignore as default implementation will be used. + } + return factory; + } + + /** + * This constant signals that a Univariate implementation + * takes into account the contributions of an infinite number of + * elements. In other words, if getWindow returns this + * constant, there is, in effect, no "window". + */ + public static final int INFINITE_WINDOW = -1; - /** - * Adds the value to the set of numbers - * @param v the value to be added - */ - public abstract void addValue(double v); + /** + * Adds the value to the set of numbers + * @param v the value to be added + */ + public abstract void addValue(double v); - /** - * Returns the - * arithmetic mean of the available values - * @return The mean or Double.NaN if no values have been added. - */ + /** + * Returns the + * arithmetic mean of the available values + * @return The mean or Double.NaN if no values have been added. + */ public double getMean() { - return apply(new Mean()); + return apply(new Mean()); } - /** - * Returns the - * geometric mean of the available values - * @return The geometricMean, Double.NaN if no values have been added, - * or if the productof the available values is less than or equal to 0. - */ + /** + * Returns the + * geometric mean of the available values + * @return The geometricMean, Double.NaN if no values have been added, + * or if the productof the available values is less than or equal to 0. + */ public double getGeometricMean() { - return apply(new GeometricMean()); + return apply(new GeometricMean()); } - /** - * Returns the variance of the available values. - * @return The variance, Double.NaN if no values have been added - * or 0.0 for a single value set. - */ + /** + * Returns the variance of the available values. + * @return The variance, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ public double getVariance() { - return apply(new Variance()); + return apply(new Variance()); } - /** - * Returns the standard deviation of the available values. - * @return The standard deviation, Double.NaN if no values have been added - * or 0.0 for a single value set. - */ + /** + * Returns the standard deviation of the available values. + * @return The standard deviation, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ public double getStandardDeviation() { - double stdDev = Double.NaN; - if (getN() > 0) { - if (getN() > 1) { - stdDev = Math.sqrt(getVariance()); - } else { - stdDev = 0.0; - } - } - return (stdDev); + double stdDev = Double.NaN; + if (getN() > 0) { + if (getN() > 1) { + stdDev = Math.sqrt(getVariance()); + } else { + stdDev = 0.0; + } + } + return (stdDev); } - /** - * Returns the skewness of the available values. Skewness is a - * measure of the assymetry of a given distribution. - * @return The skewness, Double.NaN if no values have been added - * or 0.0 for a value set <=2. - */ + /** + * Returns the skewness of the available values. Skewness is a + * measure of the assymetry of a given distribution. + * @return The skewness, Double.NaN if no values have been added + * or 0.0 for a value set <=2. + */ public double getSkewness() { - return apply(new Skewness()); + return apply(new Skewness()); } - /** - * Returns the Kurtosis of the available values. Kurtosis is a - * measure of the "peakedness" of a distribution - * @return The kurtosis, Double.NaN if no values have been added, or 0.0 - * for a value set <=3. - */ + /** + * Returns the Kurtosis of the available values. Kurtosis is a + * measure of the "peakedness" of a distribution + * @return The kurtosis, Double.NaN if no values have been added, or 0.0 + * for a value set <=3. + */ public double getKurtosis() { - return apply(new Kurtosis()); + return apply(new Kurtosis()); } - /** - * Returns the maximum of the available values - * @return The max or Double.NaN if no values have been added. - */ + /** + * Returns the maximum of the available values + * @return The max or Double.NaN if no values have been added. + */ public double getMax() { - return apply(new Max()); + return apply(new Max()); } - /** - * Returns the minimum of the available values - * @return The min or Double.NaN if no values have been added. - */ + /** + * Returns the minimum of the available values + * @return The min or Double.NaN if no values have been added. + */ public double getMin() { - return apply(new Min()); + return apply(new Min()); } - /** - * Returns the number of available values - * @return The number of available values - */ - public abstract long getN(); + /** + * Returns the number of available values + * @return The number of available values + */ + public abstract long getN(); - /** - * Returns the sum of the values that have been added to Univariate. - * @return The sum or Double.NaN if no values have been added - */ + /** + * Returns the sum of the values that have been added to Univariate. + * @return The sum or Double.NaN if no values have been added + */ public double getSum() { - return apply(new Sum()); + return apply(new Sum()); } - /** - * Returns the sum of the squares of the available values. - * @return The sum of the squares or Double.NaN if no - * values have been added. - */ + /** + * Returns the sum of the squares of the available values. + * @return The sum of the squares or Double.NaN if no + * values have been added. + */ public double getSumsq() { - return apply(new SumOfSquares()); + return apply(new SumOfSquares()); } - /** - * Resets all statistics and storage - */ - public abstract void clear(); + /** + * Resets all statistics and storage + */ + public abstract void clear(); - /** - * Univariate has the ability to return only measures for the - * last N elements added to the set of values. - * @return The current window size or -1 if its Infinite. - */ + /** + * Univariate has the ability to return only measures for the + * last N elements added to the set of values. + * @return The current window size or -1 if its Infinite. + */ - public abstract int getWindowSize(); + public abstract int getWindowSize(); - /** - * WindowSize controls the number of values which contribute - * to the values returned by Univariate. For example, if - * windowSize is set to 3 and the values {1,2,3,4,5} - * have been added in that order - * then the available values are {3,4,5} and all - * reported statistics will be based on these values - * @param windowSize sets the size of the window. - */ - public abstract void setWindowSize(int windowSize); - + /** + * WindowSize controls the number of values which contribute + * to the values returned by Univariate. For example, if + * windowSize is set to 3 and the values {1,2,3,4,5} + * have been added in that order + * then the available values are {3,4,5} and all + * reported statistics will be based on these values + * @param windowSize sets the size of the window. + */ + public abstract void setWindowSize(int windowSize); + /** * Returns the current set of values in an array of double primitives. * The order of addition is preserved. The returned array is a fresh @@ -240,7 +240,7 @@ public abstract class DescriptiveStatistics implements StatisticalSummary, Seria * @return returns the current set of numbers in the order in which they * were added to this set */ - public abstract double[] getValues(); + public abstract double[] getValues(); /** * Returns the current set of values in an array of double primitives, @@ -261,7 +261,7 @@ public abstract class DescriptiveStatistics implements StatisticalSummary, Seria * @param index The Index of the element * @return return the element at the specified index */ - public abstract double getElement(int index); + public abstract double getElement(int index); /** * Returns an estimate for the pth percentile of the stored values. @@ -281,9 +281,9 @@ public abstract class DescriptiveStatistics implements StatisticalSummary, Seria * values */ public double getPercentile(double p) { - return apply(new Percentile(p)); + return apply(new Percentile(p)); } - + /** * Generates a text report displaying * univariate statistics from values that @@ -291,23 +291,23 @@ public abstract class DescriptiveStatistics implements StatisticalSummary, Seria * @return String with line feeds displaying statistics */ public String toString() { - StringBuffer outBuffer = new StringBuffer(); - outBuffer.append("UnivariateImpl:\n"); - outBuffer.append("n: " + getN() + "\n"); - outBuffer.append("min: " + getMin() + "\n"); - outBuffer.append("max: " + getMax() + "\n"); - outBuffer.append("mean: " + getMean() + "\n"); - outBuffer.append("std dev: " + getStandardDeviation() + "\n"); - outBuffer.append("skewness: " + getSkewness() + "\n"); - outBuffer.append("kurtosis: " + getKurtosis() + "\n"); - return outBuffer.toString(); + StringBuffer outBuffer = new StringBuffer(); + outBuffer.append("UnivariateImpl:\n"); + outBuffer.append("n: " + getN() + "\n"); + outBuffer.append("min: " + getMin() + "\n"); + outBuffer.append("max: " + getMax() + "\n"); + outBuffer.append("mean: " + getMean() + "\n"); + outBuffer.append("std dev: " + getStandardDeviation() + "\n"); + outBuffer.append("skewness: " + getSkewness() + "\n"); + outBuffer.append("kurtosis: " + getKurtosis() + "\n"); + return outBuffer.toString(); } - /** - * Apply the given statistic to the data associated with this set of statistics. - * @param stat the statistic to apply - * @return the computed value of the statistic. - */ - public abstract double apply(UnivariateStatistic stat); + /** + * Apply the given statistic to the data associated with this set of statistics. + * @param stat the statistic to apply + * @return the computed value of the statistic. + */ + public abstract double apply(UnivariateStatistic stat); } diff --git a/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatisticsImpl.java b/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatisticsImpl.java index 5520a8410..1a78bee1c 100644 --- a/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatisticsImpl.java +++ b/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatisticsImpl.java @@ -23,15 +23,15 @@ import org.apache.commons.math.util.ResizableDoubleArray; * Default implementation of * {@link org.apache.commons.math.stat.univariate.DescriptiveStatistics}. * - * @version $Revision: 1.7 $ $Date: 2004/06/14 21:41:33 $ + * @version $Revision: 1.8 $ $Date: 2004/06/14 23:26:53 $ */ public class DescriptiveStatisticsImpl extends DescriptiveStatistics implements Serializable { /** Serializable version identifier */ static final long serialVersionUID = -1868088725461221010L; - /** hold the window size **/ - protected int windowSize; + /** hold the window size **/ + protected int windowSize; /** * Stored data values @@ -42,7 +42,7 @@ public class DescriptiveStatisticsImpl extends DescriptiveStatistics implements * Construct a DescriptiveStatisticsImpl with infinite window */ public DescriptiveStatisticsImpl() { - this(INFINITE_WINDOW); + this(INFINITE_WINDOW); } /** @@ -50,8 +50,8 @@ public class DescriptiveStatisticsImpl extends DescriptiveStatistics implements * @param window the finite window size. */ public DescriptiveStatisticsImpl(int window) { - super(); - eDA = new ResizableDoubleArray(); + super(); + eDA = new ResizableDoubleArray(); setWindowSize(window); } @@ -60,7 +60,7 @@ public class DescriptiveStatisticsImpl extends DescriptiveStatistics implements * @return the current window size. */ public int getWindowSize() { - return windowSize; + return windowSize; } /** diff --git a/src/java/org/apache/commons/math/stat/univariate/StatisticalSummary.java b/src/java/org/apache/commons/math/stat/univariate/StatisticalSummary.java index e7b1896b4..8ee692132 100644 --- a/src/java/org/apache/commons/math/stat/univariate/StatisticalSummary.java +++ b/src/java/org/apache/commons/math/stat/univariate/StatisticalSummary.java @@ -18,45 +18,45 @@ package org.apache.commons.math.stat.univariate; /** * Reporting interface for basic univariate statistics. * - * @version $Revision: 1.2 $ $Date: 2004/04/27 04:37:59 $ + * @version $Revision: 1.3 $ $Date: 2004/06/14 23:26:53 $ */ public interface StatisticalSummary { - /** - * Returns the - * arithmetic mean of the available values - * @return The mean or Double.NaN if no values have been added. - */ - public abstract double getMean(); - /** - * Returns the variance of the available values. - * @return The variance, Double.NaN if no values have been added - * or 0.0 for a single value set. - */ - public abstract double getVariance(); - /** - * Returns the standard deviation of the available values. - * @return The standard deviation, Double.NaN if no values have been added - * or 0.0 for a single value set. - */ - public abstract double getStandardDeviation(); - /** - * Returns the maximum of the available values - * @return The max or Double.NaN if no values have been added. - */ - public abstract double getMax(); - /** - * Returns the minimum of the available values - * @return The min or Double.NaN if no values have been added. - */ - public abstract double getMin(); - /** - * Returns the number of available values - * @return The number of available values - */ - public abstract long getN(); - /** - * Returns the sum of the values that have been added to Univariate. - * @return The sum or Double.NaN if no values have been added - */ - public abstract double getSum(); + /** + * Returns the + * arithmetic mean of the available values + * @return The mean or Double.NaN if no values have been added. + */ + public abstract double getMean(); + /** + * Returns the variance of the available values. + * @return The variance, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ + public abstract double getVariance(); + /** + * Returns the standard deviation of the available values. + * @return The standard deviation, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ + public abstract double getStandardDeviation(); + /** + * Returns the maximum of the available values + * @return The max or Double.NaN if no values have been added. + */ + public abstract double getMax(); + /** + * Returns the minimum of the available values + * @return The min or Double.NaN if no values have been added. + */ + public abstract double getMin(); + /** + * Returns the number of available values + * @return The number of available values + */ + public abstract long getN(); + /** + * Returns the sum of the values that have been added to Univariate. + * @return The sum or Double.NaN if no values have been added + */ + public abstract double getSum(); } \ No newline at end of file diff --git a/src/java/org/apache/commons/math/stat/univariate/SummaryStatistics.java b/src/java/org/apache/commons/math/stat/univariate/SummaryStatistics.java index fc9e48821..429e424cd 100644 --- a/src/java/org/apache/commons/math/stat/univariate/SummaryStatistics.java +++ b/src/java/org/apache/commons/math/stat/univariate/SummaryStatistics.java @@ -22,15 +22,15 @@ import org.apache.commons.discovery.tools.DiscoverClass; /** * Abstract factory class for univariate statistical summaries. * - * @version $Revision: 1.6 $ $Date: 2004/06/01 21:34:35 $ + * @version $Revision: 1.7 $ $Date: 2004/06/14 23:26:53 $ */ public abstract class SummaryStatistics implements StatisticalSummary, Serializable { /** Serialization UID */ static final long serialVersionUID = -6400596334135654825L; - /** - * Create an instance of a SummaryStatistics + /** + * Create an instance of a SummaryStatistics * @param cls the type of SummaryStatistics object to * create. * @return a new factory. @@ -40,13 +40,13 @@ public abstract class SummaryStatistics implements StatisticalSummary, Serializa * constructor is not accessible. * @throws ClassNotFoundException if the named * SummaryStatistics type can not be found. - */ - public static SummaryStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException { - return newInstance(Class.forName(cls)); - } + */ + public static SummaryStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException { + return newInstance(Class.forName(cls)); + } - /** - * Create an instance of a DescriptiveStatistics + /** + * Create an instance of a DescriptiveStatistics * @param cls the type of SummaryStatistics object to * create. * @return a new factory. @@ -54,108 +54,108 @@ public abstract class SummaryStatistics implements StatisticalSummary, Serializa * created. * @throws IllegalAccessException is thrown if the type's default * constructor is not accessible. - */ - public static SummaryStatistics newInstance(Class cls) throws InstantiationException, IllegalAccessException { - return (SummaryStatistics)cls.newInstance(); - } - - /** - * Create an instance of a DescriptiveStatistics - * @return a new factory. - */ - public static SummaryStatistics newInstance() { - SummaryStatistics factory = null; - try { - DiscoverClass dc = new DiscoverClass(); - factory = (SummaryStatistics) dc.newInstance( - SummaryStatistics.class, - "org.apache.commons.math.stat.univariate.SummaryStatisticsImpl"); - } catch(Exception ex) { - // ignore as default implementation will be used. - } - return factory; - } - - - /** - * Return a StatisticalSummaryValues instance reporting current statistics. - * - * @return Current values of statistics - */ - public StatisticalSummary getSummary() { - return new StatisticalSummaryValues(getMean(), getVariance(), getN(), - getMax(), getMin(), getSum()); - } - - /** - * Adds the value to the data to be summarized - * @param v the value to be added - */ - public abstract void addValue(double v); - - /** - * Returns the - * arithmetic mean of the available values - * @return The mean or Double.NaN if no values have been added. - */ - public abstract double getMean(); - - /** - * Returns the - * geometric mean of the available values - * @return The geometricMean, Double.NaN if no values have been added, - * or if the productof the available values is less than or equal to 0. - */ - public abstract double getGeometricMean(); - - /** - * Returns the variance of the available values. - * @return The variance, Double.NaN if no values have been added - * or 0.0 for a single value set. - */ - public abstract double getVariance(); - - /** - * Returns the standard deviation of the available values. - * @return The standard deviation, Double.NaN if no values have been added - * or 0.0 for a single value set. - */ - public abstract double getStandardDeviation(); + */ + public static SummaryStatistics newInstance(Class cls) throws InstantiationException, IllegalAccessException { + return (SummaryStatistics)cls.newInstance(); + } + + /** + * Create an instance of a DescriptiveStatistics + * @return a new factory. + */ + public static SummaryStatistics newInstance() { + SummaryStatistics factory = null; + try { + DiscoverClass dc = new DiscoverClass(); + factory = (SummaryStatistics) dc.newInstance( + SummaryStatistics.class, + "org.apache.commons.math.stat.univariate.SummaryStatisticsImpl"); + } catch(Exception ex) { + // ignore as default implementation will be used. + } + return factory; + } - /** - * Returns the maximum of the available values - * @return The max or Double.NaN if no values have been added. - */ - public abstract double getMax(); - /** - * Returns the minimum of the available values - * @return The min or Double.NaN if no values have been added. - */ - public abstract double getMin(); + /** + * Return a StatisticalSummaryValues instance reporting current statistics. + * + * @return Current values of statistics + */ + public StatisticalSummary getSummary() { + return new StatisticalSummaryValues(getMean(), getVariance(), getN(), + getMax(), getMin(), getSum()); + } + + /** + * Adds the value to the data to be summarized + * @param v the value to be added + */ + public abstract void addValue(double v); - /** - * Returns the number of available values - * @return The number of available values - */ - public abstract long getN(); + /** + * Returns the + * arithmetic mean of the available values + * @return The mean or Double.NaN if no values have been added. + */ + public abstract double getMean(); - /** - * Returns the sum of the values that have been added to Univariate. - * @return The sum or Double.NaN if no values have been added - */ - public abstract double getSum(); + /** + * Returns the + * geometric mean of the available values + * @return The geometricMean, Double.NaN if no values have been added, + * or if the productof the available values is less than or equal to 0. + */ + public abstract double getGeometricMean(); - /** - * Returns the sum of the squares of the available values. - * @return The sum of the squares or Double.NaN if no - * values have been added. - */ - public abstract double getSumsq(); + /** + * Returns the variance of the available values. + * @return The variance, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ + public abstract double getVariance(); - /** - * Resets all statistics - */ - public abstract void clear(); + /** + * Returns the standard deviation of the available values. + * @return The standard deviation, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ + public abstract double getStandardDeviation(); + + /** + * Returns the maximum of the available values + * @return The max or Double.NaN if no values have been added. + */ + public abstract double getMax(); + + /** + * Returns the minimum of the available values + * @return The min or Double.NaN if no values have been added. + */ + public abstract double getMin(); + + /** + * Returns the number of available values + * @return The number of available values + */ + public abstract long getN(); + + /** + * Returns the sum of the values that have been added to Univariate. + * @return The sum or Double.NaN if no values have been added + */ + public abstract double getSum(); + + /** + * Returns the sum of the squares of the available values. + * @return The sum of the squares or Double.NaN if no + * values have been added. + */ + public abstract double getSumsq(); + + /** + * Resets all statistics + */ + public abstract void clear(); } diff --git a/src/java/org/apache/commons/math/stat/univariate/SummaryStatisticsImpl.java b/src/java/org/apache/commons/math/stat/univariate/SummaryStatisticsImpl.java index 3e8e09e75..3b74adda2 100644 --- a/src/java/org/apache/commons/math/stat/univariate/SummaryStatisticsImpl.java +++ b/src/java/org/apache/commons/math/stat/univariate/SummaryStatisticsImpl.java @@ -29,7 +29,7 @@ import org.apache.commons.math.stat.univariate.summary.SumOfSquares; /** * Provides a default {@link SummaryStatistics} implementation. * - * @version $Revision: 1.3 $ $Date: 2004/06/01 21:34:35 $ + * @version $Revision: 1.4 $ $Date: 2004/06/14 23:26:53 $ */ public class SummaryStatisticsImpl extends SummaryStatistics implements Serializable { @@ -85,14 +85,14 @@ public class SummaryStatisticsImpl extends SummaryStatistics implements Serializ * @param value the value to add */ public void addValue(double value) { - sum.increment(value); - sumsq.increment(value); - min.increment(value); - max.increment(value); - sumLog.increment(value); - geoMean.increment(value); - secondMoment.increment(value); - n++; + sum.increment(value); + sumsq.increment(value); + min.increment(value); + max.increment(value); + sumLog.increment(value); + geoMean.increment(value); + secondMoment.increment(value); + n++; } /** @@ -214,8 +214,8 @@ public class SummaryStatisticsImpl extends SummaryStatistics implements Serializ } /** - * Resets all statistics and storage - */ + * Resets all statistics and storage + */ public void clear() { this.n = 0; min.clear(); diff --git a/src/java/org/apache/commons/math/stat/univariate/moment/package.html b/src/java/org/apache/commons/math/stat/univariate/moment/package.html index 8f74db34f..440273120 100644 --- a/src/java/org/apache/commons/math/stat/univariate/moment/package.html +++ b/src/java/org/apache/commons/math/stat/univariate/moment/package.html @@ -14,6 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. --> - - Summary statistics based on moments. + + Summary statistics based on moments. diff --git a/src/java/org/apache/commons/math/stat/univariate/package.html b/src/java/org/apache/commons/math/stat/univariate/package.html index e53d9c90d..75299891c 100644 --- a/src/java/org/apache/commons/math/stat/univariate/package.html +++ b/src/java/org/apache/commons/math/stat/univariate/package.html @@ -14,27 +14,27 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - Generic univariate summary statistic objects. - -

UnivariateStatistic API Usage Examples:

-

UnivariateStatistic:

- /* evaluation approach */
double[] values = new double[] { 1, 2, - 3, 4, 5 };
UnivariateStatistic stat - = new Mean();
System.out.println("mean = " + stat.evaluate(values));
-

StorelessUnivariateStatistic:

- /* incremental approach */
double[] values = new double[] { 1, 2, - 3, 4, 5 };
- StorelessUnivariateStatistic stat = new Mean();
- System.out.println("mean before adding a value is NaN = " + stat.getResult());
for (int i = 0; - i < values.length; i++) {
    stat.increment(values[i]);
    - System.out.println("current mean = " + - stat2.getResult());
}
- stat.clear();
System.out.println("mean after clear is NaN = " - + stat.getResult());
- + + + Generic univariate summary statistic objects. + +

UnivariateStatistic API Usage Examples:

+

UnivariateStatistic:

+ /* evaluation approach */
double[] values = new double[] { 1, 2, + 3, 4, 5 };
UnivariateStatistic stat + = new Mean();
System.out.println("mean = " + stat.evaluate(values));
+

StorelessUnivariateStatistic:

+ /* incremental approach */
double[] values = new double[] { 1, 2, + 3, 4, 5 };
+ StorelessUnivariateStatistic stat = new Mean();
+ System.out.println("mean before adding a value is NaN = " + stat.getResult());
for (int i = 0; + i < values.length; i++) {
    stat.increment(values[i]);
    + System.out.println("current mean = " + + stat2.getResult());
}
+ stat.clear();
System.out.println("mean after clear is NaN = " + + stat.getResult());
+ diff --git a/src/java/org/apache/commons/math/stat/univariate/rank/package.html b/src/java/org/apache/commons/math/stat/univariate/rank/package.html index a44b50cd0..7143f6ee0 100644 --- a/src/java/org/apache/commons/math/stat/univariate/rank/package.html +++ b/src/java/org/apache/commons/math/stat/univariate/rank/package.html @@ -14,6 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. --> - - Summary statistics based on ranks. + + Summary statistics based on ranks. diff --git a/src/java/org/apache/commons/math/stat/univariate/summary/package.html b/src/java/org/apache/commons/math/stat/univariate/summary/package.html index 261de2ca4..d019c85a0 100644 --- a/src/java/org/apache/commons/math/stat/univariate/summary/package.html +++ b/src/java/org/apache/commons/math/stat/univariate/summary/package.html @@ -14,6 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. --> - - Other summary statistics. + + Other summary statistics.