public class MultivariateSummaryStatistics extends java.lang.Object implements StatisticalMultivariateSummary, java.io.Serializable
Computes summary statistics for a stream of n-tuples 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
n-tuple streams.
The 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 setMeanImpl(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.
To compute statistics for a stream of n-tuples, construct a
MultivariateStatistics instance with dimension n and then use
addValue(double[])
to add n-tuples. The getXxx
methods where Xxx is a statistic return an array of double
values, where for i = 0,...,n-1
the ith array element is the
value of the given statistic for data range consisting of the ith element of
each of the input n-tuples. For example, if addValue
is called
with actual parameters {0, 1, 2}, then {3, 4, 5} and finally {6, 7, 8},
getSum
will return a three-element array with values
{0+3+6, 1+4+7, 2+5+8}
Note: This class is not thread-safe. Use
SynchronizedMultivariateSummaryStatistics
if concurrent access from multiple
threads is required.
Constructor and Description |
---|
MultivariateSummaryStatistics(int k,
boolean isCovarianceBiasCorrected)
Construct a MultivariateSummaryStatistics instance
|
Modifier and Type | Method and Description |
---|---|
void |
addValue(double[] value)
Add an n-tuple to the data
|
void |
clear()
Resets all statistics and storage
|
boolean |
equals(java.lang.Object object)
Returns true iff
object is a MultivariateSummaryStatistics
instance and all statistics have the same values as this. |
RealMatrix |
getCovariance()
Returns the covariance matrix of the values that have been added.
|
int |
getDimension()
Returns the dimension of the data
|
StorelessUnivariateStatistic[] |
getGeoMeanImpl()
Returns the currently configured geometric mean implementation
|
double[] |
getGeometricMean()
Returns an array whose ith entry is the geometric mean of the
ith entries of the arrays that have been added using
addValue(double[]) |
double[] |
getMax()
Returns an array whose ith entry is the maximum of the
ith entries of the arrays that have been added using
addValue(double[]) |
StorelessUnivariateStatistic[] |
getMaxImpl()
Returns the currently configured maximum implementation
|
double[] |
getMean()
Returns an array whose ith entry is the mean of the
ith entries of the arrays that have been added using
addValue(double[]) |
StorelessUnivariateStatistic[] |
getMeanImpl()
Returns the currently configured mean implementation
|
double[] |
getMin()
Returns an array whose ith entry is the minimum of the
ith entries of the arrays that have been added using
addValue(double[]) |
StorelessUnivariateStatistic[] |
getMinImpl()
Returns the currently configured minimum implementation
|
long |
getN()
Returns the number of available values
|
double[] |
getStandardDeviation()
Returns an array whose ith entry is the standard deviation of the
ith entries of the arrays that have been added using
addValue(double[]) |
double[] |
getSum()
Returns an array whose ith entry is the sum of the
ith entries of the arrays that have been added using
addValue(double[]) |
StorelessUnivariateStatistic[] |
getSumImpl()
Returns the currently configured Sum implementation
|
double[] |
getSumLog()
Returns an array whose ith entry is the sum of logs of the
ith entries of the arrays that have been added using
addValue(double[]) |
StorelessUnivariateStatistic[] |
getSumLogImpl()
Returns the currently configured sum of logs implementation
|
double[] |
getSumSq()
Returns an array whose ith entry is the sum of squares of the
ith entries of the arrays that have been added using
addValue(double[]) |
StorelessUnivariateStatistic[] |
getSumsqImpl()
Returns the currently configured sum of squares 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.
|
java.lang.String |
toString()
Generates a text report displaying
summary statistics from values that
have been added.
|
public MultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected)
k
- dimension of the dataisCovarianceBiasCorrected
- if true, the unbiased sample
covariance is computed, otherwise the biased population covariance
is computedpublic void addValue(double[] value) throws DimensionMismatchException
value
- the n-tuple to addDimensionMismatchException
- if the length of the array
does not match the one used at constructionpublic int getDimension()
getDimension
in interface StatisticalMultivariateSummary
public long getN()
getN
in interface StatisticalMultivariateSummary
public double[] getSum()
addValue(double[])
getSum
in interface StatisticalMultivariateSummary
public double[] getSumSq()
addValue(double[])
getSumSq
in interface StatisticalMultivariateSummary
public double[] getSumLog()
addValue(double[])
getSumLog
in interface StatisticalMultivariateSummary
public double[] getMean()
addValue(double[])
getMean
in interface StatisticalMultivariateSummary
public double[] getStandardDeviation()
addValue(double[])
getStandardDeviation
in interface StatisticalMultivariateSummary
public RealMatrix getCovariance()
getCovariance
in interface StatisticalMultivariateSummary
public double[] getMax()
addValue(double[])
getMax
in interface StatisticalMultivariateSummary
public double[] getMin()
addValue(double[])
getMin
in interface StatisticalMultivariateSummary
public double[] getGeometricMean()
addValue(double[])
getGeometricMean
in interface StatisticalMultivariateSummary
public java.lang.String toString()
toString
in class java.lang.Object
public void clear()
public boolean equals(java.lang.Object object)
object
is a MultivariateSummaryStatistics
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) throws DimensionMismatchException
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 SumDimensionMismatchException
- if the array dimension
does not match the one used at constructionjava.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic[] getSumsqImpl()
public void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl) throws DimensionMismatchException
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 squaresDimensionMismatchException
- if the array dimension
does not match the one used at constructionjava.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic[] getMinImpl()
public void setMinImpl(StorelessUnivariateStatistic[] minImpl) throws DimensionMismatchException
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 minimumDimensionMismatchException
- if the array dimension
does not match the one used at constructionjava.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic[] getMaxImpl()
public void setMaxImpl(StorelessUnivariateStatistic[] maxImpl) throws DimensionMismatchException
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 maximumDimensionMismatchException
- if the array dimension
does not match the one used at constructionjava.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic[] getSumLogImpl()
public void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl) throws DimensionMismatchException
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 sumDimensionMismatchException
- if the array dimension
does not match the one used at constructionjava.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic[] getGeoMeanImpl()
public void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl) throws DimensionMismatchException
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 meanDimensionMismatchException
- if the array dimension
does not match the one used at constructionjava.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)public StorelessUnivariateStatistic[] getMeanImpl()
public void setMeanImpl(StorelessUnivariateStatistic[] meanImpl) throws DimensionMismatchException
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 meanDimensionMismatchException
- if the array dimension
does not match the one used at constructionjava.lang.IllegalStateException
- if data has already been added
(i.e if n > 0)Copyright © 2010 - 2020 Adobe. All Rights Reserved