|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.stat.descriptive.SummaryStatistics
public class SummaryStatistics
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, commons-math provided implementations.
Note: This class is not thread-safe. Use
SynchronizedSummaryStatistics
if concurrent access from multiple
threads is required.
Field Summary | |
---|---|
protected GeometricMean |
geoMean
geoMean of values that have been added |
private StorelessUnivariateStatistic |
geoMeanImpl
Geometric mean statistic implementation - can be reset by setter. |
protected Max |
max
max of values that have been added |
private StorelessUnivariateStatistic |
maxImpl
Maximum statistic implementation - can be reset by setter. |
protected Mean |
mean
mean of values that have been added |
private StorelessUnivariateStatistic |
meanImpl
Mean statistic implementation - can be reset by setter. |
protected Min |
min
min of values that have been added |
private StorelessUnivariateStatistic |
minImpl
Minimum statistic implementation - can be reset by setter. |
protected long |
n
count of values that have been added |
protected SecondMoment |
secondMoment
SecondMoment is used to compute the mean and variance |
private static long |
serialVersionUID
Serialization UID |
protected Sum |
sum
sum of values that have been added |
private StorelessUnivariateStatistic |
sumImpl
Sum statistic implementation - can be reset by setter. |
protected SumOfLogs |
sumLog
sumLog of values that have been added |
private StorelessUnivariateStatistic |
sumLogImpl
Sum of log statistic implementation - can be reset by setter. |
protected SumOfSquares |
sumsq
sum of the square of each value that has been added |
private StorelessUnivariateStatistic |
sumsqImpl
Sum of squares statistic implementation - can be reset by setter. |
protected Variance |
variance
variance of values that have been added |
private StorelessUnivariateStatistic |
varianceImpl
Variance statistic implementation - can be reset by setter. |
Constructor Summary | |
---|---|
SummaryStatistics()
Construct a SummaryStatistics instance |
Method Summary | |
---|---|
void |
addValue(double value)
Add a value to the data |
private void |
checkEmpty()
Throws IllegalStateException if n > 0. |
void |
clear()
Resets all statistics and storage |
boolean |
equals(java.lang.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 |
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 variance of the values that have been added. |
StorelessUnivariateStatistic |
getVarianceImpl()
Returns the currently configured variance implementation |
int |
hashCode()
Returns hash code based on values of statistics |
static SummaryStatistics |
newInstance()
Deprecated. to be removed in commons-math 2.0 |
static SummaryStatistics |
newInstance(java.lang.Class cls)
Deprecated. to be removed in commons-math 2.0 |
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. |
java.lang.String |
toString()
Generates a text report displaying summary statistics from values that have been added. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
protected long n
protected SecondMoment secondMoment
protected Sum sum
protected SumOfSquares sumsq
protected Min min
protected Max max
protected SumOfLogs sumLog
protected GeometricMean geoMean
protected Mean mean
protected Variance variance
private StorelessUnivariateStatistic sumImpl
private StorelessUnivariateStatistic sumsqImpl
private StorelessUnivariateStatistic minImpl
private StorelessUnivariateStatistic maxImpl
private StorelessUnivariateStatistic sumLogImpl
private StorelessUnivariateStatistic geoMeanImpl
private StorelessUnivariateStatistic meanImpl
private StorelessUnivariateStatistic varianceImpl
Constructor Detail |
---|
public SummaryStatistics()
Method Detail |
---|
public static SummaryStatistics newInstance(java.lang.Class cls) throws java.lang.InstantiationException, java.lang.IllegalAccessException
SummaryStatistics
cls
- the type of SummaryStatistics
object to
create.
java.lang.InstantiationException
- is thrown if the object can not be
created.
java.lang.IllegalAccessException
- is thrown if the type's default
constructor is not accessible.public static SummaryStatistics newInstance()
SummaryStatistics
public 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()
Double.NaN is returned if no values have been added.
getVariance
in interface StatisticalSummary
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 java.lang.String toString()
toString
in class java.lang.Object
public void clear()
public boolean equals(java.lang.Object object)
object
is a SummaryStatistics
instance and all statistics have the same values as this.
equals
in class java.lang.Object
object
- the object to test equality against.
public int hashCode()
hashCode
in class java.lang.Object
public StorelessUnivariateStatistic getSumImpl()
public void setSumImpl(StorelessUnivariateStatistic sumImpl)
Sets the implementation for the Sum.
This method must be activated before any data has been added - i.e.,
before addValue
has been used to add data;
otherwise an IllegalStateException will be thrown.
sumImpl
- the StorelessUnivariateStatistic instance to use
for computing the Sum
java.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic getSumsqImpl()
public void setSumsqImpl(StorelessUnivariateStatistic sumsqImpl)
Sets the implementation for the sum of squares.
This method must be activated before any data has been added - i.e.,
before addValue
has been used to add data;
otherwise an IllegalStateException will be thrown.
sumsqImpl
- the StorelessUnivariateStatistic instance to use
for computing the sum of squares
java.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic getMinImpl()
public void setMinImpl(StorelessUnivariateStatistic minImpl)
Sets the implementation for the minimum.
This method must be activated before any data has been added - i.e.,
before addValue
has been used to add data;
otherwise an IllegalStateException will be thrown.
minImpl
- the StorelessUnivariateStatistic instance to use
for computing the minimum
java.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic getMaxImpl()
public void setMaxImpl(StorelessUnivariateStatistic maxImpl)
Sets the implementation for the maximum.
This method must be activated before any data has been added - i.e.,
before addValue
has been used to add data;
otherwise an IllegalStateException will be thrown.
maxImpl
- the StorelessUnivariateStatistic instance to use
for computing the maximum
java.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic getSumLogImpl()
public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl)
Sets the implementation for the sum of logs.
This method must be activated before any data has been added - i.e.,
before addValue
has been used to add data;
otherwise an IllegalStateException will be thrown.
sumLogImpl
- the StorelessUnivariateStatistic instance to use
for computing the log sum
java.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic getGeoMeanImpl()
public void setGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl)
Sets the implementation for the geometric mean.
This method must be activated before any data has been added - i.e.,
before addValue
has been used to add data;
otherwise an IllegalStateException will be thrown.
geoMeanImpl
- the StorelessUnivariateStatistic instance to use
for computing the geometric mean
java.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic getMeanImpl()
public void setMeanImpl(StorelessUnivariateStatistic meanImpl)
Sets the implementation for the mean.
This method must be activated before any data has been added - i.e.,
before addValue
has been used to add data;
otherwise an IllegalStateException will be thrown.
meanImpl
- the StorelessUnivariateStatistic instance to use
for computing the mean
java.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic getVarianceImpl()
public void setVarianceImpl(StorelessUnivariateStatistic varianceImpl)
Sets the implementation for the variance.
This method must be activated before any data has been added - i.e.,
before addValue
has been used to add data;
otherwise an IllegalStateException will be thrown.
varianceImpl
- the StorelessUnivariateStatistic instance to use
for computing the variance
java.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)private void checkEmpty()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |