org.apache.commons.math.stat.descriptive
Class AbstractStorelessUnivariateStatistic
java.lang.Object
org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic
org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic
- All Implemented Interfaces:
- java.io.Serializable, StorelessUnivariateStatistic, UnivariateStatistic
- Direct Known Subclasses:
- FirstMoment, GeometricMean, Kurtosis, Max, Mean, Min, Product, Skewness, StandardDeviation, Sum, SumOfLogs, SumOfSquares, Variance
- public abstract class AbstractStorelessUnivariateStatistic
- extends AbstractUnivariateStatistic
- implements StorelessUnivariateStatistic, java.io.Serializable
Abstract Implementation for the StorelessUnivariateStatistic
interface.
Provides default evaluate()
and incrementAll(double[])
implementations.
Note that these implementations are not synchronized.
- Version:
- $Revision: 1.1 $ $Date: 2004/10/08 05:08:17 $
- See Also:
- Serialized Form
Method Summary |
abstract void |
clear()
Clears the internal state of the Statistic |
boolean |
equals(java.lang.Object object)
Returns true iff object is an
AbstractStorelessUnivariateStatistic returning the same
values as this for getResult() and getN() |
double |
evaluate(double[] values)
This default implementation calls clear() , then invokes
increment(double) in a loop over the the input array, and then uses
getResult() to compute the return value. |
double |
evaluate(double[] values,
int begin,
int length)
This default implementation calls clear() , then invokes
increment(double) in a loop over the specified portion of the input
array, and then uses getResult() to compute the return value. |
abstract double |
getResult()
Returns the current value of the Statistic. |
int |
hashCode()
Returns hash code based on getResult() and getN() |
abstract void |
increment(double d)
Updates the internal state of the statistic to reflect the addition of the new value. |
void |
incrementAll(double[] values)
This default implementation just calls increment(double) in a loop over
the input array. |
void |
incrementAll(double[] values,
int begin,
int length)
This default implementation just calls increment(double) in a loop over
the specified portion of the input array. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
static final long serialVersionUID
- Serialization UID
- See Also:
- Constant Field Values
AbstractStorelessUnivariateStatistic
public AbstractStorelessUnivariateStatistic()
evaluate
public double evaluate(double[] values)
- This default implementation calls
clear()
, then invokes
increment(double)
in a loop over the the input array, and then uses
getResult()
to compute the return value.
Note that this implementation changes the internal state of the
statistic. Its side effects are the same as invoking clear()
and
then incrementAll(double[])
.
Implementations may override this method with a more efficient
implementation that works directly with the input array.
If the array is null, an IllegalArgumentException is thrown.
- Specified by:
evaluate
in interface UnivariateStatistic
- Overrides:
evaluate
in class AbstractUnivariateStatistic
- See Also:
UnivariateStatistic.evaluate(double[])
evaluate
public double evaluate(double[] values,
int begin,
int length)
- This default implementation calls
clear()
, then invokes
increment(double)
in a loop over the specified portion of the input
array, and then uses getResult()
to compute the return value.
Note that this implementation changes the internal state of the
statistic. Its side effects are the same as invoking clear()
and
then incrementAll(double[], int, int)
.
Implementations may override this method with a more efficient
implementation that works directly with the input array.
If the array is null or the index parameters are not valid, an
IllegalArgumentException is thrown.
- Specified by:
evaluate
in interface UnivariateStatistic
- Specified by:
evaluate
in class AbstractUnivariateStatistic
- See Also:
UnivariateStatistic.evaluate(double[], int, int)
clear
public abstract void clear()
- Description copied from interface:
StorelessUnivariateStatistic
- Clears the internal state of the Statistic
- Specified by:
clear
in interface StorelessUnivariateStatistic
- See Also:
StorelessUnivariateStatistic.clear()
getResult
public abstract double getResult()
- Description copied from interface:
StorelessUnivariateStatistic
- Returns the current value of the Statistic.
- Specified by:
getResult
in interface StorelessUnivariateStatistic
- Returns:
- value of the statistic,
Double.NaN
if it
has been cleared or just instantiated. - See Also:
StorelessUnivariateStatistic.getResult()
increment
public abstract void increment(double d)
- Description copied from interface:
StorelessUnivariateStatistic
- Updates the internal state of the statistic to reflect the addition of the new value.
- Specified by:
increment
in interface StorelessUnivariateStatistic
- Parameters:
d
- the new value.- See Also:
StorelessUnivariateStatistic.increment(double)
incrementAll
public void incrementAll(double[] values)
- This default implementation just calls
increment(double)
in a loop over
the input array.
Throws IllegalArgumentException if the input values array is null.
- Specified by:
incrementAll
in interface StorelessUnivariateStatistic
- Parameters:
values
- values to add
- Throws:
java.lang.IllegalArgumentException
- if values is null- See Also:
StorelessUnivariateStatistic.incrementAll(double[])
incrementAll
public void incrementAll(double[] values,
int begin,
int length)
- This default implementation just calls
increment(double)
in a loop over
the specified portion of the input array.
Throws IllegalArgumentException if the input values array is null.
- Specified by:
incrementAll
in interface StorelessUnivariateStatistic
- Parameters:
values
- array holding values to addbegin
- index of the first array element to addlength
- number of array elements to add
- Throws:
java.lang.IllegalArgumentException
- if values is null- See Also:
StorelessUnivariateStatistic.incrementAll(double[], int, int)
equals
public boolean equals(java.lang.Object object)
- Returns true iff
object
is an
AbstractStorelessUnivariateStatistic
returning the same
values as this for getResult()
and getN()
- Parameters:
object
- object to test equality against.
- Returns:
- true if object returns the same value as this
hashCode
public int hashCode()
- Returns hash code based on getResult() and getN()
- Returns:
- hash code