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.
| Modifier and Type | Field and Description |
|---|---|
| private VectorialCovariance | covarianceImpl
Covariance statistic implementation - cannot be reset. |
| private StorelessUnivariateStatistic[] | geoMeanImpl
Geometric mean statistic implementation - can be reset by setter. |
| private int | k
Dimension of the data. |
| private StorelessUnivariateStatistic[] | maxImpl
Maximum statistic implementation - can be reset by setter. |
| private StorelessUnivariateStatistic[] | meanImpl
Mean statistic implementation - can be reset by setter. |
| private StorelessUnivariateStatistic[] | minImpl
Minimum statistic implementation - can be reset by setter. |
| private long | n
Count of values that have been added |
| private static final long | serialVersionUID
Serialization UID |
| private StorelessUnivariateStatistic[] | sumImpl
Sum statistic implementation - can be reset by setter. |
| private StorelessUnivariateStatistic[] | sumLogImpl
Sum of log statistic implementation - can be reset by setter. |
| private StorelessUnivariateStatistic[] | sumSqImpl
Sum of squares statistic implementation - can be reset by setter. |
| Access | Constructor and Description |
|---|---|
| public | MultivariateSummaryStatistics(int
dimension of the data k, boolean if true, the unbiased sample
covariance is computed, otherwise the biased population covariance
is computed isCovarianceBiasCorrected)Construct a MultivariateSummaryStatistics instance |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| private void | append(StringBuilder
buffer to fill buffer, double[] data array data, String text prefix prefix, String elements separator separator, String text suffix suffix)Append a text representation of an array to a buffer. |
| private void | |
| private void | |
| public void | |
| public boolean | Returns: true if object equals thisthe object to test equality against. object)Overrides java. Returns true iff |
| public RealMatrix | Returns: the covariance matrixImplements org. Returns the covariance matrix of the values that have been added. |
| public int | Returns: The dimension of the dataImplements org. Returns the dimension of the data |
| public StorelessUnivariateStatistic[] | Returns: the StorelessUnivariateStatistic implementing the geometric meanReturns the currently configured geometric mean implementation |
| public double[] | Returns: the array of component geometric meansImplements org. Returns an array whose ith entry is the geometric mean of the
ith entries of the arrays that have been added using
|
| public double[] | Returns: the array of component maximaImplements org. Returns an array whose ith entry is the maximum of the
ith entries of the arrays that have been added using
|
| public StorelessUnivariateStatistic[] | Returns: the StorelessUnivariateStatistic implementing the maximumReturns the currently configured maximum implementation |
| public double[] | Returns: the array of component meansImplements org. Returns an array whose ith entry is the mean of the
ith entries of the arrays that have been added using
|
| public StorelessUnivariateStatistic[] | Returns: the StorelessUnivariateStatistic implementing the meanReturns the currently configured mean implementation |
| public double[] | Returns: the array of component minimaImplements org. Returns an array whose ith entry is the minimum of the
ith entries of the arrays that have been added using
|
| public StorelessUnivariateStatistic[] | Returns: the StorelessUnivariateStatistic implementing the minimumReturns the currently configured minimum implementation |
| public long | Returns: The number of available valuesImplements org. Returns the number of available values |
| private double[] | Returns: results arrayunivariate statistic array stats)Returns an array of the results of a statistic. |
| public double[] | Returns: the array of component standard deviationsImplements org. Returns an array whose ith entry is the standard deviation of the
ith entries of the arrays that have been added using
|
| public double[] | Returns: the array of component sumsImplements org. Returns an array whose ith entry is the sum of the
ith entries of the arrays that have been added using
|
| public StorelessUnivariateStatistic[] | Returns: the StorelessUnivariateStatistic implementing the sumReturns the currently configured Sum implementation |
| public double[] | Returns: the array of component log sumsImplements org. Returns an array whose ith entry is the sum of logs of the
ith entries of the arrays that have been added using
|
| public StorelessUnivariateStatistic[] | Returns: the StorelessUnivariateStatistic implementing the log sumReturns the currently configured sum of logs implementation |
| public double[] | Returns: the array of component sums of squaresImplements org. Returns an array whose ith entry is the sum of squares of the
ith entries of the arrays that have been added using
|
| public StorelessUnivariateStatistic[] | Returns: the StorelessUnivariateStatistic implementing the sum of squaresReturns the currently configured sum of squares implementation |
| public int | Returns: hash codeOverrides java. Returns hash code based on values of statistics |
| public void | setGeoMeanImpl(StorelessUnivariateStatistic[]
the StorelessUnivariateStatistic instance to use
for computing the geometric mean geoMeanImpl)Sets the implementation for the geometric mean. |
| private void | setImpl(StorelessUnivariateStatistic[]
new implementations for statistics newImpl, StorelessUnivariateStatistic[] old implementations for statistics oldImpl)Sets statistics implementations. |
| public void | setMaxImpl(StorelessUnivariateStatistic[]
the StorelessUnivariateStatistic instance to use
for computing the maximum maxImpl)Sets the implementation for the maximum. |
| public void | setMeanImpl(StorelessUnivariateStatistic[]
the StorelessUnivariateStatistic instance to use
for computing the mean meanImpl)Sets the implementation for the mean. |
| public void | setMinImpl(StorelessUnivariateStatistic[]
the StorelessUnivariateStatistic instance to use
for computing the minimum minImpl)Sets the implementation for the minimum. |
| public void | setSumImpl(StorelessUnivariateStatistic[]
the StorelessUnivariateStatistic instance to use
for computing the Sum sumImpl)Sets the implementation for the Sum. |
| public void | setSumLogImpl(StorelessUnivariateStatistic[]
the StorelessUnivariateStatistic instance to use
for computing the log sum sumLogImpl)Sets the implementation for the sum of logs. |
| public void | setSumsqImpl(StorelessUnivariateStatistic[]
the StorelessUnivariateStatistic instance to use
for computing the sum of squares sumsqImpl)Sets the implementation for the sum of squares. |
| public String | Returns: String with line feeds displaying statisticsOverrides java. Generates a text report displaying summary statistics from values that have been added. |
| covarianceImpl | back to summary |
|---|---|
| private VectorialCovariance covarianceImpl Covariance statistic implementation - cannot be reset. | |
| geoMeanImpl | back to summary |
|---|---|
| private StorelessUnivariateStatistic[] geoMeanImpl Geometric mean statistic implementation - can be reset by setter. | |
| k | back to summary |
|---|---|
| private int k Dimension of the data. | |
| maxImpl | back to summary |
|---|---|
| private StorelessUnivariateStatistic[] maxImpl Maximum statistic implementation - can be reset by setter. | |
| meanImpl | back to summary |
|---|---|
| private StorelessUnivariateStatistic[] meanImpl Mean statistic implementation - can be reset by setter. | |
| minImpl | back to summary |
|---|---|
| private StorelessUnivariateStatistic[] minImpl Minimum statistic implementation - can be reset by setter. | |
| n | back to summary |
|---|---|
| private long n Count of values that have been added | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization UID | |
| sumImpl | back to summary |
|---|---|
| private StorelessUnivariateStatistic[] sumImpl Sum statistic implementation - can be reset by setter. | |
| sumLogImpl | back to summary |
|---|---|
| private StorelessUnivariateStatistic[] sumLogImpl Sum of log statistic implementation - can be reset by setter. | |
| sumSqImpl | back to summary |
|---|---|
| private StorelessUnivariateStatistic[] sumSqImpl Sum of squares statistic implementation - can be reset by setter. | |
| MultivariateSummaryStatistics | back to summary |
|---|---|
| public MultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) Construct a MultivariateSummaryStatistics instance
| |
| addValue | back to summary |
|---|---|
| public void addValue(double[] value) throws DimensionMismatchException Add an n-tuple to the data
| |
| append | back to summary |
|---|---|
| private void append(StringBuilder buffer, double[] data, String prefix, String separator, String suffix) Append a text representation of an array to a buffer.
| |
| checkDimension | back to summary |
|---|---|
| private void checkDimension(int dimension) throws DimensionMismatchException Throws DimensionMismatchException if dimension != k.
| |
| checkEmpty | back to summary |
|---|---|
| private void checkEmpty() throws MathIllegalStateException Throws MathIllegalStateException if the statistic is not empty.
| |
| clear | back to summary |
|---|---|
| public void clear() Resets all statistics and storage | |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Overrides java. Returns true iff | |
| getCovariance | back to summary |
|---|---|
| public RealMatrix getCovariance() Implements org. Returns the covariance matrix of the values that have been added.
| |
| getDimension | back to summary |
|---|---|
| public int getDimension() Implements org. Returns the dimension of the data
| |
| getGeoMeanImpl | back to summary |
|---|---|
| public StorelessUnivariateStatistic[] getGeoMeanImpl() Returns the currently configured geometric mean implementation
| |
| getGeometricMean | back to summary |
|---|---|
| public double[] getGeometricMean() Implements org. Returns an array whose ith entry is the geometric mean of the
ith entries of the arrays that have been added using
| |
| getMax | back to summary |
|---|---|
| public double[] getMax() Implements org. Returns an array whose ith entry is the maximum of the
ith entries of the arrays that have been added using
| |
| getMaxImpl | back to summary |
|---|---|
| public StorelessUnivariateStatistic[] getMaxImpl() Returns the currently configured maximum implementation
| |
| getMean | back to summary |
|---|---|
| public double[] getMean() Implements org. Returns an array whose ith entry is the mean of the
ith entries of the arrays that have been added using
| |
| getMeanImpl | back to summary |
|---|---|
| public StorelessUnivariateStatistic[] getMeanImpl() Returns the currently configured mean implementation
| |
| getMin | back to summary |
|---|---|
| public double[] getMin() Implements org. Returns an array whose ith entry is the minimum of the
ith entries of the arrays that have been added using
| |
| getMinImpl | back to summary |
|---|---|
| public StorelessUnivariateStatistic[] getMinImpl() Returns the currently configured minimum implementation
| |
| getN | back to summary |
|---|---|
| public long getN() Implements org. Returns the number of available values
| |
| getResults | back to summary |
|---|---|
| private double[] getResults(StorelessUnivariateStatistic[] stats) Returns an array of the results of a statistic.
| |
| getStandardDeviation | back to summary |
|---|---|
| public double[] getStandardDeviation() Implements org. Returns an array whose ith entry is the standard deviation of the
ith entries of the arrays that have been added using
| |
| getSum | back to summary |
|---|---|
| public double[] getSum() Implements org. Returns an array whose ith entry is the sum of the
ith entries of the arrays that have been added using
| |
| getSumImpl | back to summary |
|---|---|
| public StorelessUnivariateStatistic[] getSumImpl() Returns the currently configured Sum implementation
| |
| getSumLog | back to summary |
|---|---|
| public double[] getSumLog() Implements org. Returns an array whose ith entry is the sum of logs of the
ith entries of the arrays that have been added using
| |
| getSumLogImpl | back to summary |
|---|---|
| public StorelessUnivariateStatistic[] getSumLogImpl() Returns the currently configured sum of logs implementation
| |
| getSumSq | back to summary |
|---|---|
| public double[] getSumSq() Implements org. Returns an array whose ith entry is the sum of squares of the
ith entries of the arrays that have been added using
| |
| getSumsqImpl | back to summary |
|---|---|
| public StorelessUnivariateStatistic[] getSumsqImpl() Returns the currently configured sum of squares implementation
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns hash code based on values of statistics
| |
| setGeoMeanImpl | back to summary |
|---|---|
| public void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl) throws MathIllegalStateException, DimensionMismatchException Sets the implementation for the geometric mean. This method must be activated before any data has been added - i.e.,
before
| |
| setImpl | back to summary |
|---|---|
| private void setImpl(StorelessUnivariateStatistic[] newImpl, StorelessUnivariateStatistic[] oldImpl) throws MathIllegalStateException, DimensionMismatchException Sets statistics implementations.
| |
| setMaxImpl | back to summary |
|---|---|
| public void setMaxImpl(StorelessUnivariateStatistic[] maxImpl) throws MathIllegalStateException, DimensionMismatchException Sets the implementation for the maximum. This method must be activated before any data has been added - i.e.,
before
| |
| setMeanImpl | back to summary |
|---|---|
| public void setMeanImpl(StorelessUnivariateStatistic[] meanImpl) throws MathIllegalStateException, DimensionMismatchException Sets the implementation for the mean. This method must be activated before any data has been added - i.e.,
before
| |
| setMinImpl | back to summary |
|---|---|
| public void setMinImpl(StorelessUnivariateStatistic[] minImpl) throws MathIllegalStateException, DimensionMismatchException Sets the implementation for the minimum. This method must be activated before any data has been added - i.e.,
before
| |
| setSumImpl | back to summary |
|---|---|
| public void setSumImpl(StorelessUnivariateStatistic[] sumImpl) throws MathIllegalStateException, DimensionMismatchException Sets the implementation for the Sum. This method must be activated before any data has been added - i.e.,
before
| |
| setSumLogImpl | back to summary |
|---|---|
| public void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl) throws MathIllegalStateException, DimensionMismatchException Sets the implementation for the sum of logs. This method must be activated before any data has been added - i.e.,
before
| |
| setSumsqImpl | back to summary |
|---|---|
| public void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl) throws MathIllegalStateException, DimensionMismatchException Sets the implementation for the sum of squares. This method must be activated before any data has been added - i.e.,
before
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Generates a text report displaying summary statistics from values that have been added. | |