MCPcopy Create free account
hub / github.com/Open-Quant/openquant / std_dev

Function std_dev

crates/openquant/src/synthetic_backtesting.rs:377–388  ·  view source on GitHub ↗
(values: &[f64])

Source from the content-addressed store, hash-verified

375}
376
377fn std_dev(values: &[f64]) -> f64 {
378 if values.len() < 2 {
379 return 0.0;
380 }
381 let mean = values.iter().sum::<f64>() / values.len() as f64;
382 let mut ss = 0.0;
383 for v in values {
384 let d = *v - mean;
385 ss += d * d;
386 }
387 (ss / (values.len() as f64 - 1.0)).sqrt()
388}
389
390fn median_sorted(sorted: &[f64]) -> f64 {
391 let n = sorted.len();

Callers 3

calibrate_ou_paramsFunction · 0.70
evaluate_rule_on_pathsFunction · 0.70
detect_no_stable_optimumFunction · 0.70

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected