Formatting only. Removed tabs.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141293 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2004-06-14 23:26:54 +00:00
parent fc26642480
commit a6b433d257
15 changed files with 370 additions and 370 deletions

View File

@ -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, <code>Double.NaN.</code>
* @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++) {

View File

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

View File

@ -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);

View File

@ -14,9 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Revision: 1.1 $ $Date: 2004/04/26 18:28:17 $ -->
<body>
Classes providing hypothesis testing and confidence interval
construction.
</body>
<!-- $Revision: 1.2 $ $Date: 2004/06/14 23:26:53 $ -->
<body>
Classes providing hypothesis testing and confidence interval
construction.
</body>
</html>

View File

@ -14,8 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Revision: 1.1 $ $Date: 2004/04/26 18:28:16 $ -->
<body>
Statistical routines involving multivariate data.
</body>
<!-- $Revision: 1.2 $ $Date: 2004/06/14 23:26:53 $ -->
<body>
Statistical routines involving multivariate data.
</body>
</html>

View File

@ -14,6 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Revision: 1.5 $ $Date: 2004/04/26 18:28:17 $ -->
<body>Data storage, manipulation and summary routines.</body>
<!-- $Revision: 1.6 $ $Date: 2004/06/14 23:26:53 $ -->
<body>Data storage, manipulation and summary routines.</body>
</html>

View File

