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

Function std_dev

crates/openquant/src/strategy_risk.rs:289–303  ·  view source on GitHub ↗
(values: &[f64])

Source from the content-addressed store, hash-verified

287}
288
289fn std_dev(values: &[f64]) -> f64 {
290 if values.len() < 2 {
291 return 0.0;
292 }
293 let mu = mean(values);
294 let var = values
295 .iter()
296 .map(|v| {
297 let d = *v - mu;
298 d * d
299 })
300 .sum::<f64>()
301 / (values.len() as f64 - 1.0);
302 var.sqrt()
303}
304
305fn silverman_bandwidth(samples: &[f64]) -> f64 {
306 let sigma = std_dev(samples);

Callers 2

silverman_bandwidthFunction · 0.70

Calls 2

lenMethod · 0.80
meanFunction · 0.70

Tested by

no test coverage detected