Top Description Fields Constructors Methods
org.apache.commons.math3.stat.descriptive

public Class SynchronizedDescriptiveStatistics

extends DescriptiveStatistics
Class Inheritance
Imports
org.apache.commons.math3.exception.MathIllegalArgumentException, .NullArgumentException, org.apache.commons.math3.util.MathUtils

Implementation of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics 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

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics:
INFINITE_WINDOWwindowSize

Constructor Summary

AccessConstructor and Description
public
SynchronizedDescriptiveStatistics()

Construct an instance with infinite window

public
SynchronizedDescriptiveStatistics(int
the finite window size.
window
)

Construct an instance with finite window

public
SynchronizedDescriptiveStatistics(SynchronizedDescriptiveStatistics
the SynchronizedDescriptiveStatistics instance to copy
original
)

A copy constructor.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addValue(double
the value to be added
v
)

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.addValue.

Adds the value to the dataset.

public synchronized double
apply(UnivariateStatistic
the statistic to apply
stat
)

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.apply.

Apply the given statistic to the data associated with this set of statistics.

public synchronized void
public synchronized SynchronizedDescriptiveStatistics

Returns:

a copy of this
copy
()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.copy.

Returns a copy of this SynchronizedDescriptiveStatistics instance with the same internal state.

public static void
copy(SynchronizedDescriptiveStatistics
SynchronizedDescriptiveStatistics to copy
source
,
SynchronizedDescriptiveStatistics
SynchronizedDescriptiveStatistics to copy to
dest
)

Copies source to dest.

public synchronized double
getElement(int
The Index of the element
index
)

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getElement.

Returns the element at the specified index

public synchronized long
public synchronized double
public synchronized double
public synchronized double[]
getValues()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getValues.

Returns the current set of values in an array of double primitives.

public synchronized int
getWindowSize()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getWindowSize.

Returns the maximum number of values that can be stored in the dataset, or INFINITE_WINDOW (-1) if there is no limit.

public synchronized void
setWindowSize(int
sets the size of the window.
windowSize
)

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.setWindowSize.

WindowSize controls the number of values that contribute to the reported statistics.

public synchronized String
toString()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.toString.

Generates a text report displaying univariate statistics from values that have been added.

Inherited from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics:
copygetGeometricMeangetGeometricMeanImplgetKurtosisgetKurtosisImplgetMaxgetMaxImplgetMeangetMeanImplgetMingetMinImplgetPercentilegetPercentileImplgetPopulationVariancegetSkewnessgetSkewnessImplgetSortedValuesgetSumgetSumImplgetSumsqgetSumsqImplgetVariancegetVarianceImplremoveMostRecentValuereplaceMostRecentValuesetGeometricMeanImplsetKurtosisImplsetMaxImplsetMeanImplsetMinImplsetPercentileImplsetSkewnessImplsetSumImplsetSumsqImplsetVarianceImpl

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.serialVersionUID.

Serialization UID

Constructor Detail

SynchronizedDescriptiveStatisticsback to summary
public SynchronizedDescriptiveStatistics()

Construct an instance with infinite window

SynchronizedDescriptiveStatisticsback to summary
public SynchronizedDescriptiveStatistics(int window) throws MathIllegalArgumentException

Construct an instance with finite window

Parameters
window:int

the finite window size.

Exceptions
MathIllegalArgumentException:
if window size is less than 1 but not equal to INFINITE_WINDOW
SynchronizedDescriptiveStatisticsback to summary
public SynchronizedDescriptiveStatistics(SynchronizedDescriptiveStatistics original) throws NullArgumentException

A copy constructor. Creates a deep-copy of the original.

Parameters
original:SynchronizedDescriptiveStatistics

the SynchronizedDescriptiveStatistics instance to copy

Exceptions
NullArgumentException:
if original is null

Method Detail

addValueback to summary
public synchronized void addValue(double v)

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.addValue.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.addValue.

