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 theaddValuemethod. 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
MultivariateSummaryStatisticsinstance with dimension n and then useaddValue(double[])to add n-tuples. ThegetXxxmethods where Xxx is a statistic return an array ofdoublevalues, where fori = 0,...,n-1the 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, ifaddValueis called with actual parameters {0, 1, 2}, then {3, 4, 5} and finally {6, 7, 8},getSumwill 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 voidaddValue(double[] value)Add an n-tuple to the datavoidclear()Resets all statistics and storage.booleanequals(Object object)Returns true iffobjectis aMultivariateSummaryStatisticsinstance and all statistics have the same values as this.RealMatrixgetCovariance()Returns the covariance of the available values.intgetDimension()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 samplelonggetN()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 sampleinthashCode()Returns hash code based on values of statisticsStringtoString()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 MathIllegalArgumentExceptionAdd 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:
getDimensionin interfaceStatisticalMultivariateSummary- Returns:
- The dimension of the data
-
getN
public long getN()
Returns the number of available values- Specified by:
getNin 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:
getSumin 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:
getSumSqin 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:
getSumLogin 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:
getMeanin interfaceStatisticalMultivariateSummary- Returns:
- the array of component means
-
getCovariance
public RealMatrix getCovariance()
Returns the covariance of the available values.- Specified by:
getCovariancein 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:
getMaxin 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:
getMinin 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:
getGeometricMeanin 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:
getStandardDeviationin 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 iffobjectis aMultivariateSummaryStatisticsinstance and all statistics have the same values as this.
-
-