@ -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 <code>DescriptiveStatistics</code>
/**
* Create an instance of a <code>DescriptiveStatistics</code>
* @param cls the type of <code>DescriptiveStatistics</code> 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
* <code>DescriptiveStatistics</code> 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 <code>DescriptiveStatistics</code>
/**
* Create an instance of a <code>DescriptiveStatistics</code>
* @param cls the type of <code>DescriptiveStatistics</code> 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 <code>DescriptiveStatistics</code>
* @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 <code>DescriptiveStatistics</code>
* @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 <a href="http://www.xycoon.com/arithmetic_mean.htm">
* arithmetic mean </a> of the available values
* @return The mean or Double.NaN if no values have been added.
*/
/**
* Returns the <a href="http://www.xycoon.com/arithmetic_mean.htm">
* arithmetic mean </a> 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 <a href="http://www.xycoon.com/geometric_mean.htm">
* geometric mean </a> 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 <a href="http://www.xycoon.com/geometric_mean.htm">
* geometric mean </a> 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 &lt;=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 &lt;=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 &lt;=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 &lt;=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 <strong> in that order</strong>
* then the <i>available values</i> 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 <strong> in that order</strong>
* then the <i>available values</i> 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);
}

View File

@ -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;
}
/**

View File

@ -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 <a href="http://www.xycoon.com/arithmetic_mean.htm">
* arithmetic mean </a> 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 <a href="http://www.xycoon.com/arithmetic_mean.htm">
* arithmetic mean </a> 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();
}

View File

@ -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 <code>SummaryStatistics</code>
/**
* Create an instance of a <code>SummaryStatistics</code>
* @param cls the type of <code>SummaryStatistics</code> 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
* <code>SummaryStatistics</code> 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 <code>DescriptiveStatistics</code>
/**
* Create an instance of a <code>DescriptiveStatistics</code>
* @param cls the type of <code>SummaryStatistics</code> 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 <code>DescriptiveStatistics</code>
* @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 <a href="http://www.xycoon.com/arithmetic_mean.htm">
* arithmetic mean </a> of the available values
* @return The mean or Double.NaN if no values have been added.
*/
public abstract double getMean();
/**
* Returns the <a href="http://www.xycoon.com/geometric_mean.htm">
* geometric mean </a> 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 <code>DescriptiveStatistics</code>
* @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 <a href="http://www.xycoon.com/arithmetic_mean.htm">
* arithmetic mean </a> 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 <a href="http://www.xycoon.com/geometric_mean.htm">
* geometric mean </a> 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();
}

View File

@ -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();

View File

@ -14,6 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Revision: 1.4 $ $Date: 2004/04/26 18:28:17 $ -->
<body>Summary statistics based on moments.</body>
<!-- $Revision: 1.5 $ $Date: 2004/06/14 23:26:53 $ -->
<body>Summary statistics based on moments.</body>
</html>

View File

@ -14,27 +14,27 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Revision: 1.5 $ $Date: 2004/04/26 18:28:18 $ -->
<body>
Generic univariate summary statistic objects.
<h3>UnivariateStatistic API Usage Examples:</h3>
<h4>UnivariateStatistic:</h4>
<code>/* evaluation approach */<br/> double[] values = new double[] { 1, 2,
3, 4, 5 };<br/> <span style="font-weight: bold;">UnivariateStatistic stat
= new Mean();</span><br/> System.out.println("mean = " + <span
style="font-weight: bold;">stat.evaluate(values)</span>);<br/> </code>
<h4>StorelessUnivariateStatistic:</h4>
<code>/* incremental approach */<br/> double[] values = new double[] { 1, 2,
3, 4, 5 };<br/> <span style="font-weight: bold;">
StorelessUnivariateStatistic stat = new Mean();</span><br/>
System.out.println("mean before adding a value is NaN = " + <span
style="font-weight: bold;">stat.getResult()</span>);<br/> for (int i = 0;
i &lt; values.length; i++) {<br/> &nbsp;&nbsp;&nbsp; <span
style="font-weight: bold;">stat.increment(values[i]);</span><br/> &nbsp;&nbsp;&nbsp;
System.out.println("current mean = " + <span style="font-weight: bold;">
stat2.getResult()</span>);<br/> }<br/> <span style="font-weight: bold;">
stat.clear();</span><br/> System.out.println("mean after clear is NaN = "
+ <span style="font-weight: bold;">stat.getResult()</span>);</code>
</body>
<!-- $Revision: 1.6 $ $Date: 2004/06/14 23:26:53 $ -->
<body>
Generic univariate summary statistic objects.
<h3>UnivariateStatistic API Usage Examples:</h3>
<h4>UnivariateStatistic:</h4>
<code>/* evaluation approach */<br/> double[] values = new double[] { 1, 2,
3, 4, 5 };<br/> <span style="font-weight: bold;">UnivariateStatistic stat
= new Mean();</span><br/> System.out.println("mean = " + <span
style="font-weight: bold;">stat.evaluate(values)</span>);<br/> </code>
<h4>StorelessUnivariateStatistic:</h4>
<code>/* incremental approach */<br/> double[] values = new double[] { 1, 2,
3, 4, 5 };<br/> <span style="font-weight: bold;">
StorelessUnivariateStatistic stat = new Mean();</span><br/>
System.out.println("mean before adding a value is NaN = " + <span
style="font-weight: bold;">stat.getResult()</span>);<br/> for (int i = 0;
i &lt; values.length; i++) {<br/> &nbsp;&nbsp;&nbsp; <span
style="font-weight: bold;">stat.increment(values[i]);</span><br/> &nbsp;&nbsp;&nbsp;
System.out.println("current mean = " + <span style="font-weight: bold;">
stat2.getResult()</span>);<br/> }<br/> <span style="font-weight: bold;">
stat.clear();</span><br/> System.out.println("mean after clear is NaN = "
+ <span style="font-weight: bold;">stat.getResult()</span>);</code>
</body>
</html>

View File

@ -14,6 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Revision: 1.4 $ $Date: 2004/04/26 18:28:17 $ -->
<body>Summary statistics based on ranks.</body>
<!-- $Revision: 1.5 $ $Date: 2004/06/14 23:26:54 $ -->
<body>Summary statistics based on ranks.</body>
</html>

View File

@ -14,6 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Revision: 1.4 $ $Date: 2004/04/26 18:28:16 $ -->
<body>Other summary statistics.</body>
<!-- $Revision: 1.5 $ $Date: 2004/06/14 23:26:54 $ -->
<body>Other summary statistics.</body>
</html>