Adds the value to the dataset. If the dataset is at the maximum size (i.e., the number of stored elements equals the currently configured windowSize), the first (oldest) element in the dataset is discarded to make room for the new value.

Parameters
v:double

the value to be added

Annotations
@Override
applyback to summary
public synchronized double apply(UnivariateStatistic stat)

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.apply.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.apply.

Apply the given statistic to the data associated with this set of statistics.

Parameters
stat:UnivariateStatistic

the statistic to apply

Returns:double

the computed value of the statistic.

Annotations
@Override
clearback to summary
public synchronized void clear()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.clear.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.clear.

Resets all statistics and storage

Annotations
@Override
copyback to summary
public synchronized SynchronizedDescriptiveStatistics copy()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.copy.

Returns a copy of this SynchronizedDescriptiveStatistics instance with the same internal state.

Returns:SynchronizedDescriptiveStatistics

a copy of this

Annotations
@Override
copyback to summary
public static void copy(SynchronizedDescriptiveStatistics source, SynchronizedDescriptiveStatistics dest) throws NullArgumentException

Copies source to dest.

Neither source nor dest can be null.

Acquires synchronization lock on source, then dest before copying.

Parameters
source:SynchronizedDescriptiveStatistics

SynchronizedDescriptiveStatistics to copy

dest:SynchronizedDescriptiveStatistics

SynchronizedDescriptiveStatistics to copy to

Exceptions
NullArgumentException:
if either source or dest is null
getElementback to summary
public synchronized double getElement(int index)

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getElement.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getElement.

Returns the element at the specified index

Parameters
index:int

The Index of the element

Returns:double

return the element at the specified index

Annotations
@Override
getNback to summary
public synchronized long getN()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getN.

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getN.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getN.

Returns the number of available values

Returns:long

The number of available values

Annotations
@Override
getQuadraticMeanback to summary
public synchronized double getQuadraticMean()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getQuadraticMean.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getQuadraticMean.

Returns the quadratic mean, a.k.a. root-mean-square of the available values

Returns:double

The quadratic mean or Double.NaN if no values have been added.

Annotations
@Override
getStandardDeviationback to summary
public synchronized double getStandardDeviation()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getStandardDeviation.

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getStandardDeviation.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getStandardDeviation.

Returns the standard deviation of the available values.

Returns:double

The standard deviation, Double.NaN if no values have been added or 0.0 for a single value set.

Annotations
@Override
getValuesback to summary
public synchronized double[] getValues()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getValues.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getValues.

Returns the current set of values in an array of double primitives. The order of addition is preserved. The returned array is a fresh copy of the underlying data -- i.e., it is not a reference to the stored data.

Returns:double[]

returns the current set of numbers in the order in which they were added to this set

Annotations
@Override
getWindowSizeback to summary
public synchronized int getWindowSize()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getWindowSize.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.getWindowSize.

Returns the maximum number of values that can be stored in the dataset, or INFINITE_WINDOW (-1) if there is no limit.

Returns:int

The current window size or -1 if its Infinite.

Annotations
@Override
setWindowSizeback to summary
public synchronized void setWindowSize(int windowSize) throws MathIllegalArgumentException

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.setWindowSize.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.setWindowSize.

WindowSize controls the number of values that contribute to the reported statistics. For example, if windowSize is set to 3 and the values {1,2,3,4,5} have been added in that order then the available values are {3,4,5} and all reported statistics will be based on these values. If windowSize is decreased as a result of this call and there are more than the new value of elements in the current dataset, values from the front of the array are discarded to reduce the dataset to windowSize elements.

Parameters
windowSize:int

sets the size of the window.

Annotations
@Override
Exceptions
MathIllegalArgumentException:
if window size is less than 1 but not equal to INFINITE_WINDOW
toStringback to summary
public synchronized String toString()

Overrides org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.toString.

Doc from org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.toString.

Generates a text report displaying univariate statistics from values that have been added. Each statistic is displayed on a separate line.

Returns:String

String with line feeds displaying statistics

Annotations
@Override