public class DescriptiveStatistics extends java.lang.Object implements StatisticalSummary, java.io.Serializable
windowSize
 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,
 org.apache.commons.math3.stat.descriptive.SummaryStatistics, which does not store the dataset, should be used
 instead of this class. If windowSize 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
 in the dataset.
 Note: this class is not threadsafe.  Use
 SynchronizedDescriptiveStatistics if concurrent access from multiple
 threads is required.
| Modifier and Type | Field and Description | 
|---|---|
| protected ResizableDoubleArray | eDAStored data values | 
| static int | INFINITE_WINDOWRepresents an infinite window size. | 
| protected int | windowSizehold the window size * | 
| Constructor and Description | 
|---|
| DescriptiveStatistics()Construct a DescriptiveStatistics instance with an infinite window | 
| DescriptiveStatistics(DescriptiveStatistics original)Copy constructor. | 
| DescriptiveStatistics(int window)Construct a DescriptiveStatistics instance with the specified window | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addValue(double v)Adds the value to the dataset. | 
| double | apply(UnivariateStatistic stat)Apply the given statistic to the data associated with this set of statistics. | 
| void | clear()Resets all statistics and storage | 
| DescriptiveStatistics | copy()Returns a copy of this DescriptiveStatistics instance with the same internal state. | 
| static void | copy(DescriptiveStatistics source,
    DescriptiveStatistics dest)Copies source to dest. | 
| double | getElement(int index)Returns the element at the specified index | 
| double | getGeometricMean()Returns the 
 geometric mean  of the available values | 
| UnivariateStatistic | getGeometricMeanImpl()Returns the currently configured geometric mean implementation. | 
| double | getKurtosis()Returns the Kurtosis of the available values. | 
| UnivariateStatistic | getKurtosisImpl()Returns the currently configured kurtosis implementation. | 
| double | getMax()Returns the maximum of the available values | 
| UnivariateStatistic | getMaxImpl()Returns the currently configured maximum implementation. | 
| double | getMean()Returns the 
 arithmetic mean  of the available values | 
| UnivariateStatistic | getMeanImpl()Returns the currently configured mean implementation. | 
| double | getMin()Returns the minimum of the available values | 
| UnivariateStatistic | getMinImpl()Returns the currently configured minimum implementation. | 
| long | getN()Returns the number of available values | 
| double | getPercentile(double p)Returns an estimate for the pth percentile of the stored values. | 
| UnivariateStatistic | getPercentileImpl()Returns the currently configured percentile implementation. | 
| double | getSkewness()Returns the skewness of the available values. | 
| UnivariateStatistic | getSkewnessImpl()Returns the currently configured skewness implementation. | 
| double[] | getSortedValues()Returns the current set of values in an array of double primitives,
 sorted in ascending order. | 
| double | getStandardDeviation()Returns the standard deviation of the available values. | 
| double | getSum()Returns the sum of the values that have been added to Univariate. | 
| UnivariateStatistic | getSumImpl()Returns the currently configured sum implementation. | 
| double | getSumsq()Returns the sum of the squares of the available values. | 
| UnivariateStatistic | getSumsqImpl()Returns the currently configured sum of squares implementation. | 
| double[] | getValues()Returns the current set of values in an array of double primitives. | 
| double | getVariance()Returns the variance of the available values. | 
| UnivariateStatistic | getVarianceImpl()Returns the currently configured variance implementation. | 
| int | getWindowSize()Returns the maximum number of values that can be stored in the
 dataset, or INFINITE_WINDOW (-1) if there is no limit. | 
| void | removeMostRecentValue()Removes the most recent value from the dataset. | 
| double | replaceMostRecentValue(double v)Replaces the most recently stored value with the given value. | 
| void | setGeometricMeanImpl(UnivariateStatistic geometricMeanImpl)Sets the implementation for the gemoetric mean. | 
| void | setKurtosisImpl(UnivariateStatistic kurtosisImpl)Sets the implementation for the kurtosis. | 
| void | setMaxImpl(UnivariateStatistic maxImpl)Sets the implementation for the maximum. | 
| void | setMeanImpl(UnivariateStatistic meanImpl)Sets the implementation for the mean. | 
| void | setMinImpl(UnivariateStatistic minImpl)Sets the implementation for the minimum. | 
| void | setPercentileImpl(UnivariateStatistic percentileImpl)Sets the implementation to be used by  getPercentile(double). | 
| void | setSkewnessImpl(UnivariateStatistic skewnessImpl)Sets the implementation for the skewness. | 
| void | setSumImpl(UnivariateStatistic sumImpl)Sets the implementation for the sum. | 
| void | setSumsqImpl(UnivariateStatistic sumsqImpl)Sets the implementation for the sum of squares. | 
| void | setVarianceImpl(UnivariateStatistic varianceImpl)Sets the implementation for the variance. | 
| void | setWindowSize(int windowSize)WindowSize controls the number of values which contribute
 to the reported statistics. | 
