AbstractStorelessUnivariateStatistic (Apache Commons Math 3.3 API)

org.apache.commons.math3.stat.descriptive

## Class AbstractStorelessUnivariateStatistic

- java.lang.Object
- - org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic
  - - org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic

- All Implemented Interfaces:
    StorelessUnivariateStatistic, UnivariateStatistic, MathArrays.Function
  Direct Known Subclasses:
    GeometricMean, Kurtosis, Max, Mean, Min, Product, SecondMoment, Skewness, StandardDeviation, Sum, SumOfLogs, SumOfSquares, Variance

      public abstract class AbstractStorelessUnivariateStatistic
      extends AbstractUnivariateStatistic
      implements StorelessUnivariateStatistic

  Abstract implementation of the `StorelessUnivariateStatistic` interface.

  Provides default `evaluate()` and `incrementAll(double[])` implementations.

  Note that these implementations are not synchronized.

  Version:
    $Id: AbstractStorelessUnivariateStatistic.java 1416643 2012-12-03 19:37:14Z tn $

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractStorelessUnivariateStatistic()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `clear()` Clears the internal state of the Statistic
    `abstract StorelessUnivariateStatistic` | `copy()` Returns a copy of the statistic with the same internal state.
    `boolean` | `equals(Object object)` Returns true iff `object` is an `AbstractStorelessUnivariateStatistic` returning the same values as this for `getResult()` and `getN()`
    `double` | `evaluate(double[] values)` This default implementation calls `clear()`, then invokes `increment(double)` in a loop over the the input array, and then uses `getResult()` to compute the return value.
    `double` | `evaluate(double[] values, int begin, int length)` This default implementation calls `clear()`, then invokes `increment(double)` in a loop over the specified portion of the input array, and then uses `getResult()` to compute the return value.
    `abstract double` | `getResult()` Returns the current value of the Statistic.
    `int` | `hashCode()` Returns hash code based on getResult() and getN()
    `abstract void` | `increment(double d)` Updates the internal state of the statistic to reflect the addition of the new value.
    `void` | `incrementAll(double[] values)` This default implementation just calls `increment(double)` in a loop over the input array.
    `void` | `incrementAll(double[] values, int begin, int length)` This default implementation just calls `increment(double)` in a loop over the specified portion of the input array.

    - ### Methods inherited from class org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic

      `evaluate, getData, getDataRef, setData, setData, test, test, test, test`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic

      `getN`

- - ### Constructor Detail

    - #### AbstractStorelessUnivariateStatistic

          public AbstractStorelessUnivariateStatistic()

  - ### Method Detail

    - #### evaluate

          public double evaluate(double[] values)
                          throws MathIllegalArgumentException

      This default implementation calls `clear()`, then invokes `increment(double)` in a loop over the the input array, and then uses `getResult()` to compute the return value.

      Note that this implementation changes the internal state of the statistic. Its side effects are the same as invoking `clear()` and then `incrementAll(double[])`.

      Implementations may override this method with a more efficient and possibly more accurate implementation that works directly with the input array.

      If the array is null, a MathIllegalArgumentException is thrown.

      Specified by:
        `evaluate` in interface `UnivariateStatistic`
      Specified by:
        `evaluate` in interface `MathArrays.Function`
      Overrides:
        `evaluate` in class `AbstractUnivariateStatistic`
      Parameters:
        `values` - input array
      Returns:
        the value of the statistic applied to the input array
      Throws:
        `MathIllegalArgumentException` - if values is null
      See Also:
        `UnivariateStatistic.evaluate(double[])`

    - #### evaluate

          public double evaluate(double[] values,
                        int begin,
                        int length)
                          throws MathIllegalArgumentException

      This default implementation calls `clear()`, then invokes `increment(double)` in a loop over the specified portion of the input array, and then uses `getResult()` to compute the return value.

      Note that this implementation changes the internal state of the statistic. Its side effects are the same as invoking `clear()` and then `incrementAll(double[], int, int)`.

      Implementations may override this method with a more efficient and possibly more accurate implementation that works directly with the input array.

      If the array is null or the index parameters are not valid, an MathIllegalArgumentException is thrown.

      Specified by:
        `evaluate` in interface `UnivariateStatistic`
      Specified by:
        `evaluate` in interface `MathArrays.Function`
      Specified by:
        `evaluate` in class `AbstractUnivariateStatistic`
      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
      Throws:
        `MathIllegalArgumentException` - if the array is null or the indices are not valid
      See Also:
        `UnivariateStatistic.evaluate(double[], int, int)`

    - #### copy

          public abstract StorelessUnivariateStatistic copy()

      Returns a copy of the statistic with the same internal state.
      Specified by:
        `copy` in interface `StorelessUnivariateStatistic`
      Specified by:
        `copy` in interface `UnivariateStatistic`
      Specified by:
        `copy` in class `AbstractUnivariateStatistic`
      Returns:
        a copy of the statistic

    - #### clear

          public abstract void clear()

      Clears the internal state of the Statistic
      Specified by:
        `clear` in interface `StorelessUnivariateStatistic`

    - #### getResult

          public abstract double getResult()

      Returns the current value of the Statistic.
      Specified by:
        `getResult` in interface `StorelessUnivariateStatistic`
      Returns:
        value of the statistic, `Double.NaN` if it has been cleared or just instantiated.

    - #### increment

          public abstract void increment(double d)

      Updates the internal state of the statistic to reflect the addition of the new value.
      Specified by:
        `increment` in interface `StorelessUnivariateStatistic`
      Parameters:
        `d` - the new value.

    - #### incrementAll

          public void incrementAll(double[] values)
                            throws MathIllegalArgumentException

      This default implementation just calls `increment(double)` in a loop over the input array.

      Throws IllegalArgumentException if the input values array is null.

      Specified by:
        `incrementAll` in interface `StorelessUnivariateStatistic`
      Parameters:
        `values` - values to add
      Throws:
        `MathIllegalArgumentException` - if values is null
      See Also:
        `StorelessUnivariateStatistic.incrementAll(double[])`

    - #### incrementAll

          public void incrementAll(double[] values,
                          int begin,
                          int length)
                            throws MathIllegalArgumentException

      This default implementation just calls `increment(double)` in a loop over the specified portion of the input array.

      Throws IllegalArgumentException if the input values array is null.

      Specified by:
        `incrementAll` in interface `StorelessUnivariateStatistic`
      Parameters:
        `values` - array holding values to add
        `begin` - index of the first array element to add
        `length` - number of array elements to add
      Throws:
        `MathIllegalArgumentException` - if values is null
      See Also:
        `StorelessUnivariateStatistic.incrementAll(double[], int, int)`

    - #### equals

          public boolean equals(Object object)

      Returns true iff `object` is an `AbstractStorelessUnivariateStatistic` returning the same values as this for `getResult()` and `getN()`
      Overrides:
        `equals` in class `Object`
      Parameters:
        `object` - object to test equality against.
      Returns:
        true if object returns the same value as this

    - #### hashCode

          public int hashCode()

      Returns hash code based on getResult() and getN()
      Overrides:
        `hashCode` in class `Object`
      Returns:
        hash code

Copyright © 2003–2014 The Apache Software Foundation. All rights reserved.