#accumulator #incremental-computation #statistics #online-algorithms

simple_accumulator

A simple accumulator for incremental statistical computations

9 releases (breaking)

0.7.0 Feb 12, 2024
0.6.0 Dec 21, 2023
0.5.1 Dec 19, 2023
0.4.2 Jun 16, 2023
0.3.2 Jul 29, 2022

#463 in Math

Download history 265/week @ 2024-07-18 419/week @ 2024-07-25 317/week @ 2024-08-01 276/week @ 2024-08-08 54/week @ 2024-08-15 177/week @ 2024-08-22 123/week @ 2024-08-29 93/week @ 2024-09-05 156/week @ 2024-09-12 78/week @ 2024-09-19 106/week @ 2024-09-26 481/week @ 2024-10-03 248/week @ 2024-10-10 333/week @ 2024-10-17 302/week @ 2024-10-24 200/week @ 2024-10-31

1,158 downloads per month
Used in coordinates_outliers

MIT license

15KB
169 lines

SimpleAccumulator

Crates.io docs.rs Crates.io

This crate is inspired by Boost::Accumulator which supports incremental statistical computation (online algorithms). This is a work in progress but usable. Please write integration tests before using it in production.

Read Documentation

Notes

  • 2023-12-20: Version 0.6 is a major rewrite that fix many embarassing bugs. In 0.6+, we are relying on watermill crate for underlying algorithms.

Usage:

use simple_accumulator::SimpleAccumulator;

fn main() {
    let k = [1, 2, 3, 4];

    // If second argument is `None` then accumulator stores all the data. 
    let mut x = SimpleAccumulator::new(&k, Some(10));

    println!("{:?}", x);
    
    x.push(5);
    println!("{:?}", x);

    print!("{}", x.mean());
    print!("{}", x.median());
    print!("{}", x.variance());
    print!("{}", x.sum());
    print!("{}", x.kurtosis());
    ...
}

Dependencies

~1.8–3MB
~59K SLoC