public abstract class AbstractUnivariateStatistic extends java.lang.Object implements UnivariateStatistic
UnivariateStatistic
interface.
Provides a default implementation of evaluate(double[]),
delegating to evaluate(double[], int, int)
in the natural way.
Also includes a test
method that performs generic parameter
validation for the evaluate
methods.
Constructor and Description |
---|
AbstractUnivariateStatistic() |
Modifier and Type | Method and Description |
---|---|
abstract UnivariateStatistic |
copy()
Returns a copy of the statistic with the same internal state.
|
double |
evaluate(double[] values)
Returns the result of evaluating the statistic over the input array.
|
abstract double |
evaluate(double[] values,
int begin,
int length)
Returns the result of evaluating the statistic over the specified entries
in the input array.
|
protected boolean |
test(double[] values,
double[] weights,
int begin,
int length)
This method is used by
evaluate(double[], double[], int, int) methods
to verify that the begin and length parameters designate a subarray of positive length
and the weights are all non-negative, non-NaN, finite, and not all zero. |
protected boolean |
test(double[] values,
int begin,
int length)
This method is used by
evaluate(double[], int, int) methods
to verify that the input parameters designate a subarray of positive length. |
public double evaluate(double[] values)
evaluate
in interface UnivariateStatistic
values
- input arraypublic abstract double evaluate(double[] values, int begin, int length)
evaluate
in interface UnivariateStatistic
values
- the input arraybegin
- the index of the first element to includelength
- the number of elements to includepublic abstract UnivariateStatistic copy()
copy
in interface UnivariateStatistic
protected boolean test(double[] values, int begin, int length)
evaluate(double[], int, int)
methods
to verify that the input parameters designate a subarray of positive length.
true
iff the parameters designate a subarray of
positive lengthIllegalArgumentException
if the array is null or
or the indices are invalidfalse
if the array is non-null, but
length
is 0.
- Parameters:
values
- the input array
begin
- index of the first array element to include
length
- the number of elements to include
- Returns:
- true if the parameters are valid and designate a subarray of positive length
- Throws:
java.lang.IllegalArgumentException
- if the indices are invalid or the array is null
-
test
protected boolean test(double[] values,
double[] weights,
int begin,
int length)
This method is used by evaluate(double[], double[], int, int)
methods
to verify that the begin and length parameters designate a subarray of positive length
and the weights are all non-negative, non-NaN, finite, and not all zero.
- returns
true
iff the parameters designate a subarray of
positive length and the weights array contains legitimate values.
- throws
IllegalArgumentException
if any of the following are true:
- the values array is null
- the weights array is null
- the weights array does not have the same length as the values array
- the weights array contains one or more infinite values
- the weights array contains one or more NaN values
- the weights array contains negative values
- the start and length arguments do not determine a valid array
- returns
false
if the array is non-null, but
length
is 0.
- Parameters:
values
- the input array
weights
- the weights array
begin
- index of the first array element to include
length
- the number of elements to include
- Returns:
- true if the parameters are valid and designate a subarray of positive length
- Throws:
java.lang.IllegalArgumentException
- if the indices are invalid or the array is null
- Since:
- 2.1