| java.lang.String | toString()Generates a text report displaying univariate statistics from values
 that have been added. | 
public static final int INFINITE_WINDOW
getWindowSize()
 returns this value, there is no limit to the number of data values
 that can be stored in the dataset.protected int windowSize
protected ResizableDoubleArray eDA
public DescriptiveStatistics()
public DescriptiveStatistics(int window)
window - the window size.public DescriptiveStatistics(DescriptiveStatistics original)
original - DescriptiveStatistics instance to copypublic void addValue(double v)
v - the value to be addedpublic void removeMostRecentValue()
public double replaceMostRecentValue(double v)
v - the value to replace the most recent stored valuepublic double getMean()
getMean in interface StatisticalSummarypublic double getGeometricMean()
public double getVariance()
getVariance in interface StatisticalSummarypublic double getStandardDeviation()
getStandardDeviation in interface StatisticalSummarypublic double getSkewness()
public double getKurtosis()
public double getMax()
getMax in interface StatisticalSummarypublic double getMin()
getMin in interface StatisticalSummarypublic long getN()
getN in interface StatisticalSummarypublic double getSum()
getSum in interface StatisticalSummarypublic double getSumsq()
public void clear()
public int getWindowSize()
public void setWindowSize(int windowSize)
windowSize - sets the size of the window.public double[] getValues()
public double[] getSortedValues()
public double getElement(int index)
index - The Index of the elementpublic double getPercentile(double p)
The implementation provided here follows the first estimation procedure presented here.
Preconditions:
0 < p ≤ 100IllegalArgumentException is thrown)Double.NaN
  otherwise)p - the requested percentile (scaled from 0 - 100)java.lang.IllegalStateException - if percentile implementation has been
                               overridden and the supplied implementation does not support setQuantile
                               valuespublic java.lang.String toString()
toString in class java.lang.Objectpublic double apply(UnivariateStatistic stat)
stat - the statistic to applypublic UnivariateStatistic getMeanImpl()
public void setMeanImpl(UnivariateStatistic meanImpl)
Sets the implementation for the mean.
meanImpl - the UnivariateStatistic instance to use
                 for computing the meanpublic UnivariateStatistic getGeometricMeanImpl()
public void setGeometricMeanImpl(UnivariateStatistic geometricMeanImpl)
Sets the implementation for the gemoetric mean.
geometricMeanImpl - the UnivariateStatistic instance to use
                          for computing the geometric meanpublic UnivariateStatistic getKurtosisImpl()
public void setKurtosisImpl(UnivariateStatistic kurtosisImpl)
Sets the implementation for the kurtosis.
kurtosisImpl - the UnivariateStatistic instance to use
                     for computing the kurtosispublic UnivariateStatistic getMaxImpl()
public void setMaxImpl(UnivariateStatistic maxImpl)
Sets the implementation for the maximum.
maxImpl - the UnivariateStatistic instance to use
                for computing the maximumpublic UnivariateStatistic getMinImpl()
public void setMinImpl(UnivariateStatistic minImpl)
Sets the implementation for the minimum.
minImpl - the UnivariateStatistic instance to use
                for computing the minimumpublic UnivariateStatistic getPercentileImpl()
public void setPercentileImpl(UnivariateStatistic percentileImpl)
getPercentile(double).
 The supplied UnivariateStatistic must provide a
 setQuantile(double) method; otherwise
 IllegalArgumentException is thrown.percentileImpl - the percentileImpl to setjava.lang.IllegalArgumentException - if the supplied implementation does not
                                  provide a setQuantile methodpublic UnivariateStatistic getSkewnessImpl()
public void setSkewnessImpl(UnivariateStatistic skewnessImpl)
Sets the implementation for the skewness.
skewnessImpl - the UnivariateStatistic instance to use
                     for computing the skewnesspublic UnivariateStatistic getVarianceImpl()
public void setVarianceImpl(UnivariateStatistic varianceImpl)
Sets the implementation for the variance.
varianceImpl - the UnivariateStatistic instance to use
                     for computing the variancepublic UnivariateStatistic getSumsqImpl()
public void setSumsqImpl(UnivariateStatistic sumsqImpl)
Sets the implementation for the sum of squares.
sumsqImpl - the UnivariateStatistic instance to use
                  for computing the sum of squarespublic UnivariateStatistic getSumImpl()
public void setSumImpl(UnivariateStatistic sumImpl)
Sets the implementation for the sum.
sumImpl - the UnivariateStatistic instance to use
                for computing the sumpublic DescriptiveStatistics copy()
public static void copy(DescriptiveStatistics source, DescriptiveStatistics dest)
Neither source nor dest can be null.
source - DescriptiveStatistics to copydest - DescriptiveStatistics to copy tojava.lang.NullPointerException - if either source or dest is null