sliding_features 8.0.0

Modular sliding window with various signal processing functions and technical indicators
Documentation
/// This Example provides a basic overview of chainable View definitions.
/// Assume you want to first transform your values with a Variance Stabilizing Centering Transform
//  and after that, smooth the values with an ALMA
use std::num::NonZeroUsize;

// import the needed structs, and the View trait
use sliding_features::{
    View,
    pure_functions::Echo,
    sliding_windows::{
        Alma,
        ZScoreStandardization,
    },
};

fn main() {
    // generate random value shifted up by 100.0 and scaled by 20.0,
    // a series which is neither centered around 0 nor variance stabilized
    let rands: Vec<f64> = (0..100)
        .map(|_| rand::random::<f64>() * 20.0 + 100.0)
        .collect();
    println!("rands: {:?}", rands);

    let window_len = NonZeroUsize::new(20).unwrap();
    let mut chain = Alma::new(
        // first, define the last function which gets applied in the chain
        ZScoreStandardization::new(Echo::new(), window_len), // Make the first transformation in the chain a VSCT
        window_len,
    );
    for v in &rands {
        // the chain will first call the inner most view, which is Echo.
        // after that it will apply the VSCT transform
        // and finally apply an Arnaux Legoux moving average
        chain.update(*v);
        if let Some(last_value) = chain.last() {
            println!("transformed value: {}", last_value);
        }
    }
}