/** * The `Accumulator` class is a data type for computing the running * mean, sample standard deviation, and sample variance of a stream of real * numbers. It provides an example of a mutable data type and a streaming * algorithm. *

* This implementation uses a one-pass algorithm that is less susceptible * to floating-point roundoff error than the more straightforward * implementation based on saving the sum of the squares of the numbers. * This technique is due to * B. P. Welford. * Each operation takes constant time in the worst case. * The amount of memory is constant - the data values are not stored. *

* For additional documentation, * see Section 1.2 of * Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne. */ export default class Accumulator { private n; private sum; private mu; /** * Adds the specified data value to the accumulator. * @param x the data value */ addDataValue(val: number): void; /** * Returns the mean of the data values. * @return the mean of the data values */ mean(): number; /** * Returns the sample variance of the data values. * @return the sample variance of the data values */ var(): number; /** * Returns the sample standard deviation of the data values. * @return the sample standard deviation of the data values */ stddev(): number; /** * Returns the number of data values. * @return the number of data values */ count(): number; toString(): string; }