org.apache.commons.math.stat
Class AbstractStorelessDescriptiveStatistics

java.lang.Object
  extended byorg.apache.commons.math.stat.DescriptiveStatistics
      extended byorg.apache.commons.math.stat.AbstractStorelessDescriptiveStatistics
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AbstractDescriptiveStatistics, StorelessDescriptiveStatisticsImpl

public abstract class AbstractStorelessDescriptiveStatistics
extends DescriptiveStatistics

Provides univariate measures for an array of doubles.

Version:
$Revision: 1.1 $ $Date: 2003/11/15 16:01:37 $
See Also:
Serialized Form

Field Summary
protected  GeometricMean geoMean
          geoMean of values that have been added
protected  Kurtosis kurtosis
          kurtosis of values that have been added
protected  Max max
          max of values that have been added
protected  Mean mean
          mean of values that have been added
protected  Min min
          min of values that have been added
protected  FourthMoment moment
          FourthMoment is used in calculating mean, variance,skew and kurtosis
protected  int n
          count of values that have been added
protected  Skewness skewness
          skewness of values that have been added
protected  Sum sum
          sum of values that have been added
protected  SumOfLogs sumLog
          sumLog of values that have been added
protected  SumOfSquares sumsq
          sum of the square of each value that has been added
protected  Variance variance
          variance of values that have been added
protected  int windowSize
          hold the window size
 
Fields inherited from class org.apache.commons.math.stat.DescriptiveStatistics
INFINITE_WINDOW, LEPTOKURTIC, MESOKURTIC, PLATYKURTIC
 
Constructor Summary
AbstractStorelessDescriptiveStatistics()
          Construct an AbstractStorelessDescriptiveStatistics
AbstractStorelessDescriptiveStatistics(int window)
          Construct an AbstractStorelessDescriptiveStatistics with a window
 
Method Summary
abstract  void addValue(double value)
          If windowSize is set to Infinite, statistics are calculated using the following recursive strategy .
abstract  double apply(UnivariateStatistic stat)
          Apply the given statistic to this univariate collection.
 void clear()
          Resets all statistics and storage
 double getGeometricMean()
          Returns the geometric mean of the available values
 double getKurtosis()
          Returns the kurtosis of the values that have been added as described by Equation (7) for k-Statistics.
 int getKurtosisClass()
          Returns the Kurtosis "classification" a distribution can be leptokurtic (high peak), platykurtic (flat peak), or mesokurtic (zero kurtosis).
 double getMax()
          Returns the maximum of the available values
 double getMean()
          Returns the arithmetic mean of the available values
 double getMin()
          Returns the minimum of the available values
 int getN()
          Returns the number of available values
 double getSkewness()
          Returns the skewness of the values that have been added as described by Equation (6) for k-Statistics.
 double getStandardDeviation()
          Returns the standard deviation for this collection of values
 double getSum()
          Returns the sum of the values that have been added to Univariate.
 double getSumsq()
          Returns the sum of the squares of the available values.
 double getVariance()
          Returns the variance of the values that have been added via West's algorithm as described by Chan, T.
 int getWindowSize()
          Univariate has the ability to return only measures for the last N elements added to the set of values.
 void setWindowSize(int windowSize)
          WindowSize controls the number of values which contribute to the values returned by Univariate.
 String toString()
          Generates a text report displaying univariate statistics from values that have been added.
 
Methods inherited from class org.apache.commons.math.stat.DescriptiveStatistics
getElement, getPercentile, getSortedValues, getValues, newInstance, newInstance, newInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

windowSize

protected int windowSize
hold the window size


n

protected int n
count of values that have been added


moment

protected FourthMoment moment
FourthMoment is used in calculating mean, variance,skew and kurtosis


sum

protected Sum sum
sum of values that have been added


sumsq

protected SumOfSquares sumsq
sum of the square of each value that has been added


min

protected Min min
min of values that have been added


max

protected Max max
max of values that have been added


sumLog

protected SumOfLogs sumLog
sumLog of values that have been added


geoMean

protected GeometricMean geoMean
geoMean of values that have been added


mean

protected Mean mean
mean of values that have been added


variance

protected Variance variance
variance of values that have been added


skewness

protected Skewness skewness
skewness of values that have been added


kurtosis

protected Kurtosis kurtosis
kurtosis of values that have been added

Constructor Detail

AbstractStorelessDescriptiveStatistics

public AbstractStorelessDescriptiveStatistics()
Construct an AbstractStorelessDescriptiveStatistics


AbstractStorelessDescriptiveStatistics

public AbstractStorelessDescriptiveStatistics(int window)
Construct an AbstractStorelessDescriptiveStatistics with a window

Parameters:
window - The Window Size
Method Detail

apply

public abstract double apply(UnivariateStatistic stat)
Apply the given statistic to this univariate collection.

Parameters:
stat - the statistic to apply
Returns:
the computed value of the statistic.

addValue

public abstract void addValue(double value)
If windowSize is set to Infinite, statistics are calculated using the following recursive strategy .

Specified by:
addValue in class DescriptiveStatistics
Parameters:
value - the value to be added
See Also:
org.apache.commons.math.stat.Univariate#addValue(double)

getN

