Thomas Eapen · Selected work
Turning a distribution into useful bands
A small worked example of quartile thresholds, repeated observations and a compact statistical summary.
Synthetic example · independently invented dataOne-page print edition · A3 landscape
12invented observations
10distinct values
4descriptive bands
4 · 3 · 2 · 3observations per band
SYNTHETIC INPUT / MINUTES
Keep the distribution visible
- 8
- 10
- 10
- 12
- 15
- 18
- 18
- 21
- 24
- 27
- 30
- 34
The threshold calculation uses each distinct value once. The counts include every observation, including repeated 10s and 18s.
| Band | Duration range | Count |
|---|---|---|
| Band 1 | [8, 12.75] | 4 |
| Band 2 | (12.75, 19.5] | 3 |
| Band 3 | (19.5, 26.25] | 2 |
| Band 4 | (26.25, 34] | 3 |
THE METHOD / PYTHON
Calculate, then count
from bisect import bisect_left
from math import isfinite
from statistics import quantiles
def quartile_bands(values):
observed = [float(value) for value in values]
if not observed or not all(isfinite(v) for v in observed):
raise ValueError('Use finite observations.')
unique = sorted(set(observed))
if len(unique) < 2:
raise ValueError('At least two distinct values are needed.')
cuts = quantiles(unique, n=4, method='inclusive')
edges = [unique[0], *cuts, unique[-1]]
bins = [bisect_left(cuts, value) for value in observed]
counts = [bins.count(index) for index in range(4)]
return {'edges': edges, 'bins': bins, 'counts': counts}Selected code from the new demonstration that computes these results.
Read the band, then inspect the case. These are descriptive groups from an invented dataset, not performance targets. Values exactly on a threshold stay in the lower band; the minimum is included.