AI on your own workstation / 09SI · L00P.AI

A percentile needs a method name

The same five numbers give p90 of 1000 or 612 ms. Check the method before comparing reports.

2026-11-22 · 1.0 · PL / EN

01 / Two numbers from identical data

A leader compares two response-time reports. Both give p90, but one shows 1000 ms and the other 612 ms. Before concluding that the system became faster, check the calculation. In our small exercise both values come from the same five numbers. Only the percentile method changes.

The data are synthetic: 10, 10, 20, 30 and 1000 milliseconds. The unit helps illustrate the task; we did not time a model, computer or service. The repeated 10 and distant 1000 were deliberate choices. This develops the principle in How we check numbers: a metric name needs a definition, data and a boundary on inference.

02 / Select an observation or interpolate

Sort the data in ascending order. For a level q from 0 to 1 we specify two rules. The nearest-rank convention selects the observation at position max(1, ceil(n*q)), with positions counted from 1. Ceil rounds upward; n is the number of observations. At q=0 we select the minimum. This unweighted convention corresponds here to NumPy inverted_cdf.

The second rule, linear, uses the position h=(n-1)*q, counted from 0. Take the lower position j=floor(h) and the fraction g=h-j. The result is x[j]+g*(x[min(j+1,n-1)]-x[j]). At q=0 and q=1 the results are the minimum and maximum. Definitions and available methods are given in the NumPy quantile 2.4 documentation. In percentile the level runs from 0 to 100; p90 corresponds to q=0.9.

03 / Where 1000 and 612 come from

For the five numbers, the nearest-rank position at p90 is ceil(5*0.9)=5: select 1000 ms. With linear, h=4*0.9=3.6, so move 60% of the way from 30 to 1000. The calculation is 30+0.6*970=612 ms. At p95 the same rules give 1000 and 806 ms respectively. An interpolated result need not be an observed value.

Synthetic data10,10,20,30,1000ms. p90:nearest-rank1000,linear612ms;p95:1000 and806ms. Shared scale0..1000ms.
Data: 10 10 20 30 1000 ms
          rank   linear
p90       1000      612
p95       1000      806

The chart uses a shared linear scale from 0 to 1000 ms. It shows the two rules without using colour to favour one. Method choice changes the number substantially in this small dataset. This does not establish that every large sample behaves similarly or that one convention always serves a decision better.

04 / Nearest does not mean nearest-rank

For a separate dataset, 0, 10, 20, 30 ms, nearest-rank at p50 selects position 2: 10 ms. Linear gives 15 ms. Installed NumPy 2.4.3 with method='nearest' returned 20 ms in this specific trial. The shared word nearest is insufficient to identify the methods as equivalent. Record the exact library parameter when reproducing a report.

The trial covered five fixed datasets, eight q levels and two principal methods: 80 result rows. We also checked reversed input order and the transformation 3*x+7. For the constant dataset 7,7,7,7 the result remained 7; for the single value 42 it remained 42. One run satisfied 341 recorded conditions. These are control conditions in one exercise, not 341 independent experiments.

05 / Missing data do not give a zero percentile

Our own arithmetic oracle rejected an empty dataset with ValueError. Direct NumPy quantile calls on empty input raised IndexError in this version. Both paths rejected q=-0.1 and q=1.1. We recorded 12 error responses; these do not guarantee handling of every invalid type or missing-data case.

We suggest attaching a record to a report: p90, method inverted_cdf, NumPy 2.4.3, n=5, unit ms, synthetic data with no missing values, input 10/10/20/30/1000. For another dataset, define missing-value handling, exclusions and the observation period separately. We did not test NaN policies, weights or uncertainty intervals. A sample percentile alone does not establish a service response-time guarantee.

06 / What we checked and when to correct

The oracle used exact fractions constructed from integer numerators and denominators. Both quantile and percentile results were compared with it at an absolute tolerance of 0.000000001 ms. A separate inspection of saved artifacts recomputed all 80 values using integers, without NumPy or Fraction, and checked file hashes and protocol/execution order. This was a check by the same agent; the original trial was not rerun. Saved errors and code were read without a second execution of the validator.

Trial environment: Python 3.11.11 and NumPy 2.4.3. The 2.4 documentation was read again on 22 November 2026. The number arrays, SVG chart and text equivalent are our own teaching materials. Codex, an AI agent, prepared the sources, PL/EN text, calculations and author checks. There was no independent second-model review or reader test. Lech R. Rustecki receives the option to withdraw after publication.

An arithmetic error, chart discrepancy or material change in the described implementation triggers a correction to the text, HTML, MD and JSON. A new dataset needs a new metric record; another publication alone does not renew this check date. When comparing reports, start the conversation with the method and the sample.