Crate moving_average

Source
Expand description

§Moving Average Library

moving_average is a library for calculating the moving average on a stream of data.

§Features

  • Calculate moving average in an ergonomic way.

§Usage

First, add this to your Cargo.toml:

[dependencies]
moving_average = "0.1.0"

Then, add this to your crate root:

extern crate moving_average;

§Basic Operations

You can create a new Moving instance and add or subtract values from it:

use moving_average::Moving;

let mut moving_average: Moving<usize> = Moving::new();
moving_average.add(10);
moving_average.add(20);
assert_eq!(moving_average, 15);

Structs§

Moving
Moving<T> provides an ergonomic way to compute the moving average, mode, and count for a sequence of values of type T. It supports both signed and unsigned numeric types, and can enforce a threshold to stop accepting new values when the mean reaches or exceeds it.
Value

Enums§

MovingError
Represents the possible errors that can occur in the Moving struct.

Traits§

Sign