uk.ac.liv.util
Class CummulativeDistribution

java.lang.Object
  extended byuk.ac.liv.util.CummulativeDistribution
All Implemented Interfaces:
java.lang.Cloneable, Distribution, Resetable, java.io.Serializable
Direct Known Subclasses:
HeavyweightDistribution

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

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

Example usage:

CummulativeStatCounter series1 = new CummulativeStatCounter("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());

Version:
$Revision: 1.2 $
Author:
Steve Phelps
See Also:
Serialized Form

Field Summary
protected  double max
          The maximum so far.
protected  double min
          The minimum so far.
protected  int n
          The number of data in the series so far.
protected  double total
          The cummulative total of all numbers in the series so far.
protected  double totalSq
          The square of the total.
protected  java.lang.String varName
          The name of this series.
 
Constructor Summary
CummulativeDistribution()
           
CummulativeDistribution(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 series.
 java.lang.String getName()
           
 double getStdDev()
          Get the standard deviation from the mean.
 double getStdDev(double origin)
          Get the standard deviation of the data about origin.
 double getTotal()
          Get the total of the data
 double getTrimmedMean(double p)
           
 double getVarCoef(double origin)
          Get the coefficient of variable about origin.
 double getVariance()
          Get the variance about the mean.
 double getVariance(double origin)
          Get the variance of the data about origin.
 void initialise()
           
 void log()
           
 void newData(double i)
          Add a new datum to the series.
 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

n

protected int n
The number of data in the series so far.


total

protected double total
The cummulative total of all numbers in the series so far.


totalSq

protected double totalSq
The square of the total.


min

protected double min
The minimum so far.


max

protected double max
The maximum so far.


varName

protected java.lang.String varName
The name of this series.

Constructor Detail

CummulativeDistribution

public CummulativeDistribution(java.lang.String varName)

CummulativeDistribution

public CummulativeDistribution()
Method Detail

initialise

public void initialise()

newData

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

Specified by:
newData in interface Distribution

getN

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

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(double origin)
Get the variance of the data about origin.

Specified by:
getVariance in interface Distribution

getStdDev

public double getStdDev(double origin)
Get the standard deviation of the data about origin.

Specified by:
getStdDev 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

getVarCoef

public double getVarCoef(double origin)
Get the coefficient of variable about origin.

Specified by:
getVarCoef 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
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

toString

public java.lang.String toString()

log

public void log()
Specified by:
log in interface Distribution

getTrimmedMean

public double getTrimmedMean(double p)
Specified by:
getTrimmedMean in interface Distribution