public abstract class AbstractSimpleStats extends java.lang.Object implements SampleStatistics, java.lang.Cloneable
This class contains a skeletal implementation for collecting new observations that tracks the minimum and maximum values, along with the number of observations. Classes extending AbstractSimpleStatistics will need to implement the logic for calculating the mean and standard deviation.
| Modifier and Type | Field and Description |
|---|---|
protected int |
count
The total number of observations recorded.
|
protected static java.lang.String |
DEFAULT_NAME
The default name for SampleStatistics.
|
static java.text.NumberFormat |
DEFAULT_NUMBER_FORMAT |
protected double |
maxObs
The largest observation recorded.
|
protected double |
minObs
The smallest observation recorded.
|
protected java.lang.String |
name
The name of the property that this SampleStatistic will collect
statistics on.
|
protected java.text.NumberFormat |
numberFormat
The DecimalFormat used for Strings.
|
EOL| Constructor and Description |
|---|
AbstractSimpleStats()
Creates a new instance with the default name "%unnamed%"
|
AbstractSimpleStats(java.lang.String name)
Creates a new instance with the given name.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Clone this instance
|
int |
getCount()
Gets the number of observations so far.
|
java.lang.String |
getDataLine()
Returns the data line consisting of the count, min, max, mean, variance,
and standard deviation.
|
double |
getMaxObs()
Gets the maximum observed value so far.
|
double |
getMinObs()
Gets the minimum observed value so far.
|
java.lang.String |
getName() |
void |
newObservation(boolean newObs)
Add a new Observation of type
boolean. |
void |
newObservation(java.lang.Boolean newObs)
Add a new Observation of type
Boolean. |
void |
newObservation(double newObs)
Add new observation and update counters (primitive).
|
void |
newObservation(java.lang.Number newObs)
Add new observation and update counters - normally will just call
newObservation(newObs.doubleValue()).
|
void |
propertyChange(java.beans.PropertyChangeEvent e)
If the PropertyChangeEvent contains the property this SampleStatistic is
associated with, record the value as a new observation.
|
void |
reset()
Should reset/initialize all relevant counters.
|
void |
setName(java.lang.String name) |
void |
setNumberFormat(java.text.NumberFormat numberFormat)
Sets the NumberFormat
|
void |
setSamplingType(SamplingType type)
Sets the sampling type to either TALLY or TIME_VARYING.
|
java.lang.String |
toString()
Return a String containing the Name, SamplingType, and the DataLine for
this SampleStatistic.
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetMean, getSamplingType, getStandardDeviation, getVarianceprotected static final java.lang.String DEFAULT_NAME
public static final java.text.NumberFormat DEFAULT_NUMBER_FORMAT
protected int count
protected double minObs
protected double maxObs
protected java.lang.String name
protected java.text.NumberFormat numberFormat
public AbstractSimpleStats()
public AbstractSimpleStats(java.lang.String name)
name - given namepublic double getMaxObs()
SampleStatisticsgetMaxObs in interface SampleStatisticspublic double getMinObs()
SampleStatisticsgetMinObs in interface SampleStatisticspublic int getCount()
SampleStatisticsgetCount in interface SampleStatisticspublic void reset()
SampleStatisticsreset in interface SampleStatisticspublic void newObservation(double newObs)
SampleStatisticsnewObservation in interface SampleStatisticsnewObs - The new (primitive) observationpublic void newObservation(java.lang.Number newObs)
newObservation in interface SampleStatisticsnewObs - The new (Number) observationpublic void propertyChange(java.beans.PropertyChangeEvent e)
If the name of the property is "reset" and the value of the property is the name of the property that this SampleStatistic is associated with, then reset this SampleStatistic.
propertyChange in interface java.beans.PropertyChangeListenere - Given PropertyChangeEventpublic void setSamplingType(SamplingType type)
SampleStatisticssetSamplingType in interface SampleStatisticstype - The SamplingType (TALLY or TIME_VARYING).public void setNumberFormat(java.text.NumberFormat numberFormat)
SampleStatisticssetNumberFormat in interface SampleStatisticsnumberFormat - the new DecimalFormat instancepublic void newObservation(java.lang.Boolean newObs)
SampleStatisticsBoolean. It is expected that
"true" corresponds to '1' and "false" to 0.newObservation in interface SampleStatisticsnewObs - the Boolean observationpublic void newObservation(boolean newObs)
boolean. It is expected that
"true" corresponds to '1' and "false" to 0.newObservation in interface SampleStatisticsnewObs - the boolean observationpublic java.lang.String getName()
getName in interface NamedgetName in interface SampleStatisticspublic void setName(java.lang.String name)
setName in interface NamedsetName in interface SampleStatisticsname - The new name of the Object.public java.lang.Object clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectgetDataLine()public java.lang.String getDataLine()