Class SynchronizedSummaryStatistics
- java.lang.Object
 - 
- org.apache.commons.math.stat.descriptive.SummaryStatistics
 - 
- org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatistics
 
 
 
- 
- All Implemented Interfaces:
 java.io.Serializable,StatisticalSummary
public class SynchronizedSummaryStatistics extends SummaryStatistics
Implementation ofSummaryStatisticsthat 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:
 - Serialized Form
 
 
- 
- 
Constructor Summary
Constructors Constructor Description SynchronizedSummaryStatistics()Construct a SynchronizedSummaryStatistics instanceSynchronizedSummaryStatistics(SynchronizedSummaryStatistics original)A copy constructor. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddValue(double value)Add a value to the datavoidclear()Resets all statistics and storageSynchronizedSummaryStatisticscopy()Returns a copy of this SynchronizedSummaryStatistics instance with the same internal state.static voidcopy(SynchronizedSummaryStatistics source, SynchronizedSummaryStatistics dest)Copies source to dest.booleanequals(java.lang.Object object)Returns true iffobjectis aSummaryStatisticsinstance and all statistics have the same values as this.StorelessUnivariateStatisticgetGeoMeanImpl()Returns the currently configured geometric mean implementationdoublegetGeometricMean()Returns the geometric mean of the values that have been added.doublegetMax()Returns the maximum of the values that have been added.StorelessUnivariateStatisticgetMaxImpl()Returns the currently configured maximum implementationdoublegetMean()Returns the mean of the values that have been added.StorelessUnivariateStatisticgetMeanImpl()Returns the currently configured mean implementationdoublegetMin()Returns the minimum of the values that have been added.StorelessUnivariateStatisticgetMinImpl()Returns the currently configured minimum implementationlonggetN()Returns the number of available valuesdoublegetStandardDeviation()Returns the standard deviation of the values that have been added.doublegetSum()Returns the sum of the values that have been addedStorelessUnivariateStatisticgetSumImpl()Returns the currently configured Sum implementationStorelessUnivariateStatisticgetSumLogImpl()Returns the currently configured sum of logs implementationStatisticalSummarygetSummary()Return aStatisticalSummaryValuesinstance reporting current statistics.doublegetSumsq()Returns the sum of the squares of the values that have been added.StorelessUnivariateStatisticgetSumsqImpl()Returns the currently configured sum of squares implementationdoublegetVariance()Returns the variance of the values that have been added.StorelessUnivariateStatisticgetVarianceImpl()Returns the currently configured variance implementationinthashCode()Returns hash code based on values of statisticsvoidsetGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl)Sets the implementation for the geometric mean.voidsetMaxImpl(StorelessUnivariateStatistic maxImpl)Sets the implementation for the maximum.voidsetMeanImpl(StorelessUnivariateStatistic meanImpl)Sets the implementation for the mean.voidsetMinImpl(StorelessUnivariateStatistic minImpl)Sets the implementation for the minimum.voidsetSumImpl(StorelessUnivariateStatistic sumImpl)Sets the implementation for the Sum.voidsetSumLogImpl(StorelessUnivariateStatistic sumLogImpl)Sets the implementation for the sum of logs.voidsetSumsqImpl(StorelessUnivariateStatistic sumsqImpl)Sets the implementation for the sum of squares.voidsetVarianceImpl(StorelessUnivariateStatistic varianceImpl)Sets the implementation for the variance.java.lang.StringtoString()Generates a text report displaying summary statistics from values that have been added.- 
Methods inherited from class org.apache.commons.math.stat.descriptive.SummaryStatistics
copy, getSecondMoment, getSumOfLogs 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
SynchronizedSummaryStatistics
public SynchronizedSummaryStatistics()
Construct a SynchronizedSummaryStatistics instance 
- 
SynchronizedSummaryStatistics
public SynchronizedSummaryStatistics(SynchronizedSummaryStatistics original)
A copy constructor. Creates a deep-copy of theoriginal.- Parameters:
 original- theSynchronizedSummaryStatisticsinstance to copy
 
 - 
 
- 
Method Detail
- 
getSummary
public StatisticalSummary getSummary()
Return aStatisticalSummaryValuesinstance reporting current statistics.- Overrides:
 getSummaryin classSummaryStatistics- Returns:
 - Current values of statistics
 
 
- 
addValue
public void addValue(double value)
Add a value to the data- Overrides:
 addValuein classSummaryStatistics- Parameters:
 value- the value to add
 
