df-maths 0.1.1

This is an maths
Documentation
use std::fmt::Display;

/// 样本偏差值
pub fn stddev<T: Display + std::fmt::Debug>(array: Vec<T>) -> f64 {
    let len = array.len();
    if len <= 1 {
        return 0.0;
    }
    let mut total = 0.0;
    let mut values = vec![];
    for item in array {
        let value = item.to_string().parse::<f64>().unwrap();
        values.push(value);
        total += value;
    }
    let mean = total / len.to_string().parse::<f64>().unwrap();
    total = 0.0;
    let _: Vec<f64> = values.iter_mut().map(|val| {
        let t = (*val - mean).powi(2);
        total += t;
        t
    }).collect();
    (total / (len - 1) as f64).sqrt()
}

/// 统计过程控制
/// Statistical Process Control
pub struct Spc {}

impl Spc {

}