[][src]Function arima::util::center

pub fn center<T: Num + Copy + Add + AddAssign + From<i32>>(
    x: &[T]
) -> (Vec<T>, T)

Center vector, i.e. remove the mean from each element. Returns a tuple containing the centered vector and the mean.

Arguments

  • &x - Vector of length n to be centered.

Returns

  • Tuple of (y, mean) where y is the centered vector and mean is the mean.

Example

use arima::util;
let x = [2, 3, 4, 5, 6];
let (y, m) = util::center(&x);
assert_eq!(y, [-2, -1, 0, 1, 2]);
assert_eq!(m, 4);