#average #statistics

moving-average

A simple moving average library

9 releases

0.3.0 Feb 8, 2025
0.1.7 Jul 5, 2024

#1504 in Math

Download history 45/week @ 2024-10-26 76/week @ 2024-11-02 58/week @ 2024-11-09 94/week @ 2024-11-16 91/week @ 2024-11-23 25/week @ 2024-11-30 25/week @ 2024-12-07 21/week @ 2024-12-14 25/week @ 2024-12-21 4/week @ 2024-12-28 16/week @ 2025-01-04 57/week @ 2025-01-11 36/week @ 2025-01-18 23/week @ 2025-01-25 29/week @ 2025-02-01 151/week @ 2025-02-08

260 downloads per month

MIT license

14KB
277 lines

moving-average

Structure to hold the moving average of a value


lib.rs:

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);

Dependencies

~150KB