make Python percentile_rank align C++ implementation

round in Python returns nearest even, while in C++ it
behaves as x -> floor(x + 0.5)
This commit is contained in:
Oleksandr Pavlyk
2026-06-29 13:23:43 -05:00
parent c2c46e90f0
commit 4f6dd09caf
2 changed files with 15 additions and 1 deletions

View File

@@ -1322,7 +1322,8 @@ def compute_timing_interval_from_samples(samples):
def percentile_rank(percentile: int, sample_count: int) -> int:
clamped_percentile = min(max(percentile, 0), 100)
return round((clamped_percentile / 100.0) * (sample_count - 1))
rank = (clamped_percentile / 100.0) * (sample_count - 1)
return math.floor(rank + 0.5)
def compute_robust_timing_input_from_samples(samples):