use std::{f32::consts::PI, time::Instant};
use scientific_cal::{smooth::{median}, ScientificError};


#[test]
fn move_ema_filter_test() -> Result<(), ScientificError>{
    // 参数输入
    let window_size = 100;

    let fs = 100000;
    // 仿真数据
    let dt = 1.0 / fs as f32;
    let raw_data: Vec<f32> = (0..fs as i32)
        .map(|i| {
            let t = i as f32 * dt;
            (2.0 * PI * 2.0 * t).sin() + 0.5 * (2.0 * PI * 20.0 * t).sin()
        })
        .collect();
    
    // 开始计算
    let start = Instant::now();
    let output = median(&raw_data, window_size, 0.1)?;  // ema rma用法一样
    // sma_inplase(&mut raw_data, window_size)?;        // ema  rma  没有实现 inplase
    println!("滤波运行耗时: {:?}", start.elapsed());
    println!("{:?}", &output[0..100]);
    Ok(())
}