- 
getN
public long getN()
Returns the number of available values- Specified by:
 getNin interfaceStatisticalSummary- Overrides:
 getNin classSummaryStatistics- Returns:
 - The number of available values
 
 
- 
getSum
public double getSum()
Returns the sum of the values that have been added- Specified by:
 getSumin interfaceStatisticalSummary- Overrides:
 getSumin classSummaryStatistics- Returns:
 - The sum or 
Double.NaNif no values have been added 
 
- 
getSumsq
public double getSumsq()
Returns the sum of the squares of the values that have been added.Double.NaN is returned if no values have been added.
- Overrides:
 getSumsqin classSummaryStatistics- Returns:
 - The sum of squares
 
 
- 
getMean
public double getMean()
Returns the mean of the values that have been added.Double.NaN is returned if no values have been added.
- Specified by:
 getMeanin interfaceStatisticalSummary- Overrides:
 getMeanin classSummaryStatistics- Returns:
 - the mean
 
 
- 
getStandardDeviation
public double getStandardDeviation()
Returns the standard deviation of the values that have been added.Double.NaN is returned if no values have been added.
- Specified by:
 getStandardDeviationin interfaceStatisticalSummary- Overrides:
 getStandardDeviationin classSummaryStatistics- Returns:
 - the standard deviation
 
 
- 
getVariance
public double getVariance()
Returns the variance of the values that have been added.Double.NaN is returned if no values have been added.
- Specified by:
 getVariancein interfaceStatisticalSummary- Overrides:
 getVariancein classSummaryStatistics- Returns:
 - the variance
 
 
- 
getMax
public double getMax()
Returns the maximum of the values that have been added.Double.NaN is returned if no values have been added.
- Specified by:
 getMaxin interfaceStatisticalSummary- Overrides:
 getMaxin classSummaryStatistics- Returns:
 - the maximum
 
 
- 
getMin
public double getMin()
Returns the minimum of the values that have been added.Double.NaN is returned if no values have been added.
- Specified by:
 getMinin interfaceStatisticalSummary- Overrides:
 getMinin classSummaryStatistics- Returns:
 - the minimum
 
 
- 
getGeometricMean
public double getGeometricMean()
Returns the geometric mean of the values that have been added.Double.NaN is returned if no values have been added.
- Overrides:
 getGeometricMeanin classSummaryStatistics- Returns:
 - the geometric mean
 
 
- 
toString
public java.lang.String toString()
Generates a text report displaying summary statistics from values that have been added.- Overrides:
 toStringin classSummaryStatistics- Returns:
 - String with line feeds displaying statistics
 
 
- 
clear
public void clear()
Resets all statistics and storage- Overrides:
 clearin classSummaryStatistics
 
- 
equals
public boolean equals(java.lang.Object object)
Returns true iffobjectis aSummaryStatisticsinstance and all statistics have the same values as this.- Overrides:
 equalsin classSummaryStatistics- 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:
 hashCodein classSummaryStatistics- Returns:
 - hash code
 
 
- 
getSumImpl
public StorelessUnivariateStatistic getSumImpl()
Returns the currently configured Sum implementation- Overrides:
 getSumImplin classSummaryStatistics- Returns:
 - the StorelessUnivariateStatistic implementing the sum
 
 
- 
setSumImpl
public void setSumImpl(StorelessUnivariateStatistic sumImpl)
Sets the implementation for the Sum.
This method must be activated before any data has been added - i.e., before
addValuehas been used to add data; otherwise an IllegalStateException will be thrown.- Overrides:
 setSumImplin classSummaryStatistics- Parameters:
 sumImpl- the StorelessUnivariateStatistic instance to use for computing the Sum
 
- 
getSumsqImpl
public StorelessUnivariateStatistic getSumsqImpl()
Returns the currently configured sum of squares implementation- Overrides:
 getSumsqImplin classSummaryStatistics- Returns:
 - the StorelessUnivariateStatistic implementing the sum of squares
 
 
- 
setSumsqImpl
public void setSumsqImpl(StorelessUnivariateStatistic sumsqImpl)
Sets the implementation for the sum of squares.
This method must be activated before any data has been added - i.e., before
addValuehas been used to add data; otherwise an IllegalStateException will be thrown.- Overrides:
 setSumsqImplin classSummaryStatistics- Parameters:
 sumsqImpl- the StorelessUnivariateStatistic instance to use for computing the sum of squares
 
- 
getMinImpl
public StorelessUnivariateStatistic getMinImpl()
Returns the currently configured minimum implementation- Overrides:
 getMinImplin classSummaryStatistics- Returns:
 - the StorelessUnivariateStatistic implementing the minimum
 
 