public int getN()
Description copied from class: DescriptiveStatistics
Returns the number of available values

Specified by:
getN in class DescriptiveStatistics
Returns:
The number of available values
See Also:
org.apache.commons.math.stat.Univariate#getN()

getSum

public double getSum()
Description copied from class: DescriptiveStatistics
Returns the sum of the values that have been added to Univariate.

Specified by:
getSum in class DescriptiveStatistics
Returns:
The sum or Double.NaN if no values have been added
See Also:
org.apache.commons.math.stat.Univariate#getSum()

getSumsq

public double getSumsq()
Description copied from class: DescriptiveStatistics
Returns the sum of the squares of the available values.

Specified by:
getSumsq in class DescriptiveStatistics
Returns:
The sum of the squares or Double.NaN if no values have been added.
See Also:
org.apache.commons.math.stat.Univariate#getSumsq()

getMean

public double getMean()
Description copied from class: DescriptiveStatistics
Returns the arithmetic mean of the available values

Specified by:
getMean in class DescriptiveStatistics
Returns:
The mean or Double.NaN if no values have been added.
See Also:
org.apache.commons.math.stat.Univariate#getMean()

getStandardDeviation

public double getStandardDeviation()
Returns the standard deviation for this collection of values

Specified by:
getStandardDeviation in class DescriptiveStatistics
Returns:
The standard deviation, Double.NaN if no values have been added or 0.0 for a single value set.
See Also:
org.apache.commons.math.stat.Univariate#getStandardDeviation()

getVariance

public double getVariance()
Returns the variance of the values that have been added via West's algorithm as described by Chan, T. F. and J. G. Lewis 1979, Communications of the ACM, vol. 22 no. 9, pp. 526-531..

Specified by:
getVariance in class DescriptiveStatistics
Returns:
The variance of a set of values. Double.NaN is returned for an empty set of values and 0.0 is returned for a <= 1 value set.

getSkewness

public double getSkewness()
Returns the skewness of the values that have been added as described by Equation (6) for k-Statistics.

Specified by:
getSkewness in class DescriptiveStatistics
Returns:
The skew of a set of values. Double.NaN is returned for an empty set of values and 0.0 is returned for a <= 2 value set.

getKurtosis

public double getKurtosis()
Returns the kurtosis of the values that have been added as described by Equation (7) for k-Statistics.

Specified by:
getKurtosis in class DescriptiveStatistics
Returns:
The kurtosis of a set of values. Double.NaN is returned for an empty set of values and 0.0 is returned for a <= 3 value set.

getKurtosisClass

public int getKurtosisClass()
Description copied from class: DescriptiveStatistics
Returns the Kurtosis "classification" a distribution can be leptokurtic (high peak), platykurtic (flat peak), or mesokurtic (zero kurtosis).

Specified by:
getKurtosisClass in class DescriptiveStatistics
Returns:
A static constant defined in this interface, StoredDeviation.LEPTOKURITC, StoredDeviation.PLATYKURTIC, or StoredDeviation.MESOKURTIC
See Also:
DescriptiveStatistics.getKurtosisClass()

getMax

public double getMax()
Description copied from class: DescriptiveStatistics
Returns the maximum of the available values

Specified by:
getMax in class DescriptiveStatistics
Returns:
The max or Double.NaN if no values have been added.
See Also:
org.apache.commons.math.stat.Univariate#getMax()

getMin

public double getMin()
Description copied from class: DescriptiveStatistics
Returns the minimum of the available values

Specified by:
getMin in class DescriptiveStatistics
Returns:
The min or Double.NaN if no values have been added.
See Also:
org.apache.commons.math.stat.Univariate#getMin()

getGeometricMean

public double getGeometricMean()
Description copied from class: DescriptiveStatistics
Returns the geometric mean of the available values

Specified by:
getGeometricMean in class DescriptiveStatistics
Returns:
The geometricMean, Double.NaN if no values have been added, or if the productof the available values is less than or equal to 0.
See Also:
org.apache.commons.math.stat.Univariate#getGeometricMean()

toString

public String toString()
Generates a text report displaying univariate statistics from values that have been added.

Returns:
String with line feeds displaying statistics

clear

public void clear()
Description copied from class: DescriptiveStatistics
Resets all statistics and storage

Specified by:
clear in class DescriptiveStatistics
See Also:
org.apache.commons.math.stat.Univariate#clear()

getWindowSize

public int getWindowSize()
Description copied from class: DescriptiveStatistics
Univariate has the ability to return only measures for the last N elements added to the set of values.

Specified by:
getWindowSize in class DescriptiveStatistics
Returns:
The current window size or -1 if its Infinite.
See Also:
org.apache.commons.math.stat.Univariate#getWindowSize()

setWindowSize

public void setWindowSize(int windowSize)
Description copied from class: DescriptiveStatistics
WindowSize controls the number of values which contribute to the values returned by Univariate. For example, if windowSize is set to 3 and the values {1,2,3,4,5} have been added in that order then the available values are {3,4,5} and all reported statistics will be based on these values

Specified by:
setWindowSize in class DescriptiveStatistics
Parameters:
windowSize - sets the size of the window.
See Also:
org.apache.commons.math.stat.Univariate#setWindowSize(int)


Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.