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:
- Initialize
m = the first value
- 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.
version: $Revision: 348519 $ $Date: 2005-11-23 12:12:18 -0700 (Wed, 23 Nov 2005) $ |