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

Function quantile

crates/openquant/src/hcaa.rs:398–406  ·  view source on GitHub ↗
(mut values: Vec<f64>, q: f64)

Source from the content-addressed store, hash-verified

396}
397
398fn quantile(mut values: Vec<f64>, q: f64) -> f64 {
399 if values.is_empty() {
400 return 0.0;
401 }
402 values.sort_by(f64::total_cmp);
403 let qn = q.clamp(0.0, 1.0);
404 let idx = ((values.len() - 1) as f64 * qn).round() as usize;
405 values[idx]
406}
407
408fn cluster_expected_shortfall(
409 returns: &DMatrix<f64>,

Callers 2

Calls 2

is_emptyMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected