public class DescriptiveStatistics extends Object implements StatisticalSummary, 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,
 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 | 
|---|---|
| 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(double[] initialDoubleArray)Construct a DescriptiveStatistics instance with an infinite window
 and the initial data values in double[] initialDoubleArray. | 
| 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 | getPopulationVariance()Returns the 
 population variance of the available values. | 
| double | getQuadraticMean()Returns the quadratic mean, a.k.a. | 
| 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 (sample) 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 that contribute to the
 reported statistics. | 
| 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
public DescriptiveStatistics()
public DescriptiveStatistics(int window)
                      throws MathIllegalArgumentException
window - the window size.MathIllegalArgumentException - if window size is less than 1 but
 not equal to INFINITE_WINDOWpublic DescriptiveStatistics(double[] initialDoubleArray)
initialDoubleArray - the initial double[].public DescriptiveStatistics(DescriptiveStatistics original) throws NullArgumentException
original - DescriptiveStatistics instance to copyNullArgumentException - if original is nullpublic void addValue(double v)
v - the value to be addedpublic void removeMostRecentValue()
                           throws MathIllegalStateException
MathIllegalStateException - if there are no elements storedpublic double replaceMostRecentValue(double v)
                              throws MathIllegalStateException
v - the value to replace the most recent stored valueMathIllegalStateException - if there are no elements storedpublic double getMean()
getMean in interface StatisticalSummarypublic double getGeometricMean()
 See GeometricMean for details on the computing algorithm.
public double getVariance()
This method returns the bias-corrected sample variance (using n - 1 in
 the denominator).  Use getPopulationVariance() for the non-bias-corrected
 population variance.
getVariance in interface StatisticalSummarypublic double getPopulationVariance()
public double getStandardDeviation()
getStandardDeviation in interface StatisticalSummarypublic double getQuadraticMean()
Double.NaN if no values
 have been added.public 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)
                   throws MathIllegalArgumentException
windowSize is decreased as a result
 of this call and there are more than the new value of elements in the
 current dataset, values from the front of the array are discarded to
 reduce the dataset to windowSize elements.windowSize - sets the size of the window.MathIllegalArgumentException - if window size is less than 1 but
 not equal to INFINITE_WINDOWpublic double[] getValues()
public double[] getSortedValues()
public double getElement(int index)
index - The Index of the elementpublic double getPercentile(double p)
                     throws MathIllegalStateException,
                            MathIllegalArgumentException
The implementation provided here follows the first estimation procedure presented here.
Preconditions:
0 < p ≤ 100 (otherwise an
 MathIllegalArgumentException is thrown)Double.NaN
      otherwise)p - the requested percentile (scaled from 0 - 100)MathIllegalStateException - if percentile implementation has been
  overridden and the supplied implementation does not support setQuantileMathIllegalArgumentException - if p is not a valid quantilepublic String toString()
public 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) throws MathIllegalArgumentException
getPercentile(double).
 The supplied UnivariateStatistic must provide a
 setQuantile(double) method; otherwise
 IllegalArgumentException is thrown.percentileImpl - the percentileImpl to setMathIllegalArgumentException - 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) throws NullArgumentException
Neither source nor dest can be null.
source - DescriptiveStatistics to copydest - DescriptiveStatistics to copy toNullArgumentException - if either source or dest is nullCopyright © 2003–2016 The Apache Software Foundation. All rights reserved.