org.apache.commons.math.stat.descriptive
Class SynchronizedMultivariateSummaryStatistics

java.lang.Object
  extended by org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics
      extended by org.apache.commons.math.stat.descriptive.SynchronizedMultivariateSummaryStatistics
All Implemented Interfaces:
java.io.Serializable, StatisticalMultivariateSummary

public class SynchronizedMultivariateSummaryStatistics
extends MultivariateSummaryStatistics

Implementation of 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
Version:
$Revision: 618097 $ $Date: 2008-02-03 22:39:08 +0100 (dim., 03 févr. 2008) $
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          Serialization UID
 
Constructor Summary
SynchronizedMultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected)
          Construct a SynchronizedMultivariateSummaryStatistics instance
 
Method Summary
 void addValue(double[] value)
          Add an n-tuple to the data
 void clear()
          Resets all statistics and storage
 boolean equals(java.lang.Object object)
          Returns true iff object is a SummaryStatistics instance and all statistics have the same values as this.
 RealMatrix getCovariance()
          Returns the covariance matrix of the values that have been added.
 int getDimension()
          Returns the dimension of the data
 StorelessUnivariateStatistic[] getGeoMeanImpl()
          Returns the currently configured geometric mean implementation
 double[] getGeometricMean()
          Returns an array whose ith entry is the geometric mean of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])
 double[] getMax()
          Returns an array whose ith entry is the maximum of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])
 StorelessUnivariateStatistic[] getMaxImpl()
          Returns the currently configured maximum implementation
 double[] getMean()
          Returns an array whose ith entry is the mean of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])
 StorelessUnivariateStatistic[] getMeanImpl()
          Returns the currently configured mean implementation
 double[] getMin()
          Returns an array whose ith entry is the minimum of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])
 StorelessUnivariateStatistic[] getMinImpl()
          Returns the currently configured minimum implementation
 long getN()
          Returns the number of available values
 double[] getStandardDeviation()
          Returns an array whose ith entry is the standard deviation of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])
 double[] getSum()
          Returns an array whose ith entry is the sum of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])
 StorelessUnivariateStatistic[] getSumImpl()
          Returns the currently configured Sum implementation
 double[] getSumLog()
          Returns an array whose ith entry is the sum of logs of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])
 StorelessUnivariateStatistic[] getSumLogImpl()
          Returns the currently configured sum of logs implementation
 double[] getSumSq()
          Returns an array whose ith entry is the sum of squares of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])
 StorelessUnivariateStatistic[] getSumsqImpl()
          Returns the currently configured sum of squares implementation
 int hashCode()
          Returns hash code based on values of statistics
 void 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.
 java.lang.String toString()
          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
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serialization UID

See Also:
Constant Field Values
Constructor Detail

SynchronizedMultivariateSummaryStatistics

public SynchronizedMultivariateSummaryStatistics(int k,
                                                 boolean isCovarianceBiasCorrected)
Construct a SynchronizedMultivariateSummaryStatistics instance

Parameters:
k - dimension of the data
isCovarianceBiasCorrected - if true, the unbiased sample covariance is computed, otherwise the biased population covariance is computed
Method Detail

addValue

public void addValue(double[] value)
              throws DimensionMismatchException
Description copied from class: MultivariateSummaryStatistics
Add an n-tuple to the data

Overrides:
addValue in class MultivariateSummaryStatistics
Parameters:
value - the n-tuple to add
Throws:
DimensionMismatchException - if the length of the array does not match the one used at construction
See Also:
MultivariateSummaryStatistics.addValue(double[])

getDimension

public int getDimension()
Description copied from class: MultivariateSummaryStatistics
Returns the dimension of the data

Specified by:
getDimension in interface StatisticalMultivariateSummary
Overrides:
getDimension in class MultivariateSummaryStatistics
Returns:
The dimension of the data
See Also:
MultivariateSummaryStatistics.getDimension()

getN

public long getN()
Description copied from class: MultivariateSummaryStatistics
Returns the number of available values

Specified by:
getN in interface StatisticalMultivariateSummary
Overrides:
getN in class MultivariateSummaryStatistics
Returns:
The number of available values
See Also:
MultivariateSummaryStatistics.getN()

getSum

public double[] getSum()
Description copied from class: MultivariateSummaryStatistics
Returns an array whose ith entry is the sum of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])

Specified by:
getSum in interface StatisticalMultivariateSummary
Overrides:
getSum in class MultivariateSummaryStatistics
Returns:
the array of component sums
See Also:
MultivariateSummaryStatistics.getSum()

getSumSq

public double[] getSumSq()
Description copied from class: MultivariateSummaryStatistics
Returns an array whose ith entry is the sum of squares of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])

Specified by:
getSumSq in interface StatisticalMultivariateSummary
Overrides:
getSumSq in class MultivariateSummaryStatistics
Returns:
the array of component sums of squares
See Also:
MultivariateSummaryStatistics.getSumSq()

