Top Description Fields Constructors Methods
org.apache.commons.math3.stat.descriptive

public abstract Class AbstractUnivariateStatistic

extends Object
implements UnivariateStatistic
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.stat.descriptive.UnivariateStatistic, org.apache.commons.math3.util.MathArrays.Function
Known Direct Subclasses
org.apache.commons.math3.stat.descriptive.moment.SemiVariance, org.apache.commons.math3.stat.descriptive.rank.Percentile, org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic
Imports
org.apache.commons.math3.exception.NotPositiveException, .NullArgumentException, .NumberIsTooLargeException, .MathIllegalArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.MathArrays

Abstract base class for all implementations of the 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.

Field Summary

Modifier and TypeField and Description
private double[]
storedData

Stored data.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract UnivariateStatistic
copy()

Redeclares org.apache.commons.math3.stat.descriptive.UnivariateStatistic.copy.

Returns a copy of the statistic with the same internal state.

public double

Returns:

the value of the statistic applied to the stored data
evaluate
()

Returns the result of evaluating the statistic over the stored data.

public double
evaluate(final double[]
input array
values
)

Implements org.apache.commons.math3.stat.descriptive.UnivariateStatistic.evaluate.

Returns the result of evaluating the statistic over the input array.

public abstract double
evaluate(final double[]
the input array
values
,
final int
the index of the first element to include
begin
,
final int
the number of elements to include
length
)

Redeclares org.apache.commons.math3.stat.descriptive.UnivariateStatistic.evaluate.

Returns the result of evaluating the statistic over the specified entries in the input array.

public double[]

Returns:

copy of the stored data array (may be null)
getData
()

Get a copy of the stored data array.

protected double[]

Returns:

reference to the stored data array (may be null)
getDataRef
()

Get a reference to the stored data array.

public void
setData(final double[]
data array to store (may be null to remove stored data)
values
)

Set the data array.

public void
setData(final double[]
data array to store
values
,
final int
the index of the first element to include
begin
,
final int
the number of elements to include
length
)

Set the data array.

protected boolean

Returns:

true if the parameters are valid and designate a subarray of positive length
test
(final double[]
the input array
values
,
final int
index of the first array element to include
begin
,
final int
the number of elements to include
length
)

This method is used by evaluate(double[], int, int) methods to verify that the input parameters designate a subarray of positive length.

protected boolean

Returns:

true if the parameters are valid
test
(final double[]
the input array
values
,
final int
index of the first array element to include
begin
,
final int
the number of elements to include
length
,
final boolean
if true then zero length arrays are allowed
allowEmpty
)

This method is used by evaluate(double[], int, int) methods to verify that the input parameters designate a subarray of positive length.

protected boolean

Returns:

