Python statistics.quantiles
Use inclusive sample quartiles to describe how checkout times are distributed.
A simple example
statistics.quantiles
- Start with 1, 2, 3
- Do this Find the middle quartile
- Result 2
Syntax
quantiles(times, n=4, method="inclusive")
Run these examples in Python
Save one example at a time as lesson.py. Use Python 3.9 or later.
python3 lesson.pyFind the upper quartile of checkout times
A manager wants a checkout-time threshold for the slower part of a shift. Order the recorded times and apply the stated quartile convention before using the result for staffing.
from statistics import quantiles
times = [2, 4, 6, 8, 10]
quartiles = quantiles(times, n=4, method="inclusive")
print(quartiles[2])
8.0
The third quartile of these five ordered times is eight minutes. The inclusive method uses the lowest and highest values as the endpoints.
Measure a steady cycle time
A classroom robot repeats its cycle in six seconds on every trial. The ordered sample has the same value at every relevant interpolation boundary. What is its upper quartile?
Locate a busy checkout band
Several checkout times tie at the upper end of a small sample. The ordered sample has the same value at every relevant interpolation boundary. What is its upper quartile?
What to watch for
Choose the same interpolation rule when comparing tools. Filter missing measurements deliberately.