All Implemented Interfaces:
Serializable, StorelessUnivariateStatistic, UnivariateStatistic, MathArrays.Function
Direct Known Subclasses:
SecondMoment

class FirstMoment extends AbstractStorelessUnivariateStatistic implements Serializable
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 Double.NaN may also be returned if the input includes NaN and / or infinite values.

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.