You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2009/09/05 19:37:05 UTC
svn commit: r811685 [10/24] - in /commons/proper/math/trunk: ./
src/main/java/org/apache/commons/math/
src/main/java/org/apache/commons/math/analysis/
src/main/java/org/apache/commons/math/analysis/integration/
src/main/java/org/apache/commons/math/ana...
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java Sat Sep 5 17:36:48 2009
@@ -37,90 +37,90 @@
/**
* Maintains a dataset of values of a single variable and computes descriptive
* statistics based on stored data. The {@link #getWindowSize() windowSize}
- * property sets a limit on the number of values that can be stored in the
+ * property sets a limit on the number of values that can be stored in the
* dataset. The default value, INFINITE_WINDOW, puts no limit on the size of
* the dataset. This value should be used with caution, as the backing store
- * will grow without bound in this case. For very large datasets,
+ * will grow without bound in this case. For very large datasets,
* {@link SummaryStatistics}, which does not store the dataset, should be used
* instead of this class. If <code>windowSize</code> is not INFINITE_WINDOW and
* more values are added than can be stored in the dataset, new values are
- * added in a "rolling" manner, with new values replacing the "oldest" values
+ * added in a "rolling" manner, with new values replacing the "oldest" values
* in the dataset.
- *
- * <p>Note: this class is not threadsafe. Use
+ *
+ * <p>Note: this class is not threadsafe. Use
* {@link SynchronizedDescriptiveStatistics} if concurrent access from multiple
* threads is required.</p>
*
* @version $Revision$ $Date$
*/
public class DescriptiveStatistics implements StatisticalSummary, Serializable {
-
+
/** Serialization UID */
private static final long serialVersionUID = 4133067267405273064L;
/** hold the window size **/
protected int windowSize = INFINITE_WINDOW;
-
- /**
+
+ /**
* Stored data values
*/
protected ResizableDoubleArray eDA = new ResizableDoubleArray();
-
+
/** Mean statistic implementation - can be reset by setter. */
private UnivariateStatistic meanImpl = new Mean();
-
+
/** Geometric mean statistic implementation - can be reset by setter. */
private UnivariateStatistic geometricMeanImpl = new GeometricMean();
-
+
/** Kurtosis statistic implementation - can be reset by setter. */
private UnivariateStatistic kurtosisImpl = new Kurtosis();
-
+
/** Maximum statistic implementation - can be reset by setter. */
private UnivariateStatistic maxImpl = new Max();
-
+
/** Minimum statistic implementation - can be reset by setter. */
private UnivariateStatistic minImpl = new Min();
-
+
/** Percentile statistic implementation - can be reset by setter. */
private UnivariateStatistic percentileImpl = new Percentile();
-
+
/** Skewness statistic implementation - can be reset by setter. */
private UnivariateStatistic skewnessImpl = new Skewness();
-
+
/** Variance statistic implementation - can be reset by setter. */
private UnivariateStatistic varianceImpl = new Variance();
-
+
/** Sum of squares statistic implementation - can be reset by setter. */
private UnivariateStatistic sumsqImpl = new SumOfSquares();
-
+
/** Sum statistic implementation - can be reset by setter. */
private UnivariateStatistic sumImpl = new Sum();
-
+
/**
* Construct a DescriptiveStatistics instance with an infinite window
*/
public DescriptiveStatistics() {
}
-
+
/**
* Construct a DescriptiveStatistics instance with the specified window
- *
+ *
* @param window the window size.
*/
public DescriptiveStatistics(int window) {
setWindowSize(window);
}
-
+
/**
* Copy constructor. Construct a new DescriptiveStatistics instance that
* is a copy of original.
- *
+ *
* @param original DescriptiveStatistics instance to copy
*/
public DescriptiveStatistics(DescriptiveStatistics original) {
copy(original, this);
}
-
+
/**
* Represents an infinite window size. When the {@link #getWindowSize()}
* returns this value, there is no limit to the number of data values
@@ -133,8 +133,8 @@
* (i.e., the number of stored elements equals the currently configured
* windowSize), the first (oldest) element in the dataset is discarded
* to make room for the new value.
- *
- * @param v the value to be added
+ *
+ * @param v the value to be added
*/
public void addValue(double v) {
if (windowSize != INFINITE_WINDOW) {
@@ -158,7 +158,7 @@
/**
* Replaces the most recently stored value with the given value.
* There must be at least one element stored to call this method.
- *
+ *
* @param v the value to replace the most recent stored value
* @return replaced value
*/
@@ -166,38 +166,38 @@
return eDA.substituteMostRecentElement(v);
}
- /**
+ /**
* 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
* @return The mean or Double.NaN if no values have been added.
*/
public double getMean() {
return apply(meanImpl);
}
- /**
+ /**
* 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,
+ * @return The geometricMean, Double.NaN if no values have been added,
* or if the product of the available values is less than or equal to 0.
*/
public double getGeometricMean() {
return apply(geometricMeanImpl);
}
- /**
+ /**
* 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.
+ * @return The variance, Double.NaN if no values have been added
+ * or 0.0 for a single value set.
*/
public double getVariance() {
return apply(varianceImpl);
}
- /**
+ /**
* 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.
+ * @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;
@@ -212,26 +212,26 @@
}
/**
- * Returns the skewness of the available values. Skewness is a
+ * Returns the skewness of the available values. Skewness is a
* measure of the asymmetry of a given distribution.
- * @return The skewness, Double.NaN if no values have been added
- * or 0.0 for a value set <=2.
+ * @return The skewness, Double.NaN if no values have been added
+ * or 0.0 for a value set <=2.
*/
public double getSkewness() {
return apply(skewnessImpl);
}
/**
- * Returns the Kurtosis of the available values. Kurtosis is a
+ * 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.
+ * @return The kurtosis, Double.NaN if no values have been added, or 0.0
+ * for a value set <=3.
*/
public double getKurtosis() {
return apply(kurtosisImpl);
}
- /**
+ /**
* Returns the maximum of the available values
* @return The max or Double.NaN if no values have been added.
*/
@@ -239,7 +239,7 @@
return apply(maxImpl);
}
- /**
+ /**
* Returns the minimum of the available values
* @return The min or Double.NaN if no values have been added.
*/
@@ -247,7 +247,7 @@
return apply(minImpl);
}
- /**
+ /**
* Returns the number of available values
* @return The number of available values
*/
@@ -265,14 +265,14 @@
/**
* Returns the sum of the squares of the available values.
- * @return The sum of the squares or Double.NaN if no
+ * @return The sum of the squares or Double.NaN if no
* values have been added.
*/
public double getSumsq() {
return apply(sumsqImpl);
}
- /**
+ /**
* Resets all statistics and storage
*/
public void clear() {
@@ -283,7 +283,7 @@
/**
* Returns the maximum number of values that can be stored in the
* dataset, or INFINITE_WINDOW (-1) if there is no limit.
- *
+ *
* @return The current window size or -1 if its Infinite.
*/
public int getWindowSize() {
@@ -291,10 +291,10 @@
}
/**
- * WindowSize controls the number of values which contribute
- * to the reported statistics. For example, if
- * windowSize is set to 3 and the values {1,2,3,4,5}
- * have been added <strong> in that order</strong>
+ * WindowSize controls the number of values which contribute
+ * to the reported statistics. 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.
@@ -306,24 +306,24 @@
"window size must be positive ({0})", windowSize);
}
}
-
+
this.windowSize = windowSize;
// We need to check to see if we need to discard elements
- // from the front of the array. If the windowSize is less than
+ // from the front of the array. If the windowSize is less than
// the current number of elements.
if (windowSize != INFINITE_WINDOW && windowSize < eDA.getNumElements()) {
eDA.discardFrontElements(eDA.getNumElements() - windowSize);
}
}
-
+
/**
- * Returns the current set of values in an array of double primitives.
+ * Returns the current set of values in an array of double primitives.
* The order of addition is preserved. The returned array is a fresh
* copy of the underlying data -- i.e., it is not a reference to the
* stored data.
- *
- * @return returns the current set of numbers in the order in which they
+ *
+ * @return returns the current set of numbers in the order in which they
* were added to this set
*/
public double[] getValues() {
@@ -331,12 +331,12 @@
}
/**
- * Returns the current set of values in an array of double primitives,
+ * Returns the current set of values in an array of double primitives,
* sorted in ascending order. The returned array is a fresh
* copy of the underlying data -- i.e., it is not a reference to the
* stored data.
- * @return returns the current set of
- * numbers sorted in ascending order
+ * @return returns the current set of
+ * numbers sorted in ascending order
*/
public double[] getSortedValues() {
double[] sort = getValues();
@@ -354,20 +354,20 @@
}
/**
- * Returns an estimate for the pth percentile of the stored values.
+ * Returns an estimate for the pth percentile of the stored values.
* <p>
* The implementation provided here follows the first estimation procedure presented
* <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm">here.</a>
* </p><p>
* <strong>Preconditions</strong>:<ul>
- * <li><code>0 < p ≤ 100</code> (otherwise an
+ * <li><code>0 < p ≤ 100</code> (otherwise an
* <code>IllegalArgumentException</code> is thrown)</li>
* <li>at least one value must be stored (returns <code>Double.NaN
* </code> otherwise)</li>
* </ul></p>
- *
+ *
* @param p the requested percentile (scaled from 0 - 100)
- * @return An estimate for the pth percentile of the stored data
+ * @return An estimate for the pth percentile of the stored data
* @throws IllegalStateException if percentile implementation has been
* overridden and the supplied implementation does not support setQuantile
* values
@@ -377,7 +377,7 @@
((Percentile) percentileImpl).setQuantile(p);
} else {
try {
- percentileImpl.getClass().getMethod("setQuantile",
+ percentileImpl.getClass().getMethod("setQuantile",
new Class[] {Double.TYPE}).invoke(percentileImpl,
new Object[] {Double.valueOf(p)});
} catch (NoSuchMethodException e1) { // Setter guard should prevent
@@ -389,17 +389,17 @@
"cannot access setQuantile method in percentile implementation {0}",
percentileImpl.getClass().getName());
} catch (InvocationTargetException e3) {
- throw MathRuntimeException.createIllegalArgumentException(e3.getCause());
+ throw MathRuntimeException.createIllegalArgumentException(e3.getCause());
}
}
return apply(percentileImpl);
}
-
+
/**
* Generates a text report displaying univariate statistics from values
* that have been added. Each statistic is displayed on a separate
* line.
- *
+ *
* @return String with line feeds displaying statistics
*/
@Override
@@ -418,7 +418,7 @@
outBuffer.append("kurtosis: ").append(getKurtosis()).append(endl);
return outBuffer.toString();
}
-
+
/**
* Apply the given statistic to the data associated with this set of statistics.
* @param stat the statistic to apply
@@ -429,10 +429,10 @@
}
// Implementation getters and setter
-
+
/**
* Returns the currently configured mean implementation.
- *
+ *
* @return the UnivariateStatistic implementing the mean
* @since 1.2
*/
@@ -442,7 +442,7 @@
/**
* <p>Sets the implementation for the mean.</p>
- *
+ *
* @param meanImpl the UnivariateStatistic instance to use
* for computing the mean
* @since 1.2
@@ -453,7 +453,7 @@
/**
* Returns the currently configured geometric mean implementation.
- *
+ *
* @return the UnivariateStatistic implementing the geometric mean
* @since 1.2
*/
@@ -463,7 +463,7 @@
/**
* <p>Sets the implementation for the gemoetric mean.</p>
- *
+ *
* @param geometricMeanImpl the UnivariateStatistic instance to use
* for computing the geometric mean
* @since 1.2
@@ -475,7 +475,7 @@
/**
* Returns the currently configured kurtosis implementation.
- *
+ *
* @return the UnivariateStatistic implementing the kurtosis
* @since 1.2
*/
@@ -485,7 +485,7 @@
/**
* <p>Sets the implementation for the kurtosis.</p>
- *
+ *
* @param kurtosisImpl the UnivariateStatistic instance to use
* for computing the kurtosis
* @since 1.2
@@ -496,7 +496,7 @@
/**
* Returns the currently configured maximum implementation.
- *
+ *
* @return the UnivariateStatistic implementing the maximum
* @since 1.2
*/
@@ -506,7 +506,7 @@
/**
* <p>Sets the implementation for the maximum.</p>
- *
+ *
* @param maxImpl the UnivariateStatistic instance to use
* for computing the maximum
* @since 1.2
@@ -517,7 +517,7 @@
/**
* Returns the currently configured minimum implementation.
- *
+ *
* @return the UnivariateStatistic implementing the minimum
* @since 1.2
*/
@@ -527,7 +527,7 @@
/**
* <p>Sets the implementation for the minimum.</p>
- *
+ *
* @param minImpl the UnivariateStatistic instance to use
* for computing the minimum
* @since 1.2
@@ -538,7 +538,7 @@
/**
* Returns the currently configured percentile implementation.
- *
+ *
* @return the UnivariateStatistic implementing the percentile
* @since 1.2
*/
@@ -549,9 +549,9 @@
/**
* Sets the implementation to be used by {@link #getPercentile(double)}.
* The supplied <code>UnivariateStatistic</code> must provide a
- * <code>setQuantile(double)</code> method; otherwise
+ * <code>setQuantile(double)</code> method; otherwise
* <code>IllegalArgumentException</code> is thrown.
- *
+ *
* @param percentileImpl the percentileImpl to set
* @throws IllegalArgumentException if the supplied implementation does not
* provide a <code>setQuantile</code> method
@@ -560,10 +560,10 @@
public synchronized void setPercentileImpl(
UnivariateStatistic percentileImpl) {
try {
- percentileImpl.getClass().getMethod("setQuantile",
+ percentileImpl.getClass().getMethod("setQuantile",
new Class[] {Double.TYPE}).invoke(percentileImpl,
new Object[] {Double.valueOf(50.0d)});
- } catch (NoSuchMethodException e1) {
+ } catch (NoSuchMethodException e1) {
throw MathRuntimeException.createIllegalArgumentException(
"percentile implementation {0} does not support setQuantile",
percentileImpl.getClass().getName());
@@ -572,14 +572,14 @@
"cannot access setQuantile method in percentile implementation {0}",
percentileImpl.getClass().getName());
} catch (InvocationTargetException e3) {
- throw MathRuntimeException.createIllegalArgumentException(e3.getCause());
+ throw MathRuntimeException.createIllegalArgumentException(e3.getCause());
}
this.percentileImpl = percentileImpl;
}
/**
* Returns the currently configured skewness implementation.
- *
+ *
* @return the UnivariateStatistic implementing the skewness
* @since 1.2
*/
@@ -589,7 +589,7 @@
/**
* <p>Sets the implementation for the skewness.</p>
- *
+ *
* @param skewnessImpl the UnivariateStatistic instance to use
* for computing the skewness
* @since 1.2
@@ -601,7 +601,7 @@
/**
* Returns the currently configured variance implementation.
- *
+ *
* @return the UnivariateStatistic implementing the variance
* @since 1.2
*/
@@ -611,7 +611,7 @@
/**
* <p>Sets the implementation for the variance.</p>
- *
+ *
* @param varianceImpl the UnivariateStatistic instance to use
* for computing the variance
* @since 1.2
@@ -623,7 +623,7 @@
/**
* Returns the currently configured sum of squares implementation.
- *
+ *
* @return the UnivariateStatistic implementing the sum of squares
* @since 1.2
*/
@@ -633,7 +633,7 @@
/**
* <p>Sets the implementation for the sum of squares.</p>
- *
+ *
* @param sumsqImpl the UnivariateStatistic instance to use
* for computing the sum of squares
* @since 1.2
@@ -644,7 +644,7 @@
/**
* Returns the currently configured sum implementation.
- *
+ *
* @return the UnivariateStatistic implementing the sum
* @since 1.2
*/
@@ -654,30 +654,30 @@
/**
* <p>Sets the implementation for the sum.</p>
- *
+ *
* @param sumImpl the UnivariateStatistic instance to use
* for computing the sum
* @since 1.2
*/
public synchronized void setSumImpl(UnivariateStatistic sumImpl) {
this.sumImpl = sumImpl;
- }
-
+ }
+
/**
* Returns a copy of this DescriptiveStatistics instance with the same internal state.
- *
+ *
* @return a copy of this
*/
public DescriptiveStatistics copy() {
DescriptiveStatistics result = new DescriptiveStatistics();
copy(this, result);
- return result;
+ return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source DescriptiveStatistics to copy
* @param dest DescriptiveStatistics to copy to
* @throws NullPointerException if either source or dest is null
@@ -686,7 +686,7 @@
// Copy data and window size
dest.eDA = source.eDA.copy();
dest.windowSize = source.windowSize;
-
+
// Copy implementations
dest.maxImpl = source.maxImpl.copy();
dest.meanImpl = source.meanImpl.copy();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java Sat Sep 5 17:36:48 2009
@@ -33,22 +33,22 @@
import org.apache.commons.math.util.MathUtils;
/**
- * <p>Computes summary statistics for a stream of n-tuples added using the
+ * <p>Computes summary statistics for a stream of n-tuples added using the
* {@link #addValue(double[]) addValue} method. The data values are not stored
* in memory, so this class can be used to compute statistics for very large
* n-tuple streams.</p>
- *
+ *
* <p>The {@link StorelessUnivariateStatistic} instances used to maintain
* summary state and compute statistics are configurable via setters.
* For example, the default implementation for the mean can be overridden by
* calling {@link #setMeanImpl(StorelessUnivariateStatistic[])}. Actual
- * parameters to these methods must implement the
+ * parameters to these methods must implement the
* {@link StorelessUnivariateStatistic} interface and configuration must be
* completed before <code>addValue</code> is called. No configuration is
* necessary to use the default, commons-math provided implementations.</p>
- *
+ *
* <p>To compute statistics for a stream of n-tuples, construct a
- * MultivariateStatistics instance with dimension n and then use
+ * MultivariateStatistics instance with dimension n and then use
* {@link #addValue(double[])} to add n-tuples. The <code>getXxx</code>
* methods where Xxx is a statistic return an array of <code>double</code>
* values, where for <code>i = 0,...,n-1</code> the i<sup>th</sup> array element is the
@@ -57,8 +57,8 @@
* with actual parameters {0, 1, 2}, then {3, 4, 5} and finally {6, 7, 8},
* <code>getSum</code> will return a three-element array with values
* {0+3+6, 1+4+7, 2+5+8}</p>
- *
- * <p>Note: This class is not thread-safe. Use
+ *
+ * <p>Note: This class is not thread-safe. Use
* {@link SynchronizedMultivariateSummaryStatistics} if concurrent access from multiple
* threads is required.</p>
*
@@ -109,34 +109,34 @@
/** Count of values that have been added */
private long n = 0;
-
+
/** Sum statistic implementation - can be reset by setter. */
private StorelessUnivariateStatistic[] sumImpl;
-
+
/** Sum of squares statistic implementation - can be reset by setter. */
private StorelessUnivariateStatistic[] sumSqImpl;
-
+
/** Minimum statistic implementation - can be reset by setter. */
private StorelessUnivariateStatistic[] minImpl;
-
+
/** Maximum statistic implementation - can be reset by setter. */
private StorelessUnivariateStatistic[] maxImpl;
-
+
/** Sum of log statistic implementation - can be reset by setter. */
private StorelessUnivariateStatistic[] sumLogImpl;
-
+
/** Geometric mean statistic implementation - can be reset by setter. */
private StorelessUnivariateStatistic[] geoMeanImpl;
-
+
/** Mean statistic implementation - can be reset by setter. */
private StorelessUnivariateStatistic[] meanImpl;
-
+
/** Covariance statistic implementation - cannot be reset. */
private VectorialCovariance covarianceImpl;
/**
* Add an n-tuple to the data
- *
+ *
* @param value the n-tuple to add
* @throws DimensionMismatchException if the length of the array
* does not match the one used at construction
@@ -158,7 +158,7 @@
n++;
}
- /**
+ /**
* Returns the dimension of the data
* @return The dimension of the data
*/
@@ -166,7 +166,7 @@
return k;
}
- /**
+ /**
* Returns the number of available values
* @return The number of available values
*/
@@ -189,9 +189,9 @@
/**
* Returns an array whose i<sup>th</sup> entry is the sum of the
- * i<sup>th</sup> entries of the arrays that have been added using
+ * i<sup>th</sup> entries of the arrays that have been added using
* {@link #addValue(double[])}
- *
+ *
* @return the array of component sums
*/
public double[] getSum() {
@@ -200,9 +200,9 @@
/**
* Returns an array whose i<sup>th</sup> entry is the sum of squares of the
- * i<sup>th</sup> entries of the arrays that have been added using
+ * i<sup>th</sup> entries of the arrays that have been added using
* {@link #addValue(double[])}
- *
+ *
* @return the array of component sums of squares
*/
public double[] getSumSq() {
@@ -211,9 +211,9 @@
/**
* Returns an array whose i<sup>th</sup> entry is the sum of logs of the
- * i<sup>th</sup> entries of the arrays that have been added using
+ * i<sup>th</sup> entries of the arrays that have been added using
* {@link #addValue(double[])}
- *
+ *
* @return the array of component log sums
*/
public double[] getSumLog() {
@@ -222,9 +222,9 @@
/**
* Returns an array whose i<sup>th</sup> entry is the mean of the
- * i<sup>th</sup> entries of the arrays that have been added using
+ * i<sup>th</sup> entries of the arrays that have been added using
* {@link #addValue(double[])}
- *
+ *
* @return the array of component means
*/
public double[] getMean() {
@@ -233,9 +233,9 @@
/**
* Returns an array whose i<sup>th</sup> entry is the standard deviation of the
- * i<sup>th</sup> entries of the arrays that have been added using
+ * i<sup>th</sup> entries of the arrays that have been added using
* {@link #addValue(double[])}
- *
+ *
* @return the array of component standard deviations
*/
public double[] getStandardDeviation() {
@@ -256,7 +256,7 @@
/**
* Returns the covariance matrix of the values that have been added.
*
- * @return the covariance matrix
+ * @return the covariance matrix
*/
public RealMatrix getCovariance() {
return covarianceImpl.getResult();
@@ -264,9 +264,9 @@
/**
* Returns an array whose i<sup>th</sup> entry is the maximum of the
- * i<sup>th</sup> entries of the arrays that have been added using
+ * i<sup>th</sup> entries of the arrays that have been added using
* {@link #addValue(double[])}
- *
+ *
* @return the array of component maxima
*/
public double[] getMax() {
@@ -275,9 +275,9 @@
/**
* Returns an array whose i<sup>th</sup> entry is the minimum of the
- * i<sup>th</sup> entries of the arrays that have been added using
+ * i<sup>th</sup> entries of the arrays that have been added using
* {@link #addValue(double[])}
- *
+ *
* @return the array of component minima
*/
public double[] getMin() {
@@ -286,15 +286,15 @@
/**
* Returns an array whose i<sup>th</sup> entry is the geometric mean of the
- * i<sup>th</sup> entries of the arrays that have been added using
+ * i<sup>th</sup> entries of the arrays that have been added using
* {@link #addValue(double[])}
- *
+ *
* @return the array of component geometric means
*/
public double[] getGeometricMean() {
return getResults(geoMeanImpl);
}
-
+
/**
* Generates a text report displaying
* summary statistics from values that
@@ -337,7 +337,7 @@
buffer.append(suffix);
}
- /**
+ /**
* Resets all statistics and storage
*/
public void clear() {
@@ -353,7 +353,7 @@
}
covarianceImpl.clear();
}
-
+
/**
* Returns true iff <code>object</code> is a <code>SummaryStatistics</code>
* instance and all statistics have the same values as this.
@@ -369,9 +369,9 @@
return false;
}
MultivariateSummaryStatistics stat = (MultivariateSummaryStatistics) object;
- return (MathUtils.equals(stat.getGeometricMean(),
+ return (MathUtils.equals(stat.getGeometricMean(),
this.getGeometricMean()) &&
- MathUtils.equals(stat.getMax(), this.getMax()) &&
+ MathUtils.equals(stat.getMax(), this.getMax()) &&
MathUtils.equals(stat.getMean(),this.getMean()) &&
MathUtils.equals(stat.getMin(),this.getMin()) &&
MathUtils.equals(stat.getN(), this.getN()) &&
@@ -380,10 +380,10 @@
MathUtils.equals(stat.getSumLog(),this.getSumLog()) &&
stat.getCovariance().equals(this.getCovariance()));
}
-
+
/**
* Returns hash code based on values of statistics
- *
+ *
* @return hash code
*/
@Override
@@ -421,7 +421,7 @@
/**
* Returns the currently configured Sum implementation
- *
+ *
* @return the StorelessUnivariateStatistic implementing the sum
*/
public StorelessUnivariateStatistic[] getSumImpl() {
@@ -431,9 +431,9 @@
/**
* <p>Sets the implementation for the Sum.</p>
* <p>This method must be activated before any data has been added - i.e.,
- * before {@link #addValue(double[]) addValue} has been used to add data;
+ * before {@link #addValue(double[]) addValue} has been used to add data;
* otherwise an IllegalStateException will be thrown.</p>
- *
+ *
* @param sumImpl the StorelessUnivariateStatistic instance to use
* for computing the Sum
* @throws DimensionMismatchException if the array dimension
@@ -448,7 +448,7 @@
/**
* Returns the currently configured sum of squares implementation
- *
+ *
* @return the StorelessUnivariateStatistic implementing the sum of squares
*/
public StorelessUnivariateStatistic[] getSumsqImpl() {
@@ -458,9 +458,9 @@
/**
* <p>Sets the implementation for the sum of squares.</p>
* <p>This method must be activated before any data has been added - i.e.,
- * before {@link #addValue(double[]) addValue} has been used to add data;
+ * before {@link #addValue(double[]) addValue} has been used to add data;
* otherwise an IllegalStateException will be thrown.</p>
- *
+ *
* @param sumsqImpl the StorelessUnivariateStatistic instance to use
* for computing the sum of squares
* @throws DimensionMismatchException if the array dimension
@@ -475,7 +475,7 @@
/**
* Returns the currently configured minimum implementation
- *
+ *
* @return the StorelessUnivariateStatistic implementing the minimum
*/
public StorelessUnivariateStatistic[] getMinImpl() {
@@ -485,9 +485,9 @@
/**
* <p>Sets the implementation for the minimum.</p>
* <p>This method must be activated before any data has been added - i.e.,
- * before {@link #addValue(double[]) addValue} has been used to add data;
+ * before {@link #addValue(double[]) addValue} has been used to add data;
* otherwise an IllegalStateException will be thrown.</p>
- *
+ *
* @param minImpl the StorelessUnivariateStatistic instance to use
* for computing the minimum
* @throws DimensionMismatchException if the array dimension
@@ -502,7 +502,7 @@
/**
* Returns the currently configured maximum implementation
- *
+ *
* @return the StorelessUnivariateStatistic implementing the maximum
*/
public StorelessUnivariateStatistic[] getMaxImpl() {
@@ -512,9 +512,9 @@
/**
* <p>Sets the implementation for the maximum.</p>
* <p>This method must be activated before any data has been added - i.e.,
- * before {@link #addValue(double[]) addValue} has been used to add data;
+ * before {@link #addValue(double[]) addValue} has been used to add data;
* otherwise an IllegalStateException will be thrown.</p>
- *
+ *
* @param maxImpl the StorelessUnivariateStatistic instance to use
* for computing the maximum
* @throws DimensionMismatchException if the array dimension
@@ -529,7 +529,7 @@
/**
* Returns the currently configured sum of logs implementation
- *
+ *
* @return the StorelessUnivariateStatistic implementing the log sum
*/
public StorelessUnivariateStatistic[] getSumLogImpl() {
@@ -539,14 +539,14 @@
/**
* <p>Sets the implementation for the sum of logs.</p>
* <p>This method must be activated before any data has been added - i.e.,
- * before {@link #addValue(double[]) addValue} has been used to add data;
+ * before {@link #addValue(double[]) addValue} has been used to add data;
* otherwise an IllegalStateException will be thrown.</p>
- *
+ *
* @param sumLogImpl the StorelessUnivariateStatistic instance to use
* for computing the log sum
* @throws DimensionMismatchException if the array dimension
* does not match the one used at construction
- * @throws IllegalStateException if data has already been added
+ * @throws IllegalStateException if data has already been added
* (i.e if n > 0)
*/
public void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl)
@@ -556,7 +556,7 @@
/**
* Returns the currently configured geometric mean implementation
- *
+ *
* @return the StorelessUnivariateStatistic implementing the geometric mean
*/
public StorelessUnivariateStatistic[] getGeoMeanImpl() {
@@ -566,9 +566,9 @@
/**
* <p>Sets the implementation for the geometric mean.</p>
* <p>This method must be activated before any data has been added - i.e.,
- * before {@link #addValue(double[]) addValue} has been used to add data;
+ * before {@link #addValue(double[]) addValue} has been used to add data;
* otherwise an IllegalStateException will be thrown.</p>
- *
+ *
* @param geoMeanImpl the StorelessUnivariateStatistic instance to use
* for computing the geometric mean
* @throws DimensionMismatchException if the array dimension
@@ -583,7 +583,7 @@
/**
* Returns the currently configured mean implementation
- *
+ *
* @return the StorelessUnivariateStatistic implementing the mean
*/
public StorelessUnivariateStatistic[] getMeanImpl() {
@@ -593,9 +593,9 @@
/**
* <p>Sets the implementation for the mean.</p>
* <p>This method must be activated before any data has been added - i.e.,
- * before {@link #addValue(double[]) addValue} has been used to add data;
+ * before {@link #addValue(double[]) addValue} has been used to add data;
* otherwise an IllegalStateException will be thrown.</p>
- *
+ *
* @param meanImpl the StorelessUnivariateStatistic instance to use
* for computing the mean
* @throws DimensionMismatchException if the array dimension
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalMultivariateSummary.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalMultivariateSummary.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalMultivariateSummary.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalMultivariateSummary.java Sat Sep 5 17:36:48 2009
@@ -25,7 +25,7 @@
* @version $Revision$ $Date$
*/
public interface StatisticalMultivariateSummary {
- /**
+ /**
* Returns the dimension of the data
* @return The dimension of the data
*/
@@ -34,21 +34,21 @@
* Returns an array whose i<sup>th</sup> entry is the
* mean of the i<sup>th</sup> entries of the arrays
* that correspond to each multivariate sample
- *
+ *
* @return the array of component means
*/
public abstract double[] getMean();
- /**
+ /**
* Returns the covariance of the available values.
* @return The covariance, null if no multivariate sample
- * have been added or a zeroed matrix for a single value set.
+ * have been added or a zeroed matrix for a single value set.
*/
public abstract RealMatrix getCovariance();
/**
* Returns an array whose i<sup>th</sup> entry is the
* standard deviation of the i<sup>th</sup> entries of the arrays
* that correspond to each multivariate sample
- *
+ *
* @return the array of component standard deviations
*/
public abstract double[] getStandardDeviation();
@@ -56,7 +56,7 @@
* Returns an array whose i<sup>th</sup> entry is the
* maximum of the i<sup>th</sup> entries of the arrays
* that correspond to each multivariate sample
- *
+ *
* @return the array of component maxima
*/
public abstract double[] getMax();
@@ -64,11 +64,11 @@
* Returns an array whose i<sup>th</sup> entry is the
* minimum of the i<sup>th</sup> entries of the arrays
* that correspond to each multivariate sample
- *
+ *
* @return the array of component minima
*/
public abstract double[] getMin();
- /**
+ /**
* Returns the number of available values
* @return The number of available values
*/
@@ -77,7 +77,7 @@
* Returns an array whose i<sup>th</sup> entry is the
* geometric mean of the i<sup>th</sup> entries of the arrays
* that correspond to each multivariate sample
- *
+ *
* @return the array of component geometric means
*/
public double[] getGeometricMean();
@@ -85,7 +85,7 @@
* Returns an array whose i<sup>th</sup> entry is the
* sum of the i<sup>th</sup> entries of the arrays
* that correspond to each multivariate sample
- *
+ *
* @return the array of component sums
*/
public abstract double[] getSum();
@@ -93,7 +93,7 @@
* Returns an array whose i<sup>th</sup> entry is the
* sum of squares of the i<sup>th</sup> entries of the arrays
* that correspond to each multivariate sample
- *
+ *
* @return the array of component sums of squares
*/
public abstract double[] getSumSq();
@@ -101,8 +101,8 @@
* Returns an array whose i<sup>th</sup> entry is the
* sum of logs of the i<sup>th</sup> entries of the arrays
* that correspond to each multivariate sample
- *
+ *
* @return the array of component log sums
*/
public abstract double[] getSumLog();
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummary.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummary.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummary.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummary.java Sat Sep 5 17:36:48 2009
@@ -22,35 +22,35 @@
* @version $Revision$ $Date$
*/
public interface StatisticalSummary {
- /**
+ /**
* 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
* @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.
+ * @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.
+ * @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
*/
@@ -60,4 +60,4 @@
* @return The sum or Double.NaN if no values have been added
*/
public abstract double getSum();
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java Sat Sep 5 17:36:48 2009
@@ -24,36 +24,36 @@
*
* @version $Revision$ $Date$
*/
-public class StatisticalSummaryValues implements Serializable,
+public class StatisticalSummaryValues implements Serializable,
StatisticalSummary {
-
+
/** Serialization id */
private static final long serialVersionUID = -5108854841843722536L;
/** The sample mean */
private final double mean;
-
+
/** The sample variance */
private final double variance;
-
+
/** The number of observations in the sample */
private final long n;
-
+
/** The maximum value */
private final double max;
-
+
/** The minimum value */
private final double min;
-
+
/** The sum of the sample values */
private final double sum;
-
+
/**
* Constructor
- *
+ *
* @param mean the sample mean
* @param variance the sample variance
- * @param n the number of observations in the sample
+ * @param n the number of observations in the sample
* @param max the maximum value
* @param min the minimum value
* @param sum the sum of the values
@@ -103,7 +103,7 @@
public double getSum() {
return sum;
}
-
+
/**
* @return Returns the standard deviation
*/
@@ -117,12 +117,12 @@
public double getVariance() {
return variance;
}
-
+
/**
- * Returns true iff <code>object</code> is a
+ * Returns true iff <code>object</code> is a
* <code>StatisticalSummaryValues</code> instance and all statistics have
* the same values as this.
- *
+ *
* @param object the object to test equality against.
* @return true if object equals this
*/
@@ -135,17 +135,17 @@
return false;
}
StatisticalSummaryValues stat = (StatisticalSummaryValues) object;
- return (MathUtils.equals(stat.getMax(), this.getMax()) &&
+ return (MathUtils.equals(stat.getMax(), this.getMax()) &&
MathUtils.equals(stat.getMean(),this.getMean()) &&
MathUtils.equals(stat.getMin(),this.getMin()) &&
MathUtils.equals(stat.getN(), this.getN()) &&
MathUtils.equals(stat.getSum(), this.getSum()) &&
MathUtils.equals(stat.getVariance(),this.getVariance()));
}
-
+
/**
* Returns hash code based on values of statistics
- *
+ *
* @return hash code
*/
@Override
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatistic.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatistic.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatistic.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatistic.java Sat Sep 5 17:36:48 2009
@@ -17,9 +17,9 @@
package org.apache.commons.math.stat.descriptive;
/**
- * Extends the definition of {@link UnivariateStatistic} with
+ * Extends the definition of {@link UnivariateStatistic} with
* {@link #increment} and {@link #incrementAll(double[])} methods for adding
- * values and updating internal state.
+ * values and updating internal state.
* <p>
* This interface is designed to be used for calculating statistics that can be
* computed in one pass through the data without storing the full array of
@@ -34,23 +34,23 @@
* @param d the new value.
*/
void increment(double d);
-
+
/**
* Updates the internal state of the statistic to reflect addition of
* all values in the values array. Does not clear the statistic first --
* i.e., the values are added <strong>incrementally</strong> to the dataset.
- *
+ *
* @param values array holding the new values to add
* @throws IllegalArgumentException if the array is null
*/
void incrementAll(double[] values);
-
+
/**
* Updates the internal state of the statistic to reflect addition of
* the values in the designated portion of the values array. Does not
- * clear the statistic first -- i.e., the values are added
+ * clear the statistic first -- i.e., the values are added
* <strong>incrementally</strong> to the dataset.
- *
+ *
* @param values array holding the new values to add
* @param start the array index of the first value to add
* @param length the number of elements to add
@@ -75,12 +75,12 @@
* Clears the internal state of the Statistic
*/
void clear();
-
+
/**
* Returns a copy of the statistic with the same internal state.
- *
+ *
* @return a copy of the statistic
*/
StorelessUnivariateStatistic copy();
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java Sat Sep 5 17:36:48 2009
@@ -67,7 +67,7 @@
/**
* A copy constructor. Creates a deep-copy of the {@code original}.
- *
+ *
* @param original the {@code SummaryStatistics} instance to copy
*/
public SummaryStatistics(SummaryStatistics original) {
@@ -134,7 +134,7 @@
* @return Current values of statistics
*/
public StatisticalSummary getSummary() {
- return new StatisticalSummaryValues(getMean(), getVariance(), getN(),
+ return new StatisticalSummaryValues(getMean(), getVariance(), getN(),
getMax(), getMin(), getSum());
}
@@ -283,7 +283,7 @@
public double getSumOfLogs() {
return sumLogImpl.getResult();
}
-
+
/**
* Returns a statistic related to the Second Central Moment. Specifically,
* what is returned is the sum of squared deviations from the sample mean
@@ -633,22 +633,22 @@
n);
}
}
-
+
/**
* Returns a copy of this SummaryStatistics instance with the same internal state.
- *
+ *
* @return a copy of this
*/
public SummaryStatistics copy() {
SummaryStatistics result = new SummaryStatistics();
copy(this, result);
- return result;
+ return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source SummaryStatistics to copy
* @param dest SummaryStatistics to copy to
* @throws NullPointerException if either source or dest is null
@@ -669,48 +669,48 @@
}
SecondMoment.copy(source.secondMoment, dest.secondMoment);
dest.n = source.n;
-
+
// Make sure that if stat == statImpl in source, same
// holds in dest; otherwise copy stat
if (source.geoMean == source.geoMeanImpl) {
dest.geoMean = (GeometricMean) dest.geoMeanImpl;
} else {
GeometricMean.copy(source.geoMean, dest.geoMean);
- }
+ }
if (source.max == source.maxImpl) {
dest.max = (Max) dest.maxImpl;
} else {
Max.copy(source.max, dest.max);
- }
+ }
if (source.mean == source.meanImpl) {
dest.mean = (Mean) dest.meanImpl;
} else {
Mean.copy(source.mean, dest.mean);
- }
+ }
if (source.min == source.minImpl) {
dest.min = (Min) dest.minImpl;
} else {
Min.copy(source.min, dest.min);
- }
+ }
if (source.sum == source.sumImpl) {
dest.sum = (Sum) dest.sumImpl;
} else {
Sum.copy(source.sum, dest.sum);
- }
+ }
if (source.variance == source.varianceImpl) {
dest.variance = (Variance) dest.varianceImpl;
} else {
Variance.copy(source.variance, dest.variance);
- }
+ }
if (source.sumLog == source.sumLogImpl) {
dest.sumLog = (SumOfLogs) dest.sumLogImpl;
} else {
SumOfLogs.copy(source.sumLog, dest.sumLog);
- }
+ }
if (source.sumsq == source.sumsqImpl) {
dest.sumsq = (SumOfSquares) dest.sumsqImpl;
} else {
SumOfSquares.copy(source.sumsq, dest.sumsq);
- }
+ }
}
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedDescriptiveStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedDescriptiveStatistics.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedDescriptiveStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedDescriptiveStatistics.java Sat Sep 5 17:36:48 2009
@@ -24,7 +24,7 @@
* conditions. In effect, this implementation makes modification and access
* methods atomic operations for a single instance. That is to say, as one
* thread is computing a statistic from the instance, no other thread can modify
- * the instance nor compute another statistic.
+ * the instance nor compute another statistic.
*
* @since 1.2
* @version $Revision$ $Date$
@@ -48,10 +48,10 @@
public SynchronizedDescriptiveStatistics(int window) {
super(window);
}
-
+
/**
* A copy constructor. Creates a deep-copy of the {@code original}.
- *
+ *
* @param original the {@code SynchronizedDescriptiveStatistics} instance to copy
*/
public SynchronizedDescriptiveStatistics(SynchronizedDescriptiveStatistics original) {
@@ -98,7 +98,7 @@
return super.getN();
}
- /**
+ /**
* {@inheritDoc}
*/
@Override
@@ -137,26 +137,26 @@
public synchronized String toString() {
return super.toString();
}
-
+
/**
* Returns a copy of this SynchronizedDescriptiveStatistics instance with the
* same internal state.
- *
+ *
* @return a copy of this
*/
@Override
public synchronized SynchronizedDescriptiveStatistics copy() {
- SynchronizedDescriptiveStatistics result =
+ SynchronizedDescriptiveStatistics result =
new SynchronizedDescriptiveStatistics();
copy(this, result);
- return result;
+ return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
* <p>Acquires synchronization lock on source, then dest before copying.</p>
- *
+ *
* @param source SynchronizedDescriptiveStatistics to copy
* @param dest SynchronizedDescriptiveStatistics to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java Sat Sep 5 17:36:48 2009
@@ -144,7 +144,7 @@
public synchronized double[] getGeometricMean() {
return super.getGeometricMean();
}
-
+
/**
* {@inheritDoc}
*/
@@ -160,7 +160,7 @@
public synchronized void clear() {
super.clear();
}
-
+
/**
* {@inheritDoc}
*/
@@ -168,7 +168,7 @@
public synchronized boolean equals(Object object) {
return super.equals(object);
}
-
+
/**
* {@inheritDoc}
*/
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedSummaryStatistics.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedSummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedSummaryStatistics.java Sat Sep 5 17:36:48 2009
@@ -24,7 +24,7 @@
* conditions. In effect, this implementation makes modification and access
* methods atomic operations for a single instance. That is to say, as one
* thread is computing a statistic from the instance, no other thread can modify
- * the instance nor compute another statistic.
+ * the instance nor compute another statistic.
*
* @since 1.2
* @version $Revision$ $Date$
@@ -40,10 +40,10 @@
public SynchronizedSummaryStatistics() {
super();
}
-
+
/**
* A copy constructor. Creates a deep-copy of the {@code original}.
- *
+ *
* @param original the {@code SynchronizedSummaryStatistics} instance to copy
*/
public SynchronizedSummaryStatistics(SynchronizedSummaryStatistics original) {
@@ -66,7 +66,7 @@
super.addValue(value);
}
- /**
+ /**
* {@inheritDoc}
*/
@Override
@@ -146,7 +146,7 @@
return super.toString();
}
- /**
+ /**
* {@inheritDoc}
*/
@Override
@@ -297,26 +297,26 @@
public synchronized void setVarianceImpl(StorelessUnivariateStatistic varianceImpl) {
super.setVarianceImpl(varianceImpl);
}
-
+
/**
* Returns a copy of this SynchronizedSummaryStatistics instance with the
* same internal state.
- *
+ *
* @return a copy of this
*/
@Override
public synchronized SynchronizedSummaryStatistics copy() {
- SynchronizedSummaryStatistics result =
+ SynchronizedSummaryStatistics result =
new SynchronizedSummaryStatistics();
copy(this, result);
- return result;
+ return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
* <p>Acquires synchronization lock on source, then dest before copying.</p>
- *
+ *
* @param source SynchronizedSummaryStatistics to copy
* @param dest SynchronizedSummaryStatistics to copy to
* @throws NullPointerException if either source or dest is null
@@ -329,5 +329,5 @@
}
}
}
-
+
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/UnivariateStatistic.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/UnivariateStatistic.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/UnivariateStatistic.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/UnivariateStatistic.java Sat Sep 5 17:36:48 2009
@@ -19,14 +19,14 @@
/**
* Base interface implemented by all statistics.
- *
+ *
* @version $Revision$ $Date$
*/
public interface UnivariateStatistic {
/**
* Returns the result of evaluating the statistic over the input array.
- *
+ *
* @param values input array
* @return the value of the statistic applied to the input array
*/
@@ -35,17 +35,17 @@
/**
* Returns the result of evaluating the statistic over the specified entries
* in the input array.
- *
+ *
* @param values the input array
* @param begin the index of the first element to include
* @param length the number of elements to include
* @return the value of the statistic applied to the included array entries
*/
double evaluate(double[] values, int begin, int length);
-
+
/**
* Returns a copy of the statistic with the same internal state.
- *
+ *
* @return a copy of the statistic
*/
UnivariateStatistic copy();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/FirstMoment.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/FirstMoment.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/FirstMoment.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/FirstMoment.java Sat Sep 5 17:36:48 2009
@@ -37,32 +37,32 @@
* <p>
* Returns <code>Double.NaN</code> if the dataset is empty.</p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
*
* @version $Revision$ $Date$
*/
-public class FirstMoment extends AbstractStorelessUnivariateStatistic
+public class FirstMoment extends AbstractStorelessUnivariateStatistic
implements Serializable {
/** Serializable version identifier */
private static final long serialVersionUID = 6112755307178490473L;
-
+
/** Count of values that have been added */
protected long n;
/** First moment of values that have been added */
protected double m1;
-
- /**
+
+ /**
* Deviation of most recently added value from previous first moment.
* Retained to prevent repeated computation in higher order moments.
*/
protected double dev;
-
+
/**
* Deviation of most recently added value from previous first moment,
* normalized by previous sample size. Retained to prevent repeated
@@ -79,18 +79,18 @@
dev = Double.NaN;
nDev = Double.NaN;
}
-
+
/**
* Copy constructor, creates a new {@code FirstMoment} identical
* to the {@code original}
- *
+ *
* @param original the {@code FirstMoment} instance to copy
*/
public FirstMoment(FirstMoment original) {
super();
copy(original, this);
}
-
+
/**
* {@inheritDoc}
*/
@@ -131,7 +131,7 @@
public long getN() {
return n;
}
-
+
/**
* {@inheritDoc}
*/
@@ -139,13 +139,13 @@
public FirstMoment copy() {
FirstMoment result = new FirstMoment();
copy(this, result);
- return result;
+ return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source FirstMoment to copy
* @param dest FirstMoment to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/FourthMoment.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/FourthMoment.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/FourthMoment.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/FourthMoment.java Sat Sep 5 17:36:48 2009
@@ -20,11 +20,11 @@
/**
* Computes a statistic related to the Fourth Central Moment. Specifically,
- * what is computed is the sum of
+ * what is computed is the sum of
* <p>
* (x_i - xbar) ^ 4, </p>
* <p>
- * where the x_i are the
+ * where the x_i are the
* sample observations and xbar is the sample mean. </p>
* <p>
* The following recursive updating formula is used: </p>
@@ -43,18 +43,18 @@
* Returns <code>Double.NaN</code> if no data values have been added and
* returns <code>0</code> if there is just one value in the data set. </p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally. </p>
- *
+ *
* @version $Revision$ $Date$
*/
public class FourthMoment extends ThirdMoment implements Serializable{
/** Serializable version identifier */
private static final long serialVersionUID = 4763990447117157611L;
-
+
/** fourth moment of values that have been added */
protected double m4;
@@ -65,18 +65,18 @@
super();
m4 = Double.NaN;
}
-
+
/**
* Copy constructor, creates a new {@code FourthMoment} identical
* to the {@code original}
- *
+ *
* @param original the {@code FourthMoment} instance to copy
*/
public FourthMoment(FourthMoment original) {
super();
copy(original, this);
}
-
+
/**
* {@inheritDoc}
*/
@@ -91,9 +91,9 @@
double prevM3 = m3;
double prevM2 = m2;
-
+
super.increment(d);
-
+
double n0 = n;
m4 = m4 - 4.0 * nDev * prevM3 + 6.0 * nDevSq * prevM2 +
@@ -116,7 +116,7 @@
super.clear();
m4 = Double.NaN;
}
-
+
/**
* {@inheritDoc}
*/
@@ -126,11 +126,11 @@
copy(this, result);
return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source FourthMoment to copy
* @param dest FourthMoment to copy to
* @throws NullPointerException if either source or dest is null
@@ -138,5 +138,5 @@
public static void copy(FourthMoment source, FourthMoment dest) {
ThirdMoment.copy(source, dest);
dest.m4 = source.m4;
- }
+ }
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java Sat Sep 5 17:36:48 2009
@@ -31,27 +31,27 @@
* <code> exp( 1/n (sum of logs) ).</code> Therefore, </p>
* <ul>
* <li>If any of values are < 0, the result is <code>NaN.</code></li>
- * <li>If all values are non-negative and less than
- * <code>Double.POSITIVE_INFINITY</code>, but at least one value is 0, the
+ * <li>If all values are non-negative and less than
+ * <code>Double.POSITIVE_INFINITY</code>, but at least one value is 0, the
* result is <code>0.</code></li>
- * <li>If both <code>Double.POSITIVE_INFINITY</code> and
+ * <li>If both <code>Double.POSITIVE_INFINITY</code> and
* <code>Double.NEGATIVE_INFINITY</code> are among the values, the result is
* <code>NaN.</code></li>
* </ul> </p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
*
* @version $Revision$ $Date$
*/
public class GeometricMean extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -8178734905303459453L;
-
+ private static final long serialVersionUID = -8178734905303459453L;
+
/** Wrapped SumOfLogs instance */
private StorelessUnivariateStatistic sumOfLogs;
@@ -61,18 +61,18 @@
public GeometricMean() {
sumOfLogs = new SumOfLogs();
}
-
+
/**
* Copy constructor, creates a new {@code GeometricMean} identical
* to the {@code original}
- *
+ *
* @param original the {@code GeometricMean} instance to copy
*/
public GeometricMean(GeometricMean original) {
super();
copy(original, this);
}
-
+
/**
* {@inheritDoc}
*/
@@ -82,7 +82,7 @@
copy(this, result);
return result;
}
-
+
/**
* Create a GeometricMean instance using the given SumOfLogs instance
* @param sumOfLogs sum of logs instance to use for computation
@@ -90,7 +90,7 @@
public GeometricMean(SumOfLogs sumOfLogs) {
this.sumOfLogs = sumOfLogs;
}
-
+
/**
* {@inheritDoc}
*/
@@ -126,7 +126,7 @@
* See {@link GeometricMean} for details on the computing algorithm.</p>
* <p>
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
- *
+ *
* @param values input array containing the values
* @param begin first array element to include
* @param length the number of elements to include
@@ -141,23 +141,23 @@
return Math.exp(
sumOfLogs.evaluate(values, begin, length) / length);
}
-
+
/**
* {@inheritDoc}
*/
public long getN() {
return sumOfLogs.getN();
}
-
+
/**
* <p>Sets the implementation for the sum of logs.</p>
* <p>This method must be activated before any data has been added - i.e.,
- * before {@link #increment(double) increment} has been used to add data;
+ * before {@link #increment(double) increment} has been used to add data;
* otherwise an IllegalStateException will be thrown.</p>
- *
+ *
* @param sumLogImpl the StorelessUnivariateStatistic instance to use
* for computing the log sum
- * @throws IllegalStateException if data has already been added
+ * @throws IllegalStateException if data has already been added
* (i.e if n > 0)
*/
public void setSumLogImpl(
@@ -165,20 +165,20 @@
checkEmpty();
this.sumOfLogs = sumLogImpl;
}
-
+
/**
* Returns the currently configured sum of logs implementation
- *
+ *
* @return the StorelessUnivariateStatistic implementing the log sum
*/
public StorelessUnivariateStatistic getSumLogImpl() {
return sumOfLogs;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source GeometricMean to copy
* @param dest GeometricMean to copy to
* @throws NullPointerException if either source or dest is null
@@ -186,8 +186,8 @@
public static void copy(GeometricMean source, GeometricMean dest) {
dest.sumOfLogs = source.sumOfLogs.copy();
}
-
-
+
+
/**
* Throws IllegalStateException if n > 0.
*/
@@ -199,4 +199,4 @@
}
}
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java Sat Sep 5 17:36:48 2009
@@ -35,22 +35,22 @@
* Note that this statistic is undefined for n < 4. <code>Double.Nan</code>
* is returned when there is not sufficient data to compute the statistic.</p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class Kurtosis extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = 2784465764798260919L;
-
+ private static final long serialVersionUID = 2784465764798260919L;
+
/**Fourth Moment on which this statistic is based */
protected FourthMoment moment;
- /**
+ /**
* Determines whether or not this statistic can be incremented or cleared.
* <p>
* Statistics based on (constructed from) external moments cannot
@@ -68,18 +68,18 @@
/**
* Construct a Kurtosis from an external moment
- *
+ *
* @param m4 external Moment
*/
public Kurtosis(final FourthMoment m4) {
incMoment = false;
this.moment = m4;
}
-
+
/**
* Copy constructor, creates a new {@code Kurtosis} identical
* to the {@code original}
- *
+ *
* @param original the {@code Kurtosis} instance to copy
*/
public Kurtosis(Kurtosis original) {
@@ -139,17 +139,17 @@
public long getN() {
return moment.getN();
}
-
+
/* UnvariateStatistic Approach */
/**
* Returns the kurtosis of the entries in the specified portion of the
- * input array.
+ * input array.
* <p>
* See {@link Kurtosis} for details on the computing algorithm.</p>
* <p>
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
- *
+ *
* @param values the input array
* @param begin index of the first array element to include
* @param length the number of elements to include
@@ -160,17 +160,17 @@
*/
@Override
public double evaluate(final double[] values,final int begin, final int length) {
- // Initialize the kurtosis
- double kurt = Double.NaN;
-
- if (test(values, begin, length) && length > 3) {
-
+ // Initialize the kurtosis
+ double kurt = Double.NaN;
+
+ if (test(values, begin, length) && length > 3) {
+
// Compute the mean and standard deviation
Variance variance = new Variance();
variance.incrementAll(values, begin, length);
double mean = variance.moment.m1;
double stdDev = Math.sqrt(variance.getResult());
-
+
// Sum the ^4 of the distance from the mean divided by the
// standard deviation
double accum3 = 0.0;
@@ -178,21 +178,21 @@
accum3 += Math.pow((values[i] - mean), 4.0);
}
accum3 /= Math.pow(stdDev, 4.0d);
-
+
// Get N
double n0 = length;
-
+
double coefficientOne =
(n0 * (n0 + 1)) / ((n0 - 1) * (n0 - 2) * (n0 - 3));
double termTwo =
((3 * Math.pow(n0 - 1, 2.0)) / ((n0 - 2) * (n0 - 3)));
-
+
// Calculate kurtosis
kurt = (coefficientOne * accum3) - termTwo;
- }
+ }
return kurt;
}
-
+
/**
* {@inheritDoc}
*/
@@ -202,11 +202,11 @@
copy(this, result);
return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source Kurtosis to copy
* @param dest Kurtosis to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Mean.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Mean.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Mean.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Mean.java Sat Sep 5 17:36:48 2009
@@ -48,23 +48,23 @@
* <p>
* Returns <code>Double.NaN</code> if the dataset is empty.
* </p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.
- *
+ *
* @version $Revision$ $Date$
*/
-public class Mean extends AbstractStorelessUnivariateStatistic
+public class Mean extends AbstractStorelessUnivariateStatistic
implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -1296043746617791564L;
-
+ private static final long serialVersionUID = -1296043746617791564L;
+
/** First moment on which this statistic is based. */
protected FirstMoment moment;
- /**
+ /**
* Determines whether or not this statistic can be incremented or cleared.
* <p>
* Statistics based on (constructed from) external moments cannot
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/SecondMoment.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/SecondMoment.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/SecondMoment.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/SecondMoment.java Sat Sep 5 17:36:48 2009
@@ -35,18 +35,18 @@
* Returns <code>Double.NaN</code> if no data values have been added and
* returns <code>0</code> if there is just one value in the data set.</p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class SecondMoment extends FirstMoment implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = 3942403127395076445L;
-
+ private static final long serialVersionUID = 3942403127395076445L;
+
/** second moment of values that have been added */
protected double m2;
@@ -57,18 +57,18 @@
super();
m2 = Double.NaN;
}
-
+
/**
* Copy constructor, creates a new {@code SecondMoment} identical
* to the {@code original}
- *
+ *
* @param original the {@code SecondMoment} instance to copy
*/
public SecondMoment(SecondMoment original) {
super(original);
this.m2 = original.m2;
}
-
+
/**
* {@inheritDoc}
*/
@@ -97,7 +97,7 @@
public double getResult() {
return m2;
}
-
+
/**
* {@inheritDoc}
*/
@@ -105,13 +105,13 @@
public SecondMoment copy() {
SecondMoment result = new SecondMoment();
copy(this, result);
- return result;
+ return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source SecondMoment to copy
* @param dest SecondMoment to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java Sat Sep 5 17:36:48 2009
@@ -27,25 +27,25 @@
* <p>
* skewness = [n / (n -1) (n - 2)] sum[(x_i - mean)^3] / std^3 </p>
* <p>
- * where n is the number of values, mean is the {@link Mean} and std is the
+ * where n is the number of values, mean is the {@link Mean} and std is the
* {@link StandardDeviation} </p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally. </p>
- *
+ *
* @version $Revision$ $Date$
*/
public class Skewness extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = 7101857578996691352L;
-
+ private static final long serialVersionUID = 7101857578996691352L;
+
/** Third moment on which this statistic is based */
protected ThirdMoment moment = null;
- /**
+ /**
* Determines whether or not this statistic can be incremented or cleared.
* <p>
* Statistics based on (constructed from) external moments cannot
@@ -69,11 +69,11 @@
incMoment = false;
this.moment = m3;
}
-
+
/**
* Copy constructor, creates a new {@code Skewness} identical
* to the {@code original}
- *
+ *
* @param original the {@code Skewness} instance to copy
*/
public Skewness(Skewness original) {
@@ -94,12 +94,12 @@
* Returns the value of the statistic based on the values that have been added.
* <p>
* See {@link Skewness} for the definition used in the computation.</p>
- *
+ *
* @return the skewness of the available values.
*/
@Override
public double getResult() {
-
+
if (moment.n < 3) {
return Double.NaN;
}
@@ -119,7 +119,7 @@
public long getN() {
return moment.getN();
}
-
+
/**
* {@inheritDoc}
*/
@@ -137,7 +137,7 @@
* See {@link Skewness} for the definition used in the computation.</p>
* <p>
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
- *
+ *
* @param values the input array
* @param begin the index of the first array element to include
* @param length the number of elements to include
@@ -147,7 +147,7 @@
* parameters are not valid
*/
@Override
- public double evaluate(final double[] values,final int begin,
+ public double evaluate(final double[] values,final int begin,
final int length) {
// Initialize the skewness
@@ -157,7 +157,7 @@
Mean mean = new Mean();
// Get the mean and the standard deviation
double m = mean.evaluate(values, begin, length);
-
+
// Calc the std, this is implemented here instead
// of using the standardDeviation method eliminate
// a duplicate pass to get the mean
@@ -169,22 +169,22 @@
}
double stdDev = Math.sqrt((accum - (Math.pow(accum2, 2) / length)) /
(length - 1));
-
+
double accum3 = 0.0;
for (int i = begin; i < begin + length; i++) {
accum3 += Math.pow(values[i] - m, 3.0d);
}
accum3 /= Math.pow(stdDev, 3.0d);
-
+
// Get N
double n0 = length;
-
+
// Calculate skewness
skew = (n0 / ((n0 - 1) * (n0 - 2))) * accum3;
}
return skew;
}
-
+
/**
* {@inheritDoc}
*/
@@ -194,11 +194,11 @@
copy(this, result);
return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source Skewness to copy
* @param dest Skewness to copy to
* @throws NullPointerException if either source or dest is null