Class AbstractUnivariateStatistic

java.lang.Object
org.apache.commons.math.stat.descriptive.AbstractUnivariateStatistic
All Implemented Interfaces:
UnivariateStatistic
Direct Known Subclasses:
AbstractStorelessUnivariateStatistic, Percentile, SemiVariance

public abstract class AbstractUnivariateStatistic extends Object implements UnivariateStatistic
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.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a copy of the statistic with the same internal state.
    double
    Returns the result of evaluating the statistic over the stored data.
    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.
    double[]
    Get a copy of the stored data array.
    void
    setData(double[] values)
    Set the data array.
    void
    setData(double[] values, int begin, int length)
    Set the data array.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractUnivariateStatistic

      public AbstractUnivariateStatistic()
  • Method Details

    • 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)
    • setData

      public void setData(double[] values, int begin, int length)
      Set the data array.
      Parameters:
      values - data array to store
      begin - the index of the first element to include
      length - the number of elements to include
      See Also:
    • evaluate

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

      Returns:
      the value of the statistic applied to the stored data
    • evaluate

      public double evaluate(double[] values)
      Returns the result of evaluating the statistic over the input array.
      Specified by:
      evaluate in interface UnivariateStatistic
      Parameters:
      values - input array
      Returns:
      the value of the statistic applied to the input array
    • evaluate

      public abstract double evaluate(double[] values, int begin, int length)
      Returns the result of evaluating the statistic over the specified entries in the input array.
      Specified by:
      evaluate in interface UnivariateStatistic
      Parameters:
      values - the input array
      begin - the index of the first element to include
      length - the number of elements to include
      Returns:
      the value of the statistic applied to the included array entries
    • copy

      public abstract UnivariateStatistic copy()
      Returns a copy of the statistic with the same internal state.
      Specified by:
      copy in interface UnivariateStatistic
      Returns:
      a copy of the statistic