|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math3.stat.descriptive.DescriptiveStatistics org.apache.commons.math3.stat.descriptive.SynchronizedDescriptiveStatistics
public class SynchronizedDescriptiveStatistics
Implementation of
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.
Field Summary |
---|
Fields inherited from class org.apache.commons.math3.stat.descriptive.DescriptiveStatistics |
---|
INFINITE_WINDOW, windowSize |
Constructor Summary | |
---|---|
SynchronizedDescriptiveStatistics()
Construct an instance with infinite window |
|
SynchronizedDescriptiveStatistics(int window)
Construct an instance with finite window |
|
SynchronizedDescriptiveStatistics(SynchronizedDescriptiveStatistics original)
A copy constructor. |
Method Summary | |
---|---|
void |
addValue(double v)
Adds the value to the dataset. |
double |
apply(UnivariateStatistic stat)
Apply the given statistic to the data associated with this set of statistics. |
void |
clear()
Resets all statistics and storage |
SynchronizedDescriptiveStatistics |
copy()
Returns a copy of this SynchronizedDescriptiveStatistics instance with the same internal state. |
static void |
copy(SynchronizedDescriptiveStatistics source,
SynchronizedDescriptiveStatistics dest)
Copies source to dest. |
double |
getElement(int index)
Returns the element at the specified index |
long |
getN()
Returns the number of available values |
double |
getStandardDeviation()
Returns the standard deviation of the available values. |
double[] |
getValues()
Returns the current set of values in an array of double primitives. |
int |
getWindowSize()
Returns the maximum number of values that can be stored in the dataset, or INFINITE_WINDOW (-1) if there is no limit. |
void |
setWindowSize(int windowSize)
WindowSize controls the number of values that contribute to the reported statistics. |
String |
toString()
Generates a text report displaying univariate statistics from values that have been added. |
Methods inherited from class org.apache.commons.math3.stat.descriptive.DescriptiveStatistics |
---|
copy, getGeometricMean, getGeometricMeanImpl, getKurtosis, getKurtosisImpl, getMax, getMaxImpl, getMean, getMeanImpl, getMin, getMinImpl, getPercentile, getPercentileImpl, getPopulationVariance, getSkewness, getSkewnessImpl, getSortedValues, getSum, getSumImpl, getSumsq, getSumsqImpl, getVariance, getVarianceImpl, removeMostRecentValue, replaceMostRecentValue, setGeometricMeanImpl, setKurtosisImpl, setMaxImpl, setMeanImpl, setMinImpl, setPercentileImpl, setSkewnessImpl, setSumImpl, setSumsqImpl, setVarianceImpl |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SynchronizedDescriptiveStatistics()
public SynchronizedDescriptiveStatistics(int window) throws MathIllegalArgumentException
window
- the finite window size.
MathIllegalArgumentException
- if window size is less than 1 but
not equal to DescriptiveStatistics.INFINITE_WINDOW
public SynchronizedDescriptiveStatistics(SynchronizedDescriptiveStatistics original) throws NullArgumentException
original
.
original
- the SynchronizedDescriptiveStatistics
instance to copy
NullArgumentException
- if original is nullMethod Detail |
---|
public void addValue(double v)
addValue
in class DescriptiveStatistics
v
- the value to be addedpublic double apply(UnivariateStatistic stat)
apply
in class DescriptiveStatistics
stat
- the statistic to apply
public void clear()
clear
in class DescriptiveStatistics
public double getElement(int index)
getElement
in class DescriptiveStatistics
index
- The Index of the element
public long getN()
getN
in interface StatisticalSummary
getN
in class DescriptiveStatistics
public double getStandardDeviation()
getStandardDeviation
in interface StatisticalSummary
getStandardDeviation
in class DescriptiveStatistics
public double[] getValues()
getValues
in class DescriptiveStatistics
public int getWindowSize()
getWindowSize
in class DescriptiveStatistics
public void setWindowSize(int windowSize) throws MathIllegalArgumentException
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.
setWindowSize
in class DescriptiveStatistics
windowSize
- sets the size of the window.
MathIllegalArgumentException
- if window size is less than 1 but
not equal to DescriptiveStatistics.INFINITE_WINDOW
public String toString()
toString
in class DescriptiveStatistics
public SynchronizedDescriptiveStatistics copy()
copy
in class DescriptiveStatistics
public static void copy(SynchronizedDescriptiveStatistics source, SynchronizedDescriptiveStatistics dest) throws NullArgumentException
Neither source nor dest can be null.
Acquires synchronization lock on source, then dest before copying.
source
- SynchronizedDescriptiveStatistics to copydest
- SynchronizedDescriptiveStatistics to copy to
NullArgumentException
- if either source or dest is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |