net.sourceforge.jabm.util
Class SummaryStats

java.lang.Object
  extended by net.sourceforge.jabm.util.SummaryStats
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Distribution, Resetable

public class SummaryStats
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, Resetable, Distribution

A utility class for cumulative tracking of stats for a set of doubles. Moments are incremented dynamically, rather than keeping the actual cases in memory.

Example usage:

Distribution series1 = new SummaryStats("series1");
series1.newData(4.5);
series1.newData(5.6);
series1.newData(9.0);
System.out.println("Standard deviation of series1 = " + series1.getStdDev());
series1.newData(5.56);
series1.newData(12);
System.out.println("And now the standard deviation = " + series1.getStdDev());

See Also:
Serialized Form
 

Field Summary
protected  org.apache.commons.math3.stat.descriptive.SummaryStatistics stats
           
protected  java.lang.String varName
          The name of this data set.
 
Constructor Summary
SummaryStats()
           
SummaryStats(java.lang.String varName)
           
 
Method Summary
 java.lang.Object clone()
           
 double getMax()
          Get the maximum datum.
 double getMean()
          Get the mean of the data.
 double getMin()
          Get the minimum datum.
 int getN()
          Get the number of items in the set.
 java.lang.String getName()
           
 double getStdDev()
          Get the standard deviation from the mean.
 double getTotal()
          Get the total of the data
 double getVariance()
          Get the variance about the mean.
 void initialise()
           
 void log()
          Output the moments of the distribution to the info log.
 void newData(double i)
          Add a new datum to the set.
 void reset()
          Reinitialise our state to the original settings.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stats

protected org.apache.commons.math3.stat.descriptive.SummaryStatistics stats

varName

protected java.lang.String varName
The name of this data set.

Constructor Detail

SummaryStats

public SummaryStats(java.lang.String varName)

SummaryStats

public SummaryStats()
Method Detail

initialise

public void initialise()

newData

public void newData(double i)
Add a new datum to the set.

Specified by:
newData in interface Distribution

getN

public int getN()
Get the number of items in the set.

Specified by:
getN in interface Distribution

getMean

public double getMean()
Get the mean of the data.

Specified by:
getMean in interface Distribution

getVariance

public double getVariance()
Get the variance about the mean.

Specified by:
getVariance in interface Distribution

getStdDev

public double getStdDev()
Get the standard deviation from the mean.

Specified by:
getStdDev in interface Distribution

getMin

public double getMin()
Get the minimum datum.

Specified by:
getMin in interface Distribution

getMax

public double getMax()
Get the maximum datum.

Specified by:
getMax in interface Distribution

getTotal

public double getTotal()
Get the total of the data

Specified by:
getTotal in interface Distribution

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

reset

public void reset()
Description copied from interface: Resetable
Reinitialise our state to the original settings.

Specified by:
reset in interface Resetable

getName

public java.lang.String getName()
Specified by:
getName in interface Distribution
Returns:
The name of the variable.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

log

public void log()
Description copied from interface: Distribution
Output the moments of the distribution to the info log.

Specified by:
log in interface Distribution