Class FirstMoment

  • All Implemented Interfaces:, StorelessUnivariateStatistic, UnivariateStatistic
    Direct Known Subclasses:

    public class FirstMoment
    extends AbstractStorelessUnivariateStatistic
    Computes the first moment (arithmetic mean). Uses the definitional formula:

    mean = sum(x_i) / n

    where n is the number of observations.

    To limit numeric errors, the value of the statistic is computed using the following recursive updating algorithm:

    1. Initialize m = the first value
    2. For each additional value, update using
      m = m + (new value - m) / (number of observations)

    Returns Double.NaN if the dataset is empty.

    Note that this implementation is not synchronized. If multiple threads access an instance of this class concurrently, and at least one of the threads invokes the increment() or clear() method, it must be synchronized externally.

    See Also:
    Serialized Form