Library contents

Python statistics.quantiles

Use inclusive sample quartiles to describe how checkout times are distributed.

A simple example

statistics.quantiles

  1. Start with 1, 2, 3
  2. Do this Find the middle quartile
  3. Result 2
Half of the ordered sample is on either side of the middle value 2.

Syntax

Python 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.py

Find 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 the programtimes = [2, 4, 6, 8, 10]
Result8.0
lesson.py
from statistics import quantiles

times = [2, 4, 6, 8, 10]
quartiles = quantiles(times, n=4, method="inclusive")
print(quartiles[2])
Output
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.

Advertisements

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?

Given6 · 6 · 6 · 6 · 6
Worked result6.0

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?

Given2 · 4 · 8 · 8 · 8 · 8 · 8
Worked result8.0

What to watch for

Choose the same interpolation rule when comparing tools. Filter missing measurements deliberately.

Documentation for statistics.quantiles