Class AbstractStorelessUnivariateStatistic
- java.lang.Object
-
- org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic
-
- org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic
-
- All Implemented Interfaces:
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
Abstract implementation of theStorelessUnivariateStatistic
interface.Provides default
evaluate()
andincrementAll(double[])
implementations.
Note that these implementations are not synchronized.
-
-
Constructor Summary
Constructors Constructor Description AbstractStorelessUnivariateStatistic()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
clear()
Clears the internal state of the Statisticabstract StorelessUnivariateStatistic
copy()
Returns a copy of the statistic with the same internal state.boolean
equals(java.lang.Object object)
Returns true iffobject
is anAbstractStorelessUnivariateStatistic
returning the same values as this forgetResult()
andgetN()
double
evaluate(double[] values)
This default implementation callsclear()
, then invokesincrement(double)
in a loop over the the input array, and then usesgetResult()
to compute the return value.double
evaluate(double[] values, int begin, int length)
This default implementation callsclear()
, then invokesincrement(double)
in a loop over the specified portion of the input array, and then usesgetResult()
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 callsincrement(double)
in a loop over the input array.void
incrementAll(double[] values, int begin, int length)
This default implementation just callsincrement(double)
in a loop over the specified portion of the input array.-
Methods inherited from class org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic
evaluate, getData, setData, setData
-
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic
getN
-
-
-
-
Method Detail
-
evaluate
public double evaluate(double[] values)
This default implementation callsclear()
, then invokesincrement(double)
in a loop over the the input array, and then usesgetResult()
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 thenincrementAll(double[])
.Implementations may override this method with a more efficient and possibly more accurate implementation that works directly with the input array.
If the array is null, an IllegalArgumentException is thrown.
- Specified by:
evaluate
in interfaceUnivariateStatistic
- Overrides:
evaluate
in classAbstractUnivariateStatistic
- Parameters:
values
- input array- Returns:
- the value of the statistic applied to the input array
- See Also:
UnivariateStatistic.evaluate(double[])
-
evaluate
public double evaluate(double[] values, int begin, int length)
This default implementation callsclear()
, then invokesincrement(double)
in a loop over the specified portion of the input array, and then usesgetResult()
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 thenincrementAll(double[], int, int)
.Implementations may override this method with a more efficient and possibly more accurate 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 interfaceUnivariateStatistic
- Specified by:
evaluate
in classAbstractUnivariateStatistic
- Parameters:
values
- the input arraybegin
- the index of the first element to includelength
- the number of elements to include- Returns:
- the value of the statistic applied to the included array entries
- See Also:
UnivariateStatistic.evaluate(double[], int, int)
-
copy
public abstract StorelessUnivariateStatistic copy()
Returns a copy of the statistic with the same internal state.- Specified by:
copy
in interfaceStorelessUnivariateStatistic
- Specified by:
copy
in interfaceUnivariateStatistic
- Specified by:
copy
in classAbstractUnivariateStatistic
- Returns:
- a copy of the statistic
-
clear
public abstract void clear()
Clears the internal state of the Statistic- Specified by:
clear
in interfaceStorelessUnivariateStatistic
-
getResult
public abstract double getResult()
Returns the current value of the Statistic.- Specified by:
getResult
in interfaceStorelessUnivariateStatistic
- Returns:
- value of the statistic,
Double.NaN
if it has been cleared or just instantiated.
-
increment
public abstract void increment(double d)
Updates the internal state of the statistic to reflect the addition of the new value.- Specified by:
increment
in interfaceStorelessUnivariateStatistic
- Parameters:
d
- the new value.
-
incrementAll
public void incrementAll(double[] values)
This default implementation just callsincrement(double)
in a loop over the input array.Throws IllegalArgumentException if the input values array is null.
- Specified by:
incrementAll
in interfaceStorelessUnivariateStatistic
- 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 callsincrement(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 interfaceStorelessUnivariateStatistic
- 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 iffobject
is anAbstractStorelessUnivariateStatistic
returning the same values as this forgetResult()
andgetN()
- Overrides:
equals
in classjava.lang.Object
- 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()- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hash code
-
-