box_cox_transform

Function box_cox_transform 

Source
pub fn box_cox_transform<F, S>(
    ts: &ArrayBase<S, Ix1>,
    lambda: Option<F>,
) -> Result<(Array1<F>, BoxCoxTransform<F>)>
where S: Data<Elem = F>, F: Float + FromPrimitive + Debug + Display + ScalarOperand,
Expand description

Apply Box-Cox transformation to time series

The Box-Cox transformation is defined as:

  • If λ ≠ 0: y(λ) = (y^λ - 1) / λ
  • If λ = 0: y(λ) = ln(y)

§Arguments

  • ts - Input time series (must be positive)
  • lambda - Box-Cox parameter. If None, optimal lambda is estimated

§Returns

Tuple of (transformed_series, transformation_parameters)

§Examples

use scirs2_core::ndarray::Array1;
use scirs2_series::transformations::box_cox_transform;

let ts = Array1::from_vec(vec![1.0, 2.0, 3.0, 4.0, 5.0]);
let (transformed, params) = box_cox_transform(&ts, Some(0.5)).unwrap();