iterstats 0.4.0

Statistics for rust iterators.
Documentation

iterstats

Statistics for rust iterators.

The api was inspired by itertools.

Example

// import the `Iterstats` trait & the traits belonging to whatever calculations you need
// into scope so you get access to the methods
// (alternatively just do `use iterstats::*;` to get everything)
use iterstats::{Iterstats, Mean, Variance, StdDev, ZScore};

fn main() {
    // start with your dataset
    let data = [1f32, 2., 3., 4.];

    // say you want the mean
    let mean = data.iter().mean();
    assert_eq!(mean, 2.5);

    // get the variance
    let variance = data.iter().variance();
    assert_eq!(variance, 1.25);

    // or standard deviation
    let stddev = data.iter().stddev();
    assert_eq!(stddev, 1.25f32.sqrt());

    // or the zscore of each data point
    let zscores = data.iter().zscore().collect::<Vec<_>>();
    assert_eq!(
        zscores,
        vec![-1.3416407, -0.4472136, 0.4472136, 1.3416407]
    );
}