true if the parameters are valid and designate a subarray of positive length
test
(final double[]
the input array
values
,
final double[]
the weights array
weights
,
final int
index of the first array element to include
begin
,
final int
the number of elements to include
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

Returns:

true if the parameters are valid.
test
(final double[]
the input array.
values
,
final double[]
the weights array.
weights
,
final int
index of the first array element to include.
begin
,
final int
the number of elements to include.
length
,
final boolean
if true than allow zero length arrays to pass.
allowEmpty
)

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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

storedDataback to summary
private double[] storedData

Stored data.

Constructor Detail

AbstractUnivariateStatisticback to summary
public AbstractUnivariateStatistic()

Method Detail

copyback to summary
public abstract UnivariateStatistic copy()

Redeclares org.apache.commons.math3.stat.descriptive.UnivariateStatistic.copy.

Doc from org.apache.commons.math3.stat.descriptive.UnivariateStatistic.copy.

Returns a copy of the statistic with the same internal state.

Returns:UnivariateStatistic

a copy of the statistic

evaluateback to summary
public double evaluate() throws MathIllegalArgumentException

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:double

the value of the statistic applied to the stored data

Exceptions
MathIllegalArgumentException:
if the stored data array is null
evaluateback to summary
public double evaluate(final double[] values) throws MathIllegalArgumentException

Implements org.apache.commons.math3.stat.descriptive.UnivariateStatistic.evaluate.

Doc from org.apache.commons.math3.stat.descriptive.UnivariateStatistic.evaluate.

Returns the result of evaluating the statistic over the input array.

Parameters
values:double[]

input array

Returns:double

the value of the statistic applied to the input array

Exceptions
MathIllegalArgumentException:
if values is null
evaluateback to summary
public abstract double evaluate(final double[] values, final int begin, final int length) throws MathIllegalArgumentException

Redeclares org.apache.commons.math3.stat.descriptive.UnivariateStatistic.evaluate.

Doc from org.apache.commons.math3.stat.descriptive.UnivariateStatistic.evaluate.

Returns the result of evaluating the statistic over the specified entries in the input array.

Parameters
values:double[]

the input array

begin:int

the index of the first element to include

length:int

the number of elements to include

Returns:double

the value of the statistic applied to the included array entries

Exceptions
MathIllegalArgumentException:
if values is null or the indices are invalid
getDataback to summary
public double[] getData()

Get a copy of the stored data array.

Returns:double[]

copy of the stored data array (may be null)

getDataRefback to summary
protected double[] getDataRef()

Get a reference to the stored data array.

Returns:double[]

reference to the stored data array (may be null)

setDataback to summary
public void setData(final double[] values)

Set the data array.

The stored value is a copy of the parameter array, not the array itself.

Parameters
values:double[]

data array to store (may be null to remove stored data)

See Also
evaluate()
setDataback to summary
public void setData(final double[] values, final int begin, final int length) throws MathIllegalArgumentException

Set the data array. The input array is copied, not referenced.

Parameters
values:double[]

data array to store

begin:int

the index of the first element to include

length:int

the number of elements to include

Exceptions
MathIllegalArgumentException:
if values is null or the indices are not valid
See Also
evaluate()
testback to summary
protected boolean test(final double[] values, final int begin, final int length) throws MathIllegalArgumentException

This method is used by evaluate(double[], int, int) methods to verify that the input parameters designate a subarray of positive length.

  • returns true iff the parameters designate a subarray of positive length
  • throws MathIllegalArgumentException if the array is null or or the indices are invalid
  • returns false
  • if the array is non-null, but length is 0.

Parameters
values:double[]

the input array

begin:int

index of the first array element to include

length:int

the number of elements to include

Returns:boolean

true if the parameters are valid and designate a subarray of positive length

Exceptions
MathIllegalArgumentException:
if the indices are invalid or the array is null
testback to summary
protected boolean test(final double[] values, final int begin, final int length, final boolean allowEmpty) throws MathIllegalArgumentException

This method is used by evaluate(double[], int, int) methods to verify that the input parameters designate a subarray of positive length.

  • returns true iff the parameters designate a subarray of non-negative length
  • throws IllegalArgumentException if the array is null or or the indices are invalid
  • returns false
  • if the array is non-null, but length is 0 unless allowEmpty is true

Parameters
values:double[]

the input array

begin:int

index of the first array element to include

length:int

the number of elements to include

allowEmpty:boolean

if true then zero length arrays are allowed

Returns:boolean

true if the parameters are valid

Exceptions
MathIllegalArgumentException:
if the indices are invalid or the array is null
Since
3.0
testback to summary
protected boolean test(final double[] values, final double[] weights, final int begin, final int length) throws MathIllegalArgumentException

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:double[]

the input array

weights:double[]

the weights array

begin:int

index of the first array element to include

length:int

the number of elements to include

Returns:boolean

true if the parameters are valid and designate a subarray of positive length

Exceptions
MathIllegalArgumentException:
if the indices are invalid or the array is null
Since
2.1
testback to summary
protected boolean test(final double[] values, final double[] weights, final int begin, final int length, final boolean allowEmpty) throws MathIllegalArgumentException

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 non-negative length and the weights array contains legitimate values.
  • throws MathIllegalArgumentException 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 unless allowEmpty is true.

Parameters
values:double[]

the input array.

weights:double[]

the weights array.

begin:int

index of the first array element to include.

length:int

the number of elements to include.

allowEmpty:boolean

if true than allow zero length arrays to pass.

Returns:boolean

true if the parameters are valid.

Exceptions
MathIllegalArgumentException:
if the array indices are not valid, the weights array contains NaN, infinite or negative elements, or there are no positive weights.
NullArgumentException:
if either of the arrays are null
Since
3.0