Class AbstractStorelessUnivariateStatistic
- java.lang.Object
-
- org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic
-
- All Implemented Interfaces:
MathArrays.Function,StorelessUnivariateStatistic,UnivariateStatistic
- Direct Known Subclasses:
GeometricMean,Kurtosis,Max,Mean,Min,Product,PSquarePercentile,SecondMoment,Skewness,StandardDeviation,Sum,SumOfLogs,SumOfSquares,Variance
public abstract class AbstractStorelessUnivariateStatistic extends Object implements StorelessUnivariateStatistic
Abstract base class for implementations of theStorelessUnivariateStatisticinterface.Provides default
evaluate(double[],...)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 voidclear()Clears the internal state of the Statistic.abstract StorelessUnivariateStatisticcopy()Returns a copy of the statistic with the same internal state.booleanequals(Object object)Returns true iffobjectis the same type ofStorelessUnivariateStatistic(the object's class equals this instance) returning the same values as this forgetResult()andgetN().doubleevaluate(double[] values)This default implementation creates a copy of thisStorelessUnivariateStatisticinstance, callsclear()on it, then callsincrementAll(double[])with the specified portion of the input array, and then usesgetResult()to compute the return value.doubleevaluate(double[] values, int begin, int length)This default implementation creates a copy of thisStorelessUnivariateStatisticinstance, callsclear()on it, then callsincrementAll(double[])with the specified portion of the input array, and then usesgetResult()to compute the return value.abstract doublegetResult()Returns the current value of the Statistic.inthashCode()Returns hash code based on getResult() and getN().abstract voidincrement(double d)Updates the internal state of the statistic to reflect the addition of the new value.voidincrementAll(double[] values)This default implementation just callsincrement(double)in a loop over the input array.voidincrementAll(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 java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.math4.legacy.stat.descriptive.StorelessUnivariateStatistic
getN
-
-
-
-
Constructor Detail
-
AbstractStorelessUnivariateStatistic
public AbstractStorelessUnivariateStatistic()
-
-
Method Detail
-
evaluate
public double evaluate(double[] values) throws MathIllegalArgumentException
This default implementation creates a copy of thisStorelessUnivariateStatisticinstance, callsclear()on it, then callsincrementAll(double[])with the specified portion of the input array, and then usesgetResult()to compute the return value.Note that this implementation does not change the internal state of the statistic.
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, a MathIllegalArgumentException is thrown.
- Specified by:
evaluatein interfaceMathArrays.Function- Specified by:
evaluatein interfaceUnivariateStatistic- Parameters:
values- input array- Returns:
- the value of the statistic applied to the input array
- Throws:
MathIllegalArgumentException- if values is null- See Also:
UnivariateStatistic.evaluate(double[])
-
evaluate
public double evaluate(double[] values, int begin, int length) throws MathIllegalArgumentException
This default implementation creates a copy of thisStorelessUnivariateStatisticinstance, callsclear()on it, then callsincrementAll(double[])with the specified portion of the input array, and then usesgetResult()to compute the return value.Note that this implementation does not change the internal state of the statistic.
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 MathIllegalArgumentException is thrown.
- Specified by:
evaluatein interfaceMathArrays.Function- Specified by:
evaluatein interfaceUnivariateStatistic- 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
- Throws:
MathIllegalArgumentException- if the array is null or the indices are not valid- 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:
copyin interfaceStorelessUnivariateStatistic- Specified by:
copyin interfaceUnivariateStatistic- Returns:
- a copy of the statistic
-
clear
public abstract void clear()
Clears the internal state of the Statistic.- Specified by:
clearin interfaceStorelessUnivariateStatistic
-
getResult
public abstract double getResult()
Returns the current value of the Statistic.- Specified by:
getResultin interfaceStorelessUnivariateStatistic- Returns:
- value of the statistic,
Double.NaNif 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:
incrementin interfaceStorelessUnivariateStatistic- Parameters:
d- the new value.
-
incrementAll
public void incrementAll(double[] values) throws MathIllegalArgumentException
This default implementation just callsincrement(double)in a loop over the input array.Throws IllegalArgumentException if the input values array is null.
- Specified by:
incrementAllin interfaceStorelessUnivariateStatistic- Parameters:
values- values to add- Throws:
MathIllegalArgumentException- if values is null- See Also:
StorelessUnivariateStatistic.incrementAll(double[])
-
incrementAll
public void incrementAll(double[] values, int begin, int length) throws MathIllegalArgumentException
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:
incrementAllin interfaceStorelessUnivariateStatistic- Parameters:
values- array holding values to addbegin- index of the first array element to addlength- number of array elements to add- Throws:
MathIllegalArgumentException- if values is null- See Also:
StorelessUnivariateStatistic.incrementAll(double[], int, int)
-
equals
public boolean equals(Object object)
Returns true iffobjectis the same type ofStorelessUnivariateStatistic(the object's class equals this instance) returning the same values as this forgetResult()andgetN().
-
-