Class SynchronizedMultivariateSummaryStatistics
- All Implemented Interfaces:
Serializable
,StatisticalMultivariateSummary
MultivariateSummaryStatistics
that
is safe to use in a multithreaded environment. Multiple threads can safely
operate on a single instance without causing runtime exceptions due to race
conditions. In effect, this implementation makes modification and access
methods atomic operations for a single instance. That is to say, as one
thread is computing a statistic from the instance, no other thread can modify
the instance nor compute another statistic.- Since:
- 1.2
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSynchronizedMultivariateSummaryStatistics
(int k, boolean isCovarianceBiasCorrected) Construct a SynchronizedMultivariateSummaryStatistics instance -
Method Summary
Modifier and TypeMethodDescriptionvoid
addValue
(double[] value) Add an n-tuple to the datavoid
clear()
Resets all statistics and storageboolean
Returns true iffobject
is aMultivariateSummaryStatistics
instance and all statistics have the same values as this.Returns the covariance matrix of the values that have been added.int
Returns the dimension of the dataReturns the currently configured geometric mean implementationdouble[]
Returns an array whose ith entry is the geometric mean of the ith entries of the arrays that have been added usingMultivariateSummaryStatistics.addValue(double[])
double[]
getMax()
Returns an array whose ith entry is the maximum of the ith entries of the arrays that have been added usingMultivariateSummaryStatistics.addValue(double[])
Returns the currently configured maximum implementationdouble[]
getMean()
Returns an array whose ith entry is the mean of the ith entries of the arrays that have been added usingMultivariateSummaryStatistics.addValue(double[])
Returns the currently configured mean implementationdouble[]
getMin()
Returns an array whose ith entry is the minimum of the ith entries of the arrays that have been added usingMultivariateSummaryStatistics.addValue(double[])
Returns the currently configured minimum implementationlong
getN()
Returns the number of available valuesdouble[]
Returns an array whose ith entry is the standard deviation of the ith entries of the arrays that have been added usingMultivariateSummaryStatistics.addValue(double[])
double[]
getSum()
Returns an array whose ith entry is the sum of the ith entries of the arrays that have been added usingMultivariateSummaryStatistics.addValue(double[])
Returns the currently configured Sum implementationdouble[]
Returns an array whose ith entry is the sum of logs of the ith entries of the arrays that have been added usingMultivariateSummaryStatistics.addValue(double[])
Returns the currently configured sum of logs implementationdouble[]
getSumSq()
Returns an array whose ith entry is the sum of squares of the ith entries of the arrays that have been added usingMultivariateSummaryStatistics.addValue(double[])
Returns the currently configured sum of squares implementationint
hashCode()
Returns hash code based on values of statisticsvoid
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.toString()
Generates a text report displaying summary statistics from values that have been added.
-
Constructor Details
-
SynchronizedMultivariateSummaryStatistics
public SynchronizedMultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) Construct a SynchronizedMultivariateSummaryStatistics instance- Parameters:
k
- dimension of the dataisCovarianceBiasCorrected
- if true, the unbiased sample covariance is computed, otherwise the biased population covariance is computed
-
-
Method Details
-
addValue
Add an n-tuple to the data- Overrides:
addValue
in classMultivariateSummaryStatistics
- Parameters:
value
- the n-tuple to add- Throws:
DimensionMismatchException
- if the length of the array does not match the one used at construction
-
getDimension
public int getDimension()Returns the dimension of the data- Specified by:
getDimension
in interfaceStatisticalMultivariateSummary
- Overrides:
getDimension
in classMultivariateSummaryStatistics
- Returns:
- The dimension of the data
-
getN
public long getN()Returns the number of available values- Specified by:
getN
in interfaceStatisticalMultivariateSummary
- Overrides:
getN
in classMultivariateSummaryStatistics
- 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 have been added usingMultivariateSummaryStatistics.addValue(double[])
- Specified by:
getSum
in interfaceStatisticalMultivariateSummary
- Overrides:
getSum
in classMultivariateSummaryStatistics
- 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 have been added usingMultivariateSummaryStatistics.addValue(double[])
- Specified by:
getSumSq
in interfaceStatisticalMultivariateSummary
- Overrides:
getSumSq
in classMultivariateSummaryStatistics
- 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 have been added usingMultivariateSummaryStatistics.addValue(double[])
- Specified by:
getSumLog
in interfaceStatisticalMultivariateSummary
- Overrides:
getSumLog
in classMultivariateSummaryStatistics
- 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 have been added usingMultivariateSummaryStatistics.addValue(double[])
- Specified by:
getMean
in interfaceStatisticalMultivariateSummary
- Overrides:
getMean
in classMultivariateSummaryStatistics
- Returns:
- the array of component 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 usingMultivariateSummaryStatistics.addValue(double[])
- Specified by:
getStandardDeviation
in interfaceStatisticalMultivariateSummary
- Overrides:
getStandardDeviation
in classMultivariateSummaryStatistics
- Returns:
- the array of component standard deviations
-
getCovariance
Returns the covariance matrix of the values that have been added.- Specified by:
getCovariance
in interfaceStatisticalMultivariateSummary
- Overrides:
getCovariance
in classMultivariateSummaryStatistics
- Returns:
- the covariance matrix
-
getMax
public double[] getMax()Returns an array whose ith entry is the maximum of the ith entries of the arrays that have been added usingMultivariateSummaryStatistics.addValue(double[])
- Specified by:
getMax
in interfaceStatisticalMultivariateSummary
- Overrides:
getMax
in classMultivariateSummaryStatistics
- 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 have been added usingMultivariateSummaryStatistics.addValue(double[])
- Specified by:
getMin
in interfaceStatisticalMultivariateSummary
- Overrides:
getMin
in classMultivariateSummaryStatistics
- 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 have been added usingMultivariateSummaryStatistics.addValue(double[])
- Specified by:
getGeometricMean
in interfaceStatisticalMultivariateSummary
- Overrides:
getGeometricMean
in classMultivariateSummaryStatistics
- Returns:
- the array of component geometric means
-
toString
Generates a text report displaying summary statistics from values that have been added.- Overrides:
toString
in classMultivariateSummaryStatistics
- Returns:
- String with line feeds displaying statistics
-
clear
public void clear()Resets all statistics and storage- Overrides:
clear
in classMultivariateSummaryStatistics
-
equals
Returns true iffobject
is aMultivariateSummaryStatistics
instance and all statistics have the same values as this.- Overrides:
equals
in classMultivariateSummaryStatistics
- 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 classMultivariateSummaryStatistics
- Returns:
- hash code
-
getSumImpl
Returns the currently configured Sum implementation- Overrides:
getSumImpl
in classMultivariateSummaryStatistics
- Returns:
- the StorelessUnivariateStatistic implementing the sum
-
setSumImpl
public void setSumImpl(StorelessUnivariateStatistic[] sumImpl) throws DimensionMismatchException, MathIllegalStateException 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.- Overrides:
setSumImpl
in classMultivariateSummaryStatistics
- Parameters:
sumImpl
- the StorelessUnivariateStatistic instance to use for computing the Sum- Throws:
DimensionMismatchException
- if the array dimension does not match the one used at constructionMathIllegalStateException
- if data has already been added (i.e if n > 0)
-
getSumsqImpl
Returns the currently configured sum of squares implementation- Overrides:
getSumsqImpl
in classMultivariateSummaryStatistics
- Returns:
- the StorelessUnivariateStatistic implementing the sum of squares
-
setSumsqImpl
public void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl) throws DimensionMismatchException, MathIllegalStateException 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.- Overrides:
setSumsqImpl
in classMultivariateSummaryStatistics
- Parameters:
sumsqImpl
- the StorelessUnivariateStatistic instance to use for computing the sum of squares- Throws:
DimensionMismatchException
- if the array dimension does not match the one used at constructionMathIllegalStateException
- if data has already been added (i.e if n > 0)
-
getMinImpl
Returns the currently configured minimum implementation- Overrides:
getMinImpl
in classMultivariateSummaryStatistics
- Returns:
- the StorelessUnivariateStatistic implementing the minimum
-
setMinImpl
public void setMinImpl(StorelessUnivariateStatistic[] minImpl) throws DimensionMismatchException, MathIllegalStateException 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.- Overrides:
setMinImpl
in classMultivariateSummaryStatistics
- Parameters:
minImpl
- the StorelessUnivariateStatistic instance to use for computing the minimum- Throws:
DimensionMismatchException
- if the array dimension does not match the one used at constructionMathIllegalStateException
- if data has already been added (i.e if n > 0)
-
getMaxImpl
Returns the currently configured maximum implementation- Overrides:
getMaxImpl
in classMultivariateSummaryStatistics
- Returns:
- the StorelessUnivariateStatistic implementing the maximum
-
setMaxImpl
public void setMaxImpl(StorelessUnivariateStatistic[] maxImpl) throws DimensionMismatchException, MathIllegalStateException 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.- Overrides:
setMaxImpl
in classMultivariateSummaryStatistics
- Parameters:
maxImpl
- the StorelessUnivariateStatistic instance to use for computing the maximum- Throws:
DimensionMismatchException
- if the array dimension does not match the one used at constructionMathIllegalStateException
- if data has already been added (i.e if n > 0)
-
getSumLogImpl
Returns the currently configured sum of logs implementation- Overrides:
getSumLogImpl
in classMultivariateSummaryStatistics
- Returns:
- the StorelessUnivariateStatistic implementing the log sum
-
setSumLogImpl
public void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl) throws DimensionMismatchException, MathIllegalStateException 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.- Overrides:
setSumLogImpl
in classMultivariateSummaryStatistics
- Parameters:
sumLogImpl
- the StorelessUnivariateStatistic instance to use for computing the log sum- Throws:
DimensionMismatchException
- if the array dimension does not match the one used at constructionMathIllegalStateException
- if data has already been added (i.e if n > 0)
-
getGeoMeanImpl
Returns the currently configured geometric mean implementation- Overrides:
getGeoMeanImpl
in classMultivariateSummaryStatistics
- Returns:
- the StorelessUnivariateStatistic implementing the geometric mean
-
setGeoMeanImpl
public void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl) throws DimensionMismatchException, MathIllegalStateException 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.- Overrides:
setGeoMeanImpl
in classMultivariateSummaryStatistics
- Parameters:
geoMeanImpl
- the StorelessUnivariateStatistic instance to use for computing the geometric mean- Throws:
DimensionMismatchException
- if the array dimension does not match the one used at constructionMathIllegalStateException
- if data has already been added (i.e if n > 0)
-
getMeanImpl
Returns the currently configured mean implementation- Overrides:
getMeanImpl
in classMultivariateSummaryStatistics
- Returns:
- the StorelessUnivariateStatistic implementing the mean
-
setMeanImpl
public void setMeanImpl(StorelessUnivariateStatistic[] meanImpl) throws DimensionMismatchException, MathIllegalStateException 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.- Overrides:
setMeanImpl
in classMultivariateSummaryStatistics
- Parameters:
meanImpl
- the StorelessUnivariateStatistic instance to use for computing the mean- Throws:
DimensionMismatchException
- if the array dimension does not match the one used at constructionMathIllegalStateException
- if data has already been added (i.e if n > 0)
-