pub fn box_cox(y: &[f64], lambda: f64) -> Result<Vec<f64>, TransformError>Expand description
Apply the Box-Cox power transformation to positive data.
For each element yᵢ > 0:
y(λ) = ln(y) when |λ| < 1e-10
(y^λ - 1) / λ otherwise§Errors
TransformError::InsufficientData— fewer than 2 data pointsTransformError::NonPositiveData— any element ≤ 0
§Examples
use u_numflow::transforms::box_cox;
let y = vec![1.0, std::f64::consts::E];
let y_t = box_cox(&y, 0.0).unwrap();
assert!((y_t[0] - 0.0).abs() < 1e-10);
assert!((y_t[1] - 1.0).abs() < 1e-9);