Class Statistic

java.lang.Object
  extended by Statistic
Direct Known Subclasses:
WeightedStatistic

public class Statistic
extends java.lang.Object

Abstract data type to collect values and provide certain statistical properties of the collection.


Field Summary
protected  double currentValue
           
protected  double highestValue
           
protected  double lowestValue
           
protected  int numSamples
           
protected  java.lang.String statisticName
           
protected  double sumOfValues
           
protected  double sumsqOfValues
           
 
Constructor Summary
Statistic(java.lang.String name)
          Constructor
 
Method Summary
 void collect(double value)
          Adds a value to the statistic collection
 int count()
          Retrieves the count of how many values collected so far
 double current()
          Retrieves the most recent value collected
 double highest()
          Retrieves the highest value collected so far
 double lowest()
          Retrieves the lowest value collected so far
 double mean()
          Retrieves the mean (average) of the values collected so far
 java.lang.String name()
          Retrieves the name given to the Statistic object
 double standardDeviation()
          Retrieves the standard deviation of the values collected so far
 double sum()
          Retrieves the sum of the values collected so far
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numSamples

protected int numSamples

sumOfValues

protected double sumOfValues

sumsqOfValues

protected double sumsqOfValues

lowestValue

protected double lowestValue

highestValue

protected double highestValue

currentValue

protected double currentValue

statisticName

protected java.lang.String statisticName
Constructor Detail

Statistic

public Statistic(java.lang.String name)
Constructor

Parameters:
name - String with descriptive name for this object
Method Detail

name

public java.lang.String name()
Retrieves the name given to the Statistic object

Returns:
the name as a String

lowest

public double lowest()
Retrieves the lowest value collected so far

Returns:
lowest value

highest

public double highest()
Retrieves the highest value collected so far

Returns:
highest value

current

public double current()
Retrieves the most recent value collected

Returns:
current value

sum

public double sum()
Retrieves the sum of the values collected so far

Returns:
the sum

count

public int count()
Retrieves the count of how many values collected so far

Returns:
the count

mean

public double mean()
Retrieves the mean (average) of the values collected so far

Returns:
the mean

standardDeviation

public double standardDeviation()
Retrieves the standard deviation of the values collected so far

Returns:
the standard deviation

collect

public void collect(double value)
Adds a value to the statistic collection

Parameters:
value - the value to be sampled
Postcondition:
statistic object is updated to reflect addition of new value