Interface StorelessUnivariateStatistic
-
- All Superinterfaces:
DoubleConsumer
,MathArrays.Function
,UnivariateStatistic
- All Known Implementing Classes:
AbstractStorelessUnivariateStatistic
,GeometricMean
,Kurtosis
,Max
,Mean
,Min
,Product
,PSquarePercentile
,RandomPercentile
,SecondMoment
,Skewness
,StandardDeviation
,Sum
,SumOfLogs
,SumOfSquares
,Variance
public interface StorelessUnivariateStatistic extends UnivariateStatistic, DoubleConsumer
Extends the definition ofUnivariateStatistic
withincrement(double)
andincrementAll(double[])
methods for adding values and updating internal state.This interface is designed to be used for calculating statistics that can be computed in one pass through the data without storing the full array of sample values.
Note: unless otherwise stated, the
UnivariateStatistic.evaluate(double[])
andevaluate(double[], int, int)
methods do NOT alter the internal state of the respective statistic.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
accept(double value)
void
clear()
Clears the internal state of the StatisticStorelessUnivariateStatistic
copy()
Returns a copy of the statistic with the same internal state.default double
evaluate(double[] values, int begin, int length)
Returns the result of evaluating the statistic over the specified entries in the input array.long
getN()
Returns the number of values that have been added.double
getResult()
Returns the current value of the Statistic.void
increment(double d)
Updates the internal state of the statistic to reflect the addition of the new value.default void
incrementAll(double[] values)
Updates the internal state of the statistic to reflect addition of all values in the values array.default void
incrementAll(double[] values, int start, int length)
Updates the internal state of the statistic to reflect addition of the values in the designated portion of the values array.-
Methods inherited from interface java.util.function.DoubleConsumer
andThen
-
Methods inherited from interface org.hipparchus.stat.descriptive.UnivariateStatistic
evaluate
-
-
-
-
Method Detail
-
evaluate
default double evaluate(double[] values, int begin, int length) throws MathIllegalArgumentException
Returns the result of evaluating the statistic over the specified entries in the input array.The default implementation creates a copy of this
StorelessUnivariateStatistic
instance, 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.
- Specified by:
evaluate
in interfaceMathArrays.Function
- Specified by:
evaluate
in 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)
-
increment
void increment(double d)
Updates the internal state of the statistic to reflect the addition of the new value.- Parameters:
d
- the new value.
-
accept
default void accept(double value)
- Specified by:
accept
in interfaceDoubleConsumer
-
incrementAll
default void incrementAll(double[] values) throws MathIllegalArgumentException
Updates the internal state of the statistic to reflect addition of all values in the values array. Does not clear the statistic first -- i.e., the values are added incrementally to the dataset.The default implementation delegates to
incrementAll(double[], int, int)
in the natural way.- Parameters:
values
- array holding the new values to add- Throws:
MathIllegalArgumentException
- if the array is null
-
incrementAll
default void incrementAll(double[] values, int start, int length) throws MathIllegalArgumentException
Updates the internal state of the statistic to reflect addition of the values in the designated portion of the values array. Does not clear the statistic first -- i.e., the values are added incrementally to the dataset.The default implementation just calls
increment(double)
in a loop over the specified portion of the input array.- Parameters:
values
- array holding the new values to addstart
- the array index of the first value to addlength
- the number of elements to add- Throws:
MathIllegalArgumentException
- if the array is null or the index
-
getResult
double getResult()
Returns the current value of the Statistic.- Returns:
- value of the statistic,
Double.NaN
if it has been cleared or just instantiated.
-
getN
long getN()
Returns the number of values that have been added.- Returns:
- the number of values.
-
clear
void clear()
Clears the internal state of the Statistic
-
copy
StorelessUnivariateStatistic copy()
Returns a copy of the statistic with the same internal state.- Specified by:
copy
in interfaceUnivariateStatistic
- Returns:
- a copy of the statistic
-
-