Package org.hipparchus.stat.descriptive
Class AbstractUnivariateStatistic
java.lang.Object
org.hipparchus.stat.descriptive.AbstractUnivariateStatistic
- All Implemented Interfaces:
UnivariateStatistic,MathArrays.Function
- Direct Known Subclasses:
Median,Percentile,SemiVariance
Abstract base class for implementations of the
UnivariateStatistic interface.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor.protectedCopy constructor, creates an identical copy of theoriginal. -
Method Summary
Modifier and TypeMethodDescriptionabstract UnivariateStatisticcopy()Returns a copy of the statistic with the same internal state.doubleevaluate()Returns the result of evaluating the statistic over the stored data.abstract doubleevaluate(double[] values, int begin, int length) Returns the result of evaluating the statistic over the specified entries in the input array.double[]getData()Get a copy of the stored data array.protected double[]Get a reference to the stored data array.voidsetData(double[] values) Set the data array.voidsetData(double[] values, int begin, int length) Set the data array.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hipparchus.stat.descriptive.UnivariateStatistic
evaluate
-
Constructor Details
-
AbstractUnivariateStatistic
protected AbstractUnivariateStatistic()Default constructor. -
AbstractUnivariateStatistic
Copy constructor, creates an identical copy of theoriginal.- Parameters:
original- the instance to copy- Throws:
NullArgumentException- if original is null
-
-
Method Details
-
evaluate
public abstract 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.- 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 values is null or the indices are invalid
-
copy
Returns a copy of the statistic with the same internal state.- Specified by:
copyin interfaceUnivariateStatistic- Returns:
- a copy of the statistic
-
setData
public void setData(double[] values) Set the data array.The stored value is a copy of the parameter array, not the array itself.
- Parameters:
values- data array to store (may be null to remove stored data)- See Also:
-
getData
public double[] getData()Get a copy of the stored data array.- Returns:
- copy of the stored data array (may be null)
-
getDataRef
protected double[] getDataRef()Get a reference to the stored data array.- Returns:
- reference to the stored data array (may be null)
-
setData
Set the data array. The input array is copied, not referenced.- Parameters:
values- data array to storebegin- the index of the first element to includelength- the number of elements to include- Throws:
MathIllegalArgumentException- if values is null or the indices are not valid- See Also:
-
evaluate
Returns the result of evaluating the statistic over the stored data.The stored array is the one which was set by previous calls to
setData(double[]).- Returns:
- the value of the statistic applied to the stored data
- Throws:
MathIllegalArgumentException- if the stored data array is null
-