Skip to main content

percentile

Function percentile 

pub fn percentile(
    art: &CalibrationArtifact,
    language: &str,
    metric: &str,
    value: f64,
) -> Option<CorpusPercentile>
Expand description

Corpus-relative percentile of value for (language, metric).

Binary-searches the metric’s non-decreasing breakpoint vector and linearly interpolates between the two straddling breakpoints. Contract:

  • value <= q[0]p = 0.0, not beyond-corpus.
  • value >= q[last]p = 1.0; beyond-corpus iff value > q[last].
  • unknown language / unknown metric / language pooled below MIN_LANG_SAMPLENone.

Plateaus (repeated breakpoints). Integer metrics like nargs and max_nesting produce long runs of equal breakpoints. A value landing on an interior plateau resolves to the run’s UPPER edge — a P(X <= value) (CDF) reading: every function whose metric equals value counts as at-or-below it. A value on a plateau that touches the minimum (value <= q[0]) instead returns 0.0 via the short-circuit above. Both are deliberate.