OnlineStatistics
A streaming one-pass accumulator for descriptive statistics.
Computes mean, variance, standard deviation, skewness, and kurtosis without storing individual data points. Uses the Terriberry (2008) extension of Welford's online algorithm for numerically stable single-pass updates of central moments M2, M3, and M4.
This is analogous to Apache Commons Math SummaryStatistics.
Non-finite values: NaN values propagate through all statistics (IEEE 754 semantics). Infinite values are handled correctly for mean, sum, min, and max (which use compensated summation). However, variance, standardDeviation, skewness, and kurtosis return NaN when infinite values are present, since the Welford algorithm used for higher moments computes differences of running means, producing NaN from Inf - Inf.
Example:
val stats = OnlineStatistics()
stats.addAll(doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0))
stats.mean // 3.0
stats.variance() // 2.5
stats.count // 5See also
Properties
The maximum observed value, or Double.NaN if no observations have been added.
The arithmetic mean of all observations, or Double.NaN if no observations have been added.
The minimum observed value, or Double.NaN if no observations have been added.
The sum of all observations, or Double.NaN if no observations have been added.
Functions
Adds all values from a DoubleArray to the accumulator.
Adds all values from an Iterable to the accumulator.
Computes the kurtosis of all observations.
Computes the skewness of all observations.
Computes the standard deviation of all observations.
Computes the variance of all observations.