public class SummaryStatistics extends Object implements StatisticalSummary, Serializable
Computes summary statistics for a stream of data values added using the
addValue
method. The data values are not stored in
memory, so this class can be used to compute statistics for very large data
streams.
The StorelessUnivariateStatistic
instances used to maintain summary
state and compute statistics are configurable via setters. For example, the
default implementation for the variance can be overridden by calling
setVarianceImpl(StorelessUnivariateStatistic)
. Actual parameters to
these methods must implement the StorelessUnivariateStatistic
interface and configuration must be completed before addValue
is called. No configuration is necessary to use the default, commonsmath
provided implementations.
Note: This class is not threadsafe. Use
SynchronizedSummaryStatistics
if concurrent access from multiple
threads is required.
Constructor and Description 

SummaryStatistics()
Construct a SummaryStatistics instance

SummaryStatistics(SummaryStatistics original)
A copy constructor.

Modifier and Type  Method and Description 

void 
addValue(double value)
Add a value to the data

void 
clear()
Resets all statistics and storage

SummaryStatistics 
copy()
Returns a copy of this SummaryStatistics instance with the same internal state.

static void 
copy(SummaryStatistics source,
SummaryStatistics dest)
Copies source to dest.

boolean 
equals(Object object)
Returns true iff
object is a
SummaryStatistics instance and all statistics have the
same values as this. 
StorelessUnivariateStatistic 
getGeoMeanImpl()
Returns the currently configured geometric mean implementation

double 
getGeometricMean()
Returns the geometric mean of the values that have been added.

double 
getMax()
Returns the maximum of the values that have been added.

StorelessUnivariateStatistic 
getMaxImpl()
Returns the currently configured maximum implementation

double 
getMean()
Returns the mean of the values that have been added.

StorelessUnivariateStatistic 
getMeanImpl()
Returns the currently configured mean implementation

double 
getMin()
Returns the minimum of the values that have been added.

StorelessUnivariateStatistic 
getMinImpl()
Returns the currently configured minimum implementation

long 
getN()
Returns the number of available values

double 
getPopulationVariance()
Returns the
population variance of the values that have been added.

double 
getSecondMoment()
Returns a statistic related to the Second Central Moment.

double 
getStandardDeviation()
Returns the standard deviation of the values that have been added.

double 
getSum()
Returns the sum of the values that have been added

StorelessUnivariateStatistic 
getSumImpl()
Returns the currently configured Sum implementation

StorelessUnivariateStatistic 
getSumLogImpl()
Returns the currently configured sum of logs implementation

StatisticalSummary 
getSummary()
Return a
StatisticalSummaryValues instance reporting current
statistics. 
double 
getSumOfLogs()
Returns the sum of the logs of the values that have been added.

double 
getSumsq()
Returns the sum of the squares of the values that have been added.

StorelessUnivariateStatistic 
getSumsqImpl()
Returns the currently configured sum of squares implementation

double 
getVariance()
Returns the (sample) variance of the available values.

StorelessUnivariateStatistic 
getVarianceImpl()
Returns the currently configured variance implementation

int 
hashCode()
Returns hash code based on values of statistics

void 
setGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl)
Sets the implementation for the geometric mean.

void 
setMaxImpl(StorelessUnivariateStatistic maxImpl)
Sets the implementation for the maximum.

void 
setMeanImpl(StorelessUnivariateStatistic meanImpl)
Sets the implementation for the mean.

void 
setMinImpl(StorelessUnivariateStatistic minImpl)
Sets the implementation for the minimum.

void 
setSumImpl(StorelessUnivariateStatistic sumImpl)
Sets the implementation for the Sum.

void 
setSumLogImpl(StorelessUnivariateStatistic sumLogImpl)
Sets the implementation for the sum of logs.

void 
setSumsqImpl(StorelessUnivariateStatistic sumsqImpl)
Sets the implementation for the sum of squares.

void 
setVarianceImpl(StorelessUnivariateStatistic varianceImpl)
Sets the implementation for the variance.

String 
toString()
Generates a text report displaying summary statistics from values that
have been added.

public SummaryStatistics()
public SummaryStatistics(SummaryStatistics original) throws NullArgumentException
original
.original
 the SummaryStatistics
instance to copyNullArgumentException
 if original is nullpublic StatisticalSummary getSummary()
StatisticalSummaryValues
instance reporting current
statistics.public void addValue(double value)
value
 the value to addpublic long getN()
