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 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.

To compute statistics for a stream of n-tuples, construct a MultivariateSummaryStatistics 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.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a MultivariateSummaryStatistics instance for the given dimension.
    MultivariateSummaryStatistics(int dimension, boolean covarianceBiasCorrection)
    Construct a MultivariateSummaryStatistics instance for the given dimension.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addValue(double[] value)
    Add an n-tuple to the data
    void
    Resets all statistics and storage.
    boolean
    equals(Object object)
    Returns true iff object is a MultivariateSummaryStatistics instance and all statistics have the same values as this.
    Returns the covariance of the available values.
    int
    Returns the dimension of the data
    double[]
    Returns an array whose ith entry is the geometric mean of the ith entries of the arrays that correspond to each multivariate sample
    double[]
    Returns an array whose ith entry is the maximum of the ith entries of the arrays that correspond to each multivariate sample
    double[]
    Returns an array whose ith entry is the mean of the ith entries of the arrays that correspond to each multivariate sample
    double[]
    Returns an array whose ith entry is the minimum of the ith entries of the arrays that correspond to each multivariate sample
    long
    Returns the number of available values
    double[]
    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[]
    Returns an array whose ith entry is the sum of the ith entries of the arrays that correspond to each multivariate sample
    double[]
    Returns an array whose ith entry is the sum of logs of the ith entries of the arrays that correspond to each multivariate sample
    double[]
    Returns an array whose ith entry is the sum of squares of the ith entries of the arrays that correspond to each multivariate sample
    int
    Returns hash code based on values of statistics
    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
  • Constructor Details

    • 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 data
      covarianceBiasCorrection - if true, the returned instance will compute the unbiased sample covariance, otherwise the population covariance
  • Method Details

    • 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 interface StatisticalMultivariateSummary
      Returns:
      The dimension of the data
    • getN

      public long getN()
      Returns the number of available values
      Specified by:
      getN in interface StatisticalMultivariateSummary
      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 interface StatisticalMultivariateSummary
      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 interface StatisticalMultivariateSummary
      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 interface StatisticalMultivariateSummary
      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 interface StatisticalMultivariateSummary
      Returns:
      the array of component means
    • getCovariance

      public RealMatrix getCovariance()
      Returns the covariance of the available values.
      Specified by:
      getCovariance in interface StatisticalMultivariateSummary
      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 interface StatisticalMultivariateSummary
      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 interface StatisticalMultivariateSummary
      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 interface StatisticalMultivariateSummary
      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 using addValue(double[])
      Specified by:
      getStandardDeviation in interface StatisticalMultivariateSummary
      Returns:
      the array of component standard deviations
    • toString

      public String toString()
      Generates a text report displaying summary statistics from values that have been added.
      Overrides:
      toString in class Object
      Returns:
      String with line feeds displaying statistics
    • equals

      public boolean equals(Object object)
      Returns true iff object is a MultivariateSummaryStatistics instance and all statistics have the same values as this.
      Overrides:
      equals in class Object
      Parameters:
      object - the object to test equality against.
      Returns:
      true if object equals this
    • hashCode

      public int hashCode()
      Returns hash code based on values of statistics
      Overrides:
      hashCode in class Object
      Returns:
      hash code