org.apache.commons.math.stat
Class DescriptiveStatistics

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

public abstract class DescriptiveStatistics
extends Object
implements Serializable

DescriptiveStatistics implements the Univariate interface but maintains the set of values which contribute to the values being returned. This implementation of Univariate provides additional percentile functionality such as. This additional functionality comes with a price of increased storage costs.

Version:
$Revision: 1.2 $ $Date: 2003/11/19 03:28:23 $
See Also:
Serialized Form

Field Summary
static int INFINITE_WINDOW
          This constant signals that a Univariate implementation takes into account the contributions of an infinite number of elements.
static int LEPTOKURTIC
          A LEPTOKURTIC set has a positive kurtosis (a high peak)
static int MESOKURTIC
          A MESOKURTIC set has a kurtosis of 0 - it is a normal distribution
static int PLATYKURTIC
          A PLATYKURTIC set has a negative kurtosis (a flat "peak")
 
Constructor Summary
DescriptiveStatistics()
           
 
Method Summary
abstract  void addValue(double v)
          Adds the value to the set of numbers
abstract  void clear()
          Resets all statistics and storage
abstract  double getElement(int index)
          Returns the element at the specified index
abstract  double getGeometricMean()
          Returns the geometric mean of the available values
abstract  double getKurtosis()
          Returns the Kurtosis of the available values.
abstract  int getKurtosisClass()
          Returns the Kurtosis "classification" a distribution can be leptokurtic (high peak), platykurtic (flat peak), or mesokurtic (zero kurtosis).
abstract  double getMax()
          Returns the maximum of the available values
abstract  double getMean()
          Returns the arithmetic mean of the available values
abstract  double getMin()
          Returns the minimum of the available values
abstract  int getN()
          Returns the number of available values
abstract  double getPercentile(double p)
          Returns an estimate for the pth percentile of the stored values.
abstract  double getSkewness()
          Returns the skewness of the available values.
abstract  double[] getSortedValues()
          Returns the current set of values in an array of double primitives, sorted in ascending order.
abstract  double getStandardDeviation()
          Returns the standard deviation of the available values.
abstract  double getSum()
          Returns the sum of the values that have been added to Univariate.
abstract  double getSumsq()
          Returns the sum of the squares of the available values.
abstract  double[] getValues()
          Returns the current set of values in an array of double primitives.
abstract  double getVariance()
          Returns the variance of the available values.
abstract  int getWindowSize()
          Univariate has the ability to return only measures for the last N elements added to the set of values.
static DescriptiveStatistics newInstance()
          Create an instance of a DescriptiveStatistics
static DescriptiveStatistics newInstance(Class cls)
          Create an instance of a DescriptiveStatistics
static DescriptiveStatistics newInstance(String cls)
          Create an instance of a DescriptiveStatistics
abstract  void setWindowSize(int windowSize)
          WindowSize controls the number of values which contribute to the values returned by Univariate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFINITE_WINDOW

public static final int INFINITE_WINDOW
This constant signals that a Univariate implementation takes into account the contributions of an infinite number of elements. In other words, if getWindow returns this constant, there is, in effect, no "window".

See Also:
Constant Field Values

LEPTOKURTIC

public static int LEPTOKURTIC
A LEPTOKURTIC set has a positive kurtosis (a high peak)


MESOKURTIC

public static int MESOKURTIC
A MESOKURTIC set has a kurtosis of 0 - it is a normal distribution


PLATYKURTIC

public static int PLATYKURTIC
A PLATYKURTIC set has a negative kurtosis (a flat "peak")

Constructor Detail

DescriptiveStatistics

public DescriptiveStatistics()
Method Detail

newInstance

public static DescriptiveStatistics newInstance(String cls)
                                         throws InstantiationException,
                                                IllegalAccessException,
                                                ClassNotFoundException
Create an instance of a DescriptiveStatistics

Returns:
a new factory.
Throws:
InstantiationException
IllegalAccessException
ClassNotFoundException