getSumLog

public double[] getSumLog()
Description copied from class: MultivariateSummaryStatistics
Returns an array whose ith entry is the sum of logs of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])

Specified by:
getSumLog in interface StatisticalMultivariateSummary
Overrides:
getSumLog in class MultivariateSummaryStatistics
Returns:
the array of component log sums
See Also:
MultivariateSummaryStatistics.getSumLog()

getMean

public double[] getMean()
Description copied from class: MultivariateSummaryStatistics
Returns an array whose ith entry is the mean of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])

Specified by:
getMean in interface StatisticalMultivariateSummary
Overrides:
getMean in class MultivariateSummaryStatistics
Returns:
the array of component means
See Also:
MultivariateSummaryStatistics.getMean()

getStandardDeviation

public double[] getStandardDeviation()
Description copied from class: MultivariateSummaryStatistics
Returns an array whose ith entry is the standard deviation of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])

Specified by:
getStandardDeviation in interface StatisticalMultivariateSummary
Overrides:
getStandardDeviation in class MultivariateSummaryStatistics
Returns:
the array of component standard deviations
See Also:
MultivariateSummaryStatistics.getStandardDeviation()

getCovariance

public RealMatrix getCovariance()
Description copied from class: MultivariateSummaryStatistics
Returns the covariance matrix of the values that have been added.

Specified by:
getCovariance in interface StatisticalMultivariateSummary
Overrides:
getCovariance in class MultivariateSummaryStatistics
Returns:
the covariance matrix
See Also:
MultivariateSummaryStatistics.getCovariance()

getMax

public double[] getMax()
Description copied from class: MultivariateSummaryStatistics
Returns an array whose ith entry is the maximum of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])

Specified by:
getMax in interface StatisticalMultivariateSummary
Overrides:
getMax in class MultivariateSummaryStatistics
Returns:
the array of component maxima
See Also:
MultivariateSummaryStatistics.getMax()

getMin

public double[] getMin()
Description copied from class: MultivariateSummaryStatistics
Returns an array whose ith entry is the minimum of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])

Specified by:
getMin in interface StatisticalMultivariateSummary
Overrides:
getMin in class MultivariateSummaryStatistics
Returns:
the array of component minima
See Also:
MultivariateSummaryStatistics.getMin()

getGeometricMean

public double[] getGeometricMean()
Description copied from class: MultivariateSummaryStatistics
Returns an array whose ith entry is the geometric mean of the ith entries of the arrays that have been added using MultivariateSummaryStatistics.addValue(double[])

Specified by:
getGeometricMean in interface StatisticalMultivariateSummary
Overrides:
getGeometricMean in class MultivariateSummaryStatistics
Returns:
the array of component geometric means
See Also:
MultivariateSummaryStatistics.getGeometricMean()

toString

public java.lang.String toString()
Description copied from class: MultivariateSummaryStatistics
Generates a text report displaying summary statistics from values that have been added.

Overrides:
toString in class MultivariateSummaryStatistics
Returns:
String with line feeds displaying statistics
See Also:
MultivariateSummaryStatistics.toString()

clear

public void clear()
Description copied from class: MultivariateSummaryStatistics
Resets all statistics and storage

Overrides:
clear in class MultivariateSummaryStatistics
See Also:
MultivariateSummaryStatistics.clear()

equals

public boolean equals(java.lang.Object object)
Description copied from class: MultivariateSummaryStatistics
Returns true iff object is a SummaryStatistics instance and all statistics have the same values as this.

Overrides:
equals in class MultivariateSummaryStatistics
Parameters:
object - the object to test equality against.
Returns:
true if object equals this
See Also:
MultivariateSummaryStatistics.equals(Object)

hashCode

public int hashCode()
Description copied from class: MultivariateSummaryStatistics
Returns hash code based on values of statistics

Overrides:
hashCode in class MultivariateSummaryStatistics
Returns:
hash code
See Also:
MultivariateSummaryStatistics.hashCode()

getSumImpl

public StorelessUnivariateStatistic[] getSumImpl()
Description copied from class: MultivariateSummaryStatistics
Returns the currently configured Sum implementation

Overrides:
getSumImpl in class MultivariateSummaryStatistics
Returns:
the StorelessUnivariateStatistic implementing the sum
See Also:
MultivariateSummaryStatistics.getSumImpl()

setSumImpl

public void setSumImpl(StorelessUnivariateStatistic[] sumImpl)
                throws DimensionMismatchException
Description copied from class: MultivariateSummaryStatistics

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 class MultivariateSummaryStatistics
Parameters:
sumImpl - the StorelessUnivariateStatistic instance to use for computing the Sum
Throws:
DimensionMismatchException - if the array dimension does not match the one used at construction
See Also:
MultivariateSummaryStatistics.setSumImpl(StorelessUnivariateStatistic[])

