Percentiles: median, P90 and P95

Concept · Statistical measures · Measures

Updated

Browse documentation
On this page

Engine 19.0.0rc597 · Reader 9.0.0rc656 · Development snapshot

A percentile identifies a position in a sorted collection of values. The median, or P50, describes its middle. P90 and P95 describe positions farther into the upper part of the distribution. Ghost Observatory calculates these empirical quantiles using linear interpolation between recorded values.

Use them together to ask whether a typical duration also represents the slower observations. A median of ten minutes and a P90 of an hour describe a different operating pattern from a median of ten minutes and a P90 of twelve minutes. Neither result establishes a service target.

The linear-interpolation formula

For at least one known value, sort the n values as x1 through xn. The quantile fraction q lies between 0 and 1: 0.5 for the median, 0.9 for P90 or 0.95 for P95. Locate the percentile at zero-based position h.

h = (n − 1)q   ·   j = floor(h)   ·   g = h − j

If g = 0: Q(q) = xj+1

If g > 0: Q(q) = (1 − g)xj+1 + g xj+2

Multiply the quantile fraction by one less than the sample size. Round that position down to get its integer part; the remainder is its fractional part. If the fraction is zero, use the value at that zero-based position. Otherwise weight that value by one minus the fraction and the next value by the fraction, then add them.

Each admitted observation has equal weight. The result retains the input unit, which is seconds for the published duration fields. Other software may choose a different quantile convention, so matching the same data and the name “P90” alone does not guarantee an identical number.

A worked example: 1 through 20 seconds

For twenty durations of 1, 2, 3, …, 20 seconds, the median position is 19 × 0.5 = 9.5. It sits halfway between the tenth and eleventh values, giving 10.5 seconds.

For P90, the position is 19 × 0.9 = 17.1. Interpolating one tenth of the distance from 18 to 19 gives 18.1 seconds. Both values follow directly from the interpolation formula.

Interpolated values subject to the documented publication minimums
Recorded durationsMedianP90P95
1 through 19 seconds10WithheldWithheld
1 through 20 seconds10.518.1Withheld
1 through 40 seconds20.536.138.05

Why some percentiles are missing

For interior quantiles (0 < q < 1), the Engine applies this minimum to the number of known values used for the percentile:

nmin(q) = max(5, ceil[2 / min(q, 1 − q)])

Take the smaller of the quantile fraction and one minus that fraction. Divide two by it and round up to a whole number. Use the larger of that number and five. The median needs 5 known values, P90 needs 20 and P95 needs 40.

These publication thresholds prevent a handful of observations from producing a tail percentile. Passing the minimum does not make the estimate exact or ensure that the records represent future work. Below it, the stored value is NULL.

A known zero duration can enter an ordinary duration percentile. An unknown duration cannot. This differs from logarithmic KDE and control charts, which require positive durations. Check the relevant count before comparing the displays.

Which population does the field describe?

Empirical quantiles in the published result
FieldsPopulation
duration_stats.median_sec
duration_stats.p90_sec
The row’s activity, person or selected team duration population; or completed top-level objects for a lead-time row.
edges.median_wait_sec
edges.p95_wait_sec
Waiting times between transitions on that activity edge. Person-handover edges publish a median over known waits, without P95.
variants.median_lead_time_sec
variants.p95_lead_time_sec
Known lead times of completed objects following that counted activity sequence.

Read scope_id, subject_kind and duration_source alongside a duration statistic. Processing time, each work evidence class and object lead time stay separate. An activity or person summary includes valid zero durations; a selected team work-curve row describes its positive durations.

Some populations have additional completeness rules. An activity-edge wait quantile is withheld when any transition has an unknown wait or overlaps. A person-handover median instead uses its known waits and supplies known_wait_count. Small rule-hit lead-time groups are omitted entirely; the corresponding rule-rest row is also omitted when its hit group is too small.

Group medians and percentiles cannot be averaged to recover a pooled percentile. Calculating that percentile requires the pooled underlying observations with the intended population and weights.

How the Reader uses the result

The Reader places the stored median and P90 on duration plots and curves. Process maps and variant views use their stored wait and lead-time quantiles. Filtering the visible rows does not create a new pooled percentile in the browser.

An empirical completed-object median also answers a different question from the Kaplan–Meier median time to close. The former uses completed observations; the survival estimate retains eligible objects that remain open through censoring. Both can be expressed in seconds while describing different evidence.

Mean, median and P90 answer different questions

The arithmetic mean adds the values and divides by their count. A few long durations can pull it upward. The median locates the middle of the sorted observations; P90 describes a position farther into the slow end. None of these values describes the entire distribution.

Use a duration distribution when you need to see whether the same median hides several clusters. Use a control chart when order matters. State the quantile convention when reproducing a percentile: an interpolated P90 need not equal any one recorded duration.

Follow the input definitions for lead time, processing time and waiting time. The measure reference brings them together.

Dependency reference: the official Polars quantile documentation. The examples above use linear interpolation; the calculation does not depend on a particular software package.