Skip navigation links
org.apache.commons.math.stat.descriptive

Class AbstractStorelessUnivariateStatistic

    • Constructor Detail

      • AbstractStorelessUnivariateStatistic

        public AbstractStorelessUnivariateStatistic()
    • Method Detail

      • evaluate

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

        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, an IllegalArgumentException is thrown.

        Specified by:
        evaluate in interface UnivariateStatistic
        Overrides:
        evaluate in class AbstractUnivariateStatistic
        Parameters:
        values - input array
        Returns:
        the value of the statistic applied to the input array
        See Also:
        UnivariateStatistic.evaluate(double[])
      • evaluate

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

        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 IllegalArgumentException is thrown.

        Specified by:
        evaluate in interface UnivariateStatistic
        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
        See Also:
        UnivariateStatistic.evaluate(double[], int, int)
      • 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,
                                 int begin,
                                 int length)
        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:
        java.lang.IllegalArgumentException - if values is null
        See Also:
        StorelessUnivariateStatistic.incrementAll(double[], int, int)
      • equals

        public boolean equals(java.lang.Object object)
        Returns true iff object is an AbstractStorelessUnivariateStatistic returning the same values as this for getResult() and getN()
        Overrides:
        equals in class java.lang.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 java.lang.Object
        Returns:
        hash code

Copyright © 2010 - 2020 Adobe. All Rights Reserved