newInstance

public static DescriptiveStatistics newInstance(Class cls)
                                         throws InstantiationException,
                                                IllegalAccessException
Create an instance of a DescriptiveStatistics

Returns:
a new factory.
Throws:
InstantiationException
IllegalAccessException

newInstance

public static DescriptiveStatistics newInstance()
Create an instance of a DescriptiveStatistics

Returns:
a new factory.

addValue

public abstract void addValue(double v)
Adds the value to the set of numbers

Parameters:
v - the value to be added

getMean

public abstract double getMean()
Returns the arithmetic mean of the available values

Returns:
The mean or Double.NaN if no values have been added.

getGeometricMean

public abstract double getGeometricMean()
Returns the geometric mean of the available values

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.

getVariance

public abstract double getVariance()
Returns the variance of the available values.

Returns:
The variance, Double.NaN if no values have been added or 0.0 for a single value set.

getStandardDeviation

public abstract double getStandardDeviation()
Returns the standard deviation of the available values.

Returns:
The standard deviation, Double.NaN if no values have been added or 0.0 for a single value set.

getSkewness

public abstract double getSkewness()
Returns the skewness of the available values. Skewness is a measure of the assymetry of a given distribution.

Returns:
The skewness, Double.NaN if no values have been added or 0.0 for a value set <=2.

getKurtosis

public abstract double getKurtosis()
Returns the Kurtosis of the available values. Kurtosis is a measure of the "peakedness" of a distribution

Returns:
The kurtosis, Double.NaN if no values have been added, or 0.0 for a value set <=3.

getKurtosisClass

public abstract int getKurtosisClass()
Returns the Kurtosis "classification" a distribution can be leptokurtic (high peak), platykurtic (flat peak), or mesokurtic (zero kurtosis).

Returns:
A static constant defined in this interface, StoredDeviation.LEPTOKURITC, StoredDeviation.PLATYKURTIC, or StoredDeviation.MESOKURTIC

getMax

public abstract double getMax()
Returns the maximum of the available values

Returns:
The max or Double.NaN if no values have been added.

getMin

public abstract double getMin()
Returns the minimum of the available values

Returns:
The min or Double.NaN if no values have been added.

getN

public abstract int getN()
Returns the number of available values

Returns:
The number of available values

getSum

public abstract double getSum()
Returns the sum of the values that have been added to Univariate.

Returns:
The sum or Double.NaN if no values have been added

getSumsq

public abstract double getSumsq()
Returns the sum of the squares of the available values.

Returns:
The sum of the squares or Double.NaN if no values have been added.

clear

public abstract void clear()
Resets all statistics and storage


getWindowSize

public abstract int getWindowSize()
Univariate has the ability to return only measures for the last N elements added to the set of values.

Returns:
The current window size or -1 if its Infinite.

setWindowSize

public abstract void setWindowSize(int windowSize)
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

Parameters:
windowSize - sets the size of the window.

getValues

public abstract double[] getValues()
Returns the current set of values in an array of double primitives. The order of addition is preserved. The returned array is a fresh copy of the underlying data -- i.e., it is not a reference to the stored data.

Returns:
returns the current set of numbers in the order in which they were added to this set

getSortedValues

public abstract double[] getSortedValues()
Returns the current set of values in an array of double primitives, sorted in ascending order. The returned array is a fresh copy of the underlying data -- i.e., it is not a reference to the stored data.

Returns:
returns the current set of numbers sorted in ascending order

getElement

public abstract double getElement(int index)
Returns the element at the specified index

Parameters:
index - The Index of the element
Returns:
return the element at the specified index

getPercentile

public abstract double getPercentile(double p)
Returns an estimate for the pth percentile of the stored values. This estimate follows the interpolation-adjusted defintion presented here

Preconditions:

Parameters:
p - the requested percentile (scaled from 0 - 100)
Returns:
An estimate for the pth percentile of the stored data values


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