Accumulate a given (non-NaN) value.
Accumulate a given (non-NaN) value.
Number of accumulated values.
Biggest accumulated value.
Average accumulated value.
Smallest accumulated value.
Population standard deviation.
Sample standard deviation.
Sample variance.
Population variance.
import std.range.primitives : put, isOutputRange; import std.math.operations : isClose; Accumulator small, big; static assert(isOutputRange!(Accumulator, double)); static const double[] smallNumbers = [ 4, 7, 13, 16 ]; put(small, smallNumbers); static const double[] bigNumbers = [ // same as smallnumbers + 1e9 1.000000004e9, 1.000000007e9, 1.000000013e9, 1.000000016e9 ]; put(big, bigNumbers); assert(isClose(small.count, big.count )); assert(isClose(small.min + 1e9, big.min )); assert(isClose(small.max + 1e9, big.max )); assert(isClose(small.mean + 1e9, big.mean )); assert(isClose(small.var, big.var )); assert(isClose(small.variance, big.variance )); assert(isClose(small.std, big.std )); assert(isClose(small.standardDeviation, big.standardDeviation));
Tracks a stream of values and computes some statistics in constant space.