Skip to main content

normalize

Function normalize 

Source
pub fn normalize(data: &FdMatrix, method: NormalizationMethod) -> FdMatrix
Expand description

Normalize functional data using the specified method.

Column-wise methods (across curves at each time point):

  • Center: subtract column means (same as center_1d)
  • Autoscale: center + divide by column std dev (unit variance per time point)
  • Pareto: center + divide by sqrt(column std dev)
  • Range: center + divide by column range (max - min)

Row-wise methods (per curve):

  • CurveCenter: subtract each curve’s own mean
  • CurveStandardize: subtract mean, divide by std dev per curve
  • CurveRange: scale each curve to [0, 1]
  • CurveLp(p): divide each curve by its Lp norm — requires argvals, use normalize_with_argvals instead

§Panics

Panics if CurveLp is used without argvals. Use normalize_with_argvals for Lp normalization.

§Examples

use fdars_core::matrix::FdMatrix;
use fdars_core::fdata::{normalize, NormalizationMethod};

let data = FdMatrix::from_column_major(
    vec![1.0, 3.0, 2.0, 6.0, 3.0, 9.0], 2, 3,
).unwrap();

// Autoscale: zero mean, unit variance per time point
let scaled = normalize(&data, NormalizationMethod::Autoscale);
assert_eq!(scaled.shape(), (2, 3));