getN
in interface StatisticalSummary
public double getSum()
getSum
in interface StatisticalSummary
Double.NaN
if no values have been addedpublic double getSumsq()
Double.NaN is returned if no values have been added.
public double getMean()
Double.NaN is returned if no values have been added.
getMean
in interface StatisticalSummary
public double getStandardDeviation()
Double.NaN is returned if no values have been added.
getStandardDeviation
in interface StatisticalSummary
public double getVariance()
This method returns the biascorrected sample variance (using n  1
in
the denominator). Use getPopulationVariance()
for the nonbiascorrected
population variance.
Double.NaN is returned if no values have been added.
getVariance
in interface StatisticalSummary
public double getPopulationVariance()
Double.NaN is returned if no values have been added.
public double getMax()
Double.NaN is returned if no values have been added.
getMax
in interface StatisticalSummary
public double getMin()
Double.NaN is returned if no values have been added.
getMin
in interface StatisticalSummary
public double getGeometricMean()
Double.NaN is returned if no values have been added.
public double getSumOfLogs()
Double.NaN is returned if no values have been added.
public double getSecondMoment()
Returns Double.NaN
if no data values have been added and
returns 0
if there is just one value in the data set.
public String toString()
public void clear()
public boolean equals(Object object)
object
is a
SummaryStatistics
instance and all statistics have the
same values as this.public int hashCode()
public StorelessUnivariateStatistic getSumImpl()
public void setSumImpl(StorelessUnivariateStatistic sumImpl) throws MathIllegalStateException
Sets the implementation for the Sum.
This method cannot be activated after data has been added  i.e.,
after addValue
has been used to add data.
If it is activated after data has been added, an IllegalStateException
will be thrown.
sumImpl
 the StorelessUnivariateStatistic instance to use for
computing the SumMathIllegalStateException
 if data has already been added (i.e if n >0)public StorelessUnivariateStatistic getSumsqImpl()
public void setSumsqImpl(StorelessUnivariateStatistic sumsqImpl) throws MathIllegalStateException
Sets the implementation for the sum of squares.
This method cannot be activated after data has been added  i.e.,
after addValue
has been used to add data.
If it is activated after data has been added, an IllegalStateException
will be thrown.
sumsqImpl
 the StorelessUnivariateStatistic instance to use for
computing the sum of squaresMathIllegalStateException
 if data has already been added (i.e if n > 0)public StorelessUnivariateStatistic getMinImpl()
public void setMinImpl(StorelessUnivariateStatistic minImpl) throws MathIllegalStateException
Sets the implementation for the minimum.
This method cannot be activated after data has been added  i.e.,
after addValue
has been used to add data.
If it is activated after data has been added, an IllegalStateException
will be thrown.
minImpl
 the StorelessUnivariateStatistic instance to use for
computing the minimumMathIllegalStateException
 if data has already been added (i.e if n > 0)public StorelessUnivariateStatistic getMaxImpl()
public void setMaxImpl(StorelessUnivariateStatistic maxImpl) throws MathIllegalStateException
Sets the implementation for the maximum.
This method cannot be activated after data has been added  i.e.,
after addValue
has been used to add data.
If it is activated after data has been added, an IllegalStateException
will be thrown.
maxImpl
 the StorelessUnivariateStatistic instance to use for
computing the maximumMathIllegalStateException
 if data has already been added (i.e if n > 0)public StorelessUnivariateStatistic getSumLogImpl()
public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl) throws MathIllegalStateException
Sets the implementation for the sum of logs.
This method cannot be activated after data has been added  i.e.,
after addValue
has been used to add data.
If it is activated after data has been added, an IllegalStateException
will be thrown.
sumLogImpl
 the StorelessUnivariateStatistic instance to use for
computing the log sumMathIllegalStateException
 if data has already been added (i.e if n > 0)public StorelessUnivariateStatistic getGeoMeanImpl()
public void setGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl) throws MathIllegalStateException
Sets the implementation for the geometric mean.
This method cannot be activated after data has been added  i.e.,
after addValue
has been used to add data.
If it is activated after data has been added, an IllegalStateException
will be thrown.
geoMeanImpl
 the StorelessUnivariateStatistic instance to use for
computing the geometric meanMathIllegalStateException
 if data has already been added (i.e if n > 0)public StorelessUnivariateStatistic getMeanImpl()
public void setMeanImpl(StorelessUnivariateStatistic meanImpl) throws MathIllegalStateException
Sets the implementation for the mean.
This method cannot be activated after data has been added  i.e.,
after addValue
has been used to add data.
If it is activated after data has been added, an IllegalStateException
will be thrown.
meanImpl
 the StorelessUnivariateStatistic instance to use for
computing the meanMathIllegalStateException
 if data has already been added (i.e if n > 0)public StorelessUnivariateStatistic getVarianceImpl()
public void setVarianceImpl(StorelessUnivariateStatistic varianceImpl) throws MathIllegalStateException
Sets the implementation for the variance.
This method cannot be activated after data has been added  i.e.,
after addValue
has been used to add data.
If it is activated after data has been added, an IllegalStateException
will be thrown.
varianceImpl
 the StorelessUnivariateStatistic instance to use for
computing the varianceMathIllegalStateException
 if data has already been added (i.e if n > 0)public SummaryStatistics copy()
public static void copy(SummaryStatistics source, SummaryStatistics dest) throws NullArgumentException
Neither source nor dest can be null.
source
 SummaryStatistics to copydest
 SummaryStatistics to copy toNullArgumentException
 if either source or dest is nullCopyright © 2003–2014 The Apache Software Foundation. All rights reserved.