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.

Quartile thresholds and counts for twelve synthetic durationsThe four bands contain 4, 3, 2, 3 observations. Duplicate values are stacked as dots. Thresholds are calculated from the ten distinct values.Band 1n = 4Band 2n = 3Band 3n = 2Band 4n = 3812.7519.526.2534Duration in minutes · each dot is one invented observation
Quartile boundaries divide the distinct-value range; they do not guarantee equal observation counts.
Counts in the computed bands
BandDuration rangeCount
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.