- 
setMinImpl
public void setMinImpl(StorelessUnivariateStatistic minImpl)
Sets the implementation for the minimum.
This method must be activated before any data has been added - i.e., before
addValuehas been used to add data; otherwise an IllegalStateException will be thrown.- Overrides:
 setMinImplin classSummaryStatistics- Parameters:
 minImpl- the StorelessUnivariateStatistic instance to use for computing the minimum
 
- 
getMaxImpl
public StorelessUnivariateStatistic getMaxImpl()
Returns the currently configured maximum implementation- Overrides:
 getMaxImplin classSummaryStatistics- Returns:
 - the StorelessUnivariateStatistic implementing the maximum
 
 
- 
setMaxImpl
public void setMaxImpl(StorelessUnivariateStatistic maxImpl)
Sets the implementation for the maximum.
This method must be activated before any data has been added - i.e., before
addValuehas been used to add data; otherwise an IllegalStateException will be thrown.- Overrides:
 setMaxImplin classSummaryStatistics- Parameters:
 maxImpl- the StorelessUnivariateStatistic instance to use for computing the maximum
 
- 
getSumLogImpl
public StorelessUnivariateStatistic getSumLogImpl()
Returns the currently configured sum of logs implementation- Overrides:
 getSumLogImplin classSummaryStatistics- Returns:
 - the StorelessUnivariateStatistic implementing the log sum
 
 
- 
setSumLogImpl
public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl)
Sets the implementation for the sum of logs.
This method must be activated before any data has been added - i.e., before
addValuehas been used to add data; otherwise an IllegalStateException will be thrown.- Overrides:
 setSumLogImplin classSummaryStatistics- Parameters:
 sumLogImpl- the StorelessUnivariateStatistic instance to use for computing the log sum
 
- 
getGeoMeanImpl
public StorelessUnivariateStatistic getGeoMeanImpl()
Returns the currently configured geometric mean implementation- Overrides:
 getGeoMeanImplin classSummaryStatistics- Returns:
 - the StorelessUnivariateStatistic implementing the geometric mean
 
 
- 
setGeoMeanImpl
public void setGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl)
Sets the implementation for the geometric mean.
This method must be activated before any data has been added - i.e., before
addValuehas been used to add data; otherwise an IllegalStateException will be thrown.- Overrides:
 setGeoMeanImplin classSummaryStatistics- Parameters:
 geoMeanImpl- the StorelessUnivariateStatistic instance to use for computing the geometric mean
 
- 
getMeanImpl
public StorelessUnivariateStatistic getMeanImpl()
Returns the currently configured mean implementation- Overrides:
 getMeanImplin classSummaryStatistics- Returns:
 - the StorelessUnivariateStatistic implementing the mean
 
 
- 
setMeanImpl
public void setMeanImpl(StorelessUnivariateStatistic meanImpl)
Sets the implementation for the mean.
This method must be activated before any data has been added - i.e., before
addValuehas been used to add data; otherwise an IllegalStateException will be thrown.- Overrides:
 setMeanImplin classSummaryStatistics- Parameters:
 meanImpl- the StorelessUnivariateStatistic instance to use for computing the mean
 
- 
getVarianceImpl
public StorelessUnivariateStatistic getVarianceImpl()
Returns the currently configured variance implementation- Overrides:
 getVarianceImplin classSummaryStatistics- Returns:
 - the StorelessUnivariateStatistic implementing the variance
 
 
- 
setVarianceImpl
public void setVarianceImpl(StorelessUnivariateStatistic varianceImpl)
Sets the implementation for the variance.
This method must be activated before any data has been added - i.e., before
addValuehas been used to add data; otherwise an IllegalStateException will be thrown.- Overrides:
 setVarianceImplin classSummaryStatistics- Parameters:
 varianceImpl- the StorelessUnivariateStatistic instance to use for computing the variance
 
- 
copy
public SynchronizedSummaryStatistics copy()
Returns a copy of this SynchronizedSummaryStatistics instance with the same internal state.- Overrides:
 copyin classSummaryStatistics- Returns:
 - a copy of this
 
 
- 
copy
public static void copy(SynchronizedSummaryStatistics source, SynchronizedSummaryStatistics dest)
Copies source to dest.Neither source nor dest can be null.
Acquires synchronization lock on source, then dest before copying.
- Parameters:
 source- SynchronizedSummaryStatistics to copydest- SynchronizedSummaryStatistics to copy to- Throws:
 java.lang.NullPointerException- if either source or dest is null
 
 - 
 
 -