T
- the number type used in these statistics@ThreadSafe public class SimpleStatistics<T extends Number> extends Object
minimum
, maximum
, total (aggregate sum)
, and mean (average)
. See DetailedStatistics
for a subclass that also calculates the median
, standard deviation
and the histogram
of the values.
This class is threadsafe.
Modifier and Type | Field and Description |
---|---|
protected MathOperations<T> |
math |
Constructor and Description |
---|
SimpleStatistics(MathOperations<T> operations) |
Modifier and Type | Method and Description |
---|---|
void |
add(T value)
Add a new value to these statistics.
|
protected void |
doAddValue(T value)
A method that can be overridden by subclasses when
add is called. |
protected void |
doReset()
Method that can be overridden by subclasses when
reset() is called. |
int |
getCount()
Get the number of values that have been measured.
|
protected ReadWriteLock |
getLock() |
MathOperations<T> |
getMathOperations() |
T |
getMaximum()
Get the maximum value in the series.
|
T |
getMean()
Return the approximate mean (average) value represented as an instance of the operand type.
|
double |
getMeanValue()
Return the mean (average) value.
|
T |
getMinimum()
Get the minimum value in the series.
|
T |
getTotal()
Get the aggregate sum of the values in the series.
|
void |
reset()
Reset the statistics in this object, and clear out any stored information.
|
String |
toString() |
protected final MathOperations<T extends Number> math
public SimpleStatistics(MathOperations<T> operations)
public void add(T value)
value
- the new valueprotected void doAddValue(T value)
add
is called. This method is called within the
write lock, and does real work. Therefore, subclasses should call this method when they overwrite it.value
- the value already addedpublic T getTotal()
count
is 0public T getMaximum()
count
is 0public T getMinimum()
count
is 0public int getCount()
public T getMean()
getMeanValue()
.count
is 0public double getMeanValue()
public void reset()
public MathOperations<T> getMathOperations()
protected ReadWriteLock getLock()
protected void doReset()
reset()
is called. This method is called while the object is
locked for write and does work; therefore, the subclass should call this method.Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.