Skip to main content

z_normalize_window

Function z_normalize_window 

Source
pub fn z_normalize_window(slice: &[f64]) -> Vec<f64>
Expand description

Z-normalize a window slice, returning a freshly allocated vector.

Population std (ddof = 0); constant windows (std ≤ 1e-12) map to the zero vector. See z_normalize_into for the in-place hot-loop variant.

§Examples

use fdars_core::shapelet::z_normalize_window;

// A constant window normalizes to zeros (no NaN/Inf).
let z = z_normalize_window(&[5.0, 5.0, 5.0]);
assert_eq!(z, vec![0.0, 0.0, 0.0]);

// A non-constant window has mean ~0 and population std ~1.
let z = z_normalize_window(&[1.0, 2.0, 3.0]);
let mean: f64 = z.iter().sum::<f64>() / z.len() as f64;
assert!(mean.abs() < 1e-12);