amv-dev / yata

Yet Another Technical Analysis library [for Rust]
Apache License 2.0
321 stars 49 forks source link

calculation for standard deviation seems wrong #28

Closed flameoftheforest closed 1 year ago

flameoftheforest commented 1 year ago
fn main() {
  let v = vec![1.0, 1.0, 2.0];
  let mut stdev = StDev::new(3, &v[0]).unwrap();
  stdev.next(&v[1]);
  assert_eq!(stdev.next(&v[2]), 0.4714045207910317);
}

assert failed.

amv-dev commented 1 year ago
  1. You can't use strict comparison with float values.
  2. The right value is 0.577350269189626. yata uses corrected sample standard deviation.
flameoftheforest commented 1 year ago

thanks for reply. i understand now.