Skip to main content

moving_average_into

Function moving_average_into 

Source
pub fn moving_average_into(
    values: &[f64],
    window: usize,
    out: &mut [f64],
) -> Option<usize>
Expand description

Simple moving average with the given window, written into out.

Produces n − window + 1 values, where out[i] is the mean of values[i..i+window]. Returns the number of values written, or None if window == 0, window > n, or out is too small to hold the result. Uses a running-sum sweep (O(n), not O(n·window)).