getSumsqImpl

public StorelessUnivariateStatistic[] getSumsqImpl()
Description copied from class: MultivariateSummaryStatistics
Returns the currently configured sum of squares implementation

Overrides:
getSumsqImpl in class MultivariateSummaryStatistics
Returns:
the StorelessUnivariateStatistic implementing the sum of squares
See Also:
MultivariateSummaryStatistics.getSumsqImpl()

setSumsqImpl

public void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl)
                  throws DimensionMismatchException
Description copied from class: MultivariateSummaryStatistics

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 class MultivariateSummaryStatistics
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 construction
See Also:
MultivariateSummaryStatistics.setSumsqImpl(StorelessUnivariateStatistic[])

getMinImpl

public StorelessUnivariateStatistic[] getMinImpl()
Description copied from class: MultivariateSummaryStatistics
Returns the currently configured minimum implementation

Overrides:
getMinImpl in class MultivariateSummaryStatistics
Returns:
the StorelessUnivariateStatistic implementing the minimum
See Also:
MultivariateSummaryStatistics.getMinImpl()

setMinImpl

public void setMinImpl(StorelessUnivariateStatistic[] minImpl)
                throws DimensionMismatchException
Description copied from class: MultivariateSummaryStatistics

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 class MultivariateSummaryStatistics
Parameters:
minImpl - the StorelessUnivariateStatistic instance to use for computing the minimum
Throws:
DimensionMismatchException - if the array dimension does not match the one used at construction
See Also:
MultivariateSummaryStatistics.setMinImpl(StorelessUnivariateStatistic[])

getMaxImpl

public StorelessUnivariateStatistic[] getMaxImpl()
Description copied from class: MultivariateSummaryStatistics
Returns the currently configured maximum implementation

Overrides:
getMaxImpl in class MultivariateSummaryStatistics
Returns:
the StorelessUnivariateStatistic implementing the maximum
See Also:
MultivariateSummaryStatistics.getMaxImpl()

setMaxImpl

public void setMaxImpl(StorelessUnivariateStatistic[] maxImpl)
                throws DimensionMismatchException
Description copied from class: MultivariateSummaryStatistics

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 class MultivariateSummaryStatistics
Parameters:
maxImpl - the StorelessUnivariateStatistic instance to use for computing the maximum
Throws:
DimensionMismatchException - if the array dimension does not match the one used at construction
See Also:
MultivariateSummaryStatistics.setMaxImpl(StorelessUnivariateStatistic[])

getSumLogImpl

public StorelessUnivariateStatistic[] getSumLogImpl()
Description copied from class: MultivariateSummaryStatistics
Returns the currently configured sum of logs implementation

Overrides:
getSumLogImpl in class MultivariateSummaryStatistics
Returns:
the StorelessUnivariateStatistic implementing the log sum
See Also:
MultivariateSummaryStatistics.getSumLogImpl()

setSumLogImpl

public void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl)
                   throws DimensionMismatchException
Description copied from class: MultivariateSummaryStatistics

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 class MultivariateSummaryStatistics
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 construction
See Also:
MultivariateSummaryStatistics.setSumLogImpl(StorelessUnivariateStatistic[])

getGeoMeanImpl

public StorelessUnivariateStatistic[] getGeoMeanImpl()
Description copied from class: MultivariateSummaryStatistics
Returns the currently configured geometric mean implementation

Overrides:
getGeoMeanImpl in class MultivariateSummaryStatistics
Returns:
the StorelessUnivariateStatistic implementing the geometric mean
See Also:
MultivariateSummaryStatistics.getGeoMeanImpl()

setGeoMeanImpl

public void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl)
                    throws DimensionMismatchException
Description copied from class: MultivariateSummaryStatistics

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 class MultivariateSummaryStatistics
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 construction
See Also:
MultivariateSummaryStatistics.setGeoMeanImpl(StorelessUnivariateStatistic[])

getMeanImpl

public StorelessUnivariateStatistic[] getMeanImpl()
Description copied from class: MultivariateSummaryStatistics
Returns the currently configured mean implementation

Overrides:
getMeanImpl in class MultivariateSummaryStatistics
Returns:
the StorelessUnivariateStatistic implementing the mean
See Also:
MultivariateSummaryStatistics.getMeanImpl()

setMeanImpl

public void setMeanImpl(StorelessUnivariateStatistic[] meanImpl)
                 throws DimensionMismatchException
Description copied from class: MultivariateSummaryStatistics

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 class MultivariateSummaryStatistics
Parameters:
meanImpl - the StorelessUnivariateStatistic instance to use for computing the mean
Throws:
DimensionMismatchException - if the array dimension does not match the one used at construction
See Also:
MultivariateSummaryStatistics.setMeanImpl(StorelessUnivariateStatistic[])