MCPcopy Create free account
hub / github.com/alceal/plotlars / percentile

Function percentile

crates/plotlars-plotters/src/render/boxplot.rs:57–66  ·  view source on GitHub ↗
(sorted: &[f64], p: f64)

Source from the content-addressed store, hash-verified

55}
56
57fn percentile(sorted: &[f64], p: f64) -> f64 {
58 if sorted.is_empty() {
59 return 0.0;
60 }
61 let idx = (p / 100.0) * (sorted.len() as f64 - 1.0);
62 let lo = idx.floor() as usize;
63 let hi = (lo + 1).min(sorted.len() - 1);
64 let frac = idx - lo as f64;
65 sorted[lo] * (1.0 - frac) + sorted[hi] * frac
66}
67
68/// `slot_width` is the per-group horizontal slice; `box_width` is the rendered
69/// box width within the slot, narrowed when grouped so adjacent boxes don't touch.

Callers 1

compute_box_statsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected