Skip to main content

running_mean

Function running_mean 

Source
pub fn running_mean(data: &[f64], binwidth: usize) -> Result<Vec<f64>>
Expand description

Running (moving) mean of data over windows of binwidth consecutive values.

The result has data.len() - binwidth + 1 elements: element i is the mean of data[i..i + binwidth].

Binds igraph_running_mean. Time complexity: O(n).

§Errors

ErrorKind::InvalidValue if binwidth is zero or larger than data.len().

§Examples

use igraph::misc;
assert_eq!(misc::running_mean(&[1.0, 2.0, 3.0, 4.0, 5.0], 2)?, vec![1.5, 2.5, 3.5, 4.5]);