Package org.hipparchus.stat.descriptive
Class MultivariateSummaryStatistics
- java.lang.Object
-
- org.hipparchus.stat.descriptive.MultivariateSummaryStatistics
-
- All Implemented Interfaces:
Serializable
,StatisticalMultivariateSummary
public class MultivariateSummaryStatistics extends Object implements StatisticalMultivariateSummary, Serializable
Computes summary statistics for a stream of n-tuples added using theaddValue
method. The data values are not stored in memory, so this class can be used to compute statistics for very large n-tuple streams.To compute statistics for a stream of n-tuples, construct a
MultivariateSummaryStatistics
instance with dimension n and then useaddValue(double[])
to add n-tuples. ThegetXxx
methods where Xxx is a statistic return an array ofdouble
values, where fori = 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, ifaddValue
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.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MultivariateSummaryStatistics(int dimension)
Construct a MultivariateSummaryStatistics instance for the given dimension.MultivariateSummaryStatistics(int dimension, boolean covarianceBiasCorrection)
Construct a MultivariateSummaryStatistics instance for the given dimension.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addValue(double[] value)
Add an n-tuple to the datavoid
clear()
Resets all statistics and storage.boolean
equals(Object object)
Returns true iffobject
is aMultivariateSummaryStatistics
instance and all statistics have the same values as this.RealMatrix
getCovariance()
Returns the covariance of the available values.int
getDimension()
Returns the dimension of the datadouble[]
getGeometricMean()
Returns an array whose ith entry is the geometric mean of the ith entries of the arrays that correspond to each multivariate sampledouble[]
getMax()
Returns an array whose ith entry is the maximum of the ith entries of the arrays that correspond to each multivariate sampledouble[]
getMean()
Returns an array whose ith entry is the mean of the ith entries of the arrays that correspond to each multivariate sampledouble[]
getMin()
Returns an array whose ith entry is the minimum of the ith entries of the arrays that correspond to each multivariate samplelong
getN()
Returns the number of available valuesdouble[]
getStandardDeviation()
Returns an array whose ith entry is the standard deviation of the ith entries of the arrays that have been added usingaddValue(double[])
double[]
getSum()
Returns an array whose ith entry is the sum of the ith entries of the arrays that correspond to each multivariate sampledouble[]
getSumLog()
Returns an array whose ith entry is the sum of logs of the ith entries of the arrays that correspond to each multivariate sampledouble[]
getSumSq()
Returns an array whose ith entry is the sum of squares of the ith entries of the arrays that correspond to each multivariate sampleint
hashCode()
Returns hash code based on values of statisticsString
toString()
Generates a text report displaying summary statistics from values that have been added.
-
-
-
Constructor Detail
-
MultivariateSummaryStatistics
public MultivariateSummaryStatistics(int dimension)
Construct a MultivariateSummaryStatistics instance for the given dimension. The returned instance will compute the unbiased sample covariance.The returned instance is not thread-safe.
- Parameters:
dimension
- dimension of the data
-
MultivariateSummaryStatistics
public MultivariateSummaryStatistics(int dimension, boolean covarianceBiasCorrection)
Construct a MultivariateSummaryStatistics instance for the given dimension.The returned instance is not thread-safe.
- Parameters:
dimension
- dimension of the datacovarianceBiasCorrection
- if true, the returned instance will compute the unbiased sample covariance, otherwise the population covariance
-
-
Method Detail
-
addValue
public void addValue(double[] value) throws MathIllegalArgumentException
Add an n-tuple to the data- Parameters:
value
- the n-tuple to add- Throws:
MathIllegalArgumentException
- if the array is null or the length of the array does not match the one used at construction
-
clear
public void clear()
Resets all statistics and storage.
-
getDimension
public int getDimension()
Returns the dimension of the data- Specified by:
getDimension
in interfaceStatisticalMultivariateSummary
- Returns:
- The dimension of the data
-
getN
public long getN()
Returns the number of available values- Specified by:
getN
in interfaceStatisticalMultivariateSummary
- Returns:
- The number of available values
-
getSum
public double[] getSum()
Returns an array whose ith entry is the sum of the ith entries of the arrays that correspond to each multivariate sample- Specified by:
getSum
in interfaceStatisticalMultivariateSummary
- Returns:
- the array of component sums
-
getSumSq
public double[] getSumSq()
Returns an array whose ith entry is the sum of squares of the ith entries of the arrays that correspond to each multivariate sample- Specified by:
getSumSq
in interfaceStatisticalMultivariateSummary
- Returns:
- the array of component sums of squares
-
getSumLog
public double[] getSumLog()
Returns an array whose ith entry is the sum of logs of the ith entries of the arrays that correspond to each multivariate sample- Specified by:
getSumLog
in interfaceStatisticalMultivariateSummary
- Returns:
- the array of component log sums
-
getMean
public double[] getMean()
Returns an array whose ith entry is the mean of the ith entries of the arrays that correspond to each multivariate sample- Specified by:
getMean
in interfaceStatisticalMultivariateSummary
- Returns:
- the array of component means
-
getCovariance
public RealMatrix getCovariance()
Returns the covariance of the available values.- Specified by:
getCovariance
in interfaceStatisticalMultivariateSummary
- Returns:
- The covariance, null if no multivariate sample have been added or a zeroed matrix for a single value set.
-
getMax
public double[] getMax()
Returns an array whose ith entry is the maximum of the ith entries of the arrays that correspond to each multivariate sample- Specified by:
getMax
in interfaceStatisticalMultivariateSummary
- Returns:
- the array of component maxima
-
getMin
public double[] getMin()
Returns an array whose ith entry is the minimum of the ith entries of the arrays that correspond to each multivariate sample- Specified by:
getMin
in interfaceStatisticalMultivariateSummary
- Returns:
- the array of component minima
-
getGeometricMean
public double[] getGeometricMean()
Returns an array whose ith entry is the geometric mean of the ith entries of the arrays that correspond to each multivariate sample- Specified by:
getGeometricMean
in interfaceStatisticalMultivariateSummary
- Returns:
- the array of component geometric means
-
getStandardDeviation
public double[] getStandardDeviation()
Returns an array whose ith entry is the standard deviation of the ith entries of the arrays that have been added usingaddValue(double[])
- Specified by:
getStandardDeviation
in interfaceStatisticalMultivariateSummary
- Returns:
- the array of component standard deviations
-
toString
public String toString()
Generates a text report displaying summary statistics from values that have been added.
-
equals
public boolean equals(Object object)
Returns true iffobject
is aMultivariateSummaryStatistics
instance and all statistics have the same values as this.
-
-