org.apache.commons.math.stat
Class StorelessDescriptiveStatisticsImpl

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

public class StorelessDescriptiveStatisticsImpl
extends AbstractStorelessDescriptiveStatistics
implements Serializable

Accumulates univariate statistics for values fed in through the addValue() method. Does not store raw data values. All data are represented internally as doubles. Integers, floats and longs can be added, but they will be converted to doubles by addValue().

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

Field Summary
 
Fields inherited from class org.apache.commons.math.stat.AbstractStorelessDescriptiveStatistics
geoMean, kurtosis, max, mean, min, moment, n, skewness, sum, sumLog, sumsq, variance, windowSize
 
Fields inherited from class org.apache.commons.math.stat.DescriptiveStatistics
INFINITE_WINDOW, LEPTOKURTIC, MESOKURTIC, PLATYKURTIC
 
Constructor Summary
StorelessDescriptiveStatisticsImpl()
          Creates new univariate with an infinite window
StorelessDescriptiveStatisticsImpl(int window)
          Creates a new univariate with a fixed window
 
Method Summary
 void addValue(double value)
          If windowSize is set to Infinite, moments are calculated using the following recursive strategy .
 double apply(UnivariateStatistic stat)
          Apply the given statistic to this univariate collection.
 void clear()
          Resets all statistics and storage
 double getElement(int index)
          Returns the element at the specified index
 double getPercentile(double p)
          Returns an estimate for the pth percentile of the stored values.
 double[] getSortedValues()
          Returns the current set of values in an array of double primitives, sorted in ascending order.
 double[] getValues()
          Returns the current set of values in an array of double primitives.
 String toString()
          Generates a text report displaying univariate statistics from values that have been added.
 
Methods inherited from class org.apache.commons.math.stat.AbstractStorelessDescriptiveStatistics
getGeometricMean, getKurtosis, getKurtosisClass, getMax, getMean, getMin, getN, getSkewness, getStandardDeviation, getSum, getSumsq, getVariance, getWindowSize, setWindowSize
 
Methods inherited from class org.apache.commons.math.stat.DescriptiveStatistics
newInstance, newInstance, newInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StorelessDescriptiveStatisticsImpl

public StorelessDescriptiveStatisticsImpl()
Creates new univariate with an infinite window


StorelessDescriptiveStatisticsImpl

public StorelessDescriptiveStatisticsImpl(int window)
Creates a new univariate with a fixed window

Parameters:
window - Window Size
Method Detail

addValue

public void addValue(double value)
If windowSize is set to Infinite, moments are calculated using the following recursive strategy . Otherwise, stat methods delegate to StatUtils.

Specified by:
addValue in class AbstractStorelessDescriptiveStatistics
See Also:
org.apache.commons.math.stat.Univariate#addValue(double)

toString

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

Overrides:
toString in class AbstractStorelessDescriptiveStatistics
Returns:
String with line feeds displaying statistics

clear

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

Overrides:
clear in class AbstractStorelessDescriptiveStatistics
See Also:
org.apache.commons.math.stat.Univariate#clear()

apply

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

Specified by:
apply in class AbstractStorelessDescriptiveStatistics
Parameters:
stat - the statistic to apply
Returns:
the computed value of the statistic.

getValues

public double[] getValues()
Description copied from class: DescriptiveStatistics
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.

Specified by:
getValues in class DescriptiveStatistics
Returns:
returns the current set of numbers in the order in which they were added to this set

getSortedValues

public double[] getSortedValues()
Description copied from class: DescriptiveStatistics
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.

Specified by:
getSortedValues in class DescriptiveStatistics
Returns:
returns the current set of numbers sorted in ascending order

getElement

public double getElement(int index)
Description copied from class: DescriptiveStatistics
Returns the element at the specified index

Specified by:
getElement in class DescriptiveStatistics
Parameters:
index - The Index of the element
Returns:
return the element at the specified index

getPercentile

public double getPercentile(double p)
Description copied from class: DescriptiveStatistics
Returns an estimate for the pth percentile of the stored values. This estimate follows the interpolation-adjusted defintion presented here

Preconditions:

Specified by:
getPercentile in class DescriptiveStatistics
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.