Skip to content

What (One-liner)

Percentile rank of a value within a reference series (discrete ordinal). Library-level primitive.

How to use

python
from services.algo.statistics import percentile_rank
percentile_rank(70, [10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
# → 0.6 (6 strictly less than 70 / 10 total)

Core formulas

filtered = [x for x in series if x is not None]
pct = sum(1 for x in filtered if x < value) / len(filtered)

Assumptions & applicability

Assumptions: ordinal discrete + tie-lower + empty series 0.5.

Applicable: BLCV peer ranking, quantile trigger signals, heavy-tailed asset standardization.

Not applicable: Precise quantile (use numpy.quantile type-7), ML feature engineering.

Known limitations

  1. Discrete (no interpolation)
  2. Tie goes to lower
  3. Empty series 0.5 convention

References

Type 1 among 9 definitions in Hyndman & Fan (1996) Sample Quantiles.

Golden Test

tests/golden/fixtures/tier1/percentile_rank/, 1e-12, 2026-04-20 passing.

Changelog

  • 1.0.0 (2026-04-20) — First Active

Verifiable intelligence for the decisions that demand scrutiny.