Raw capture โ raw/lorenz-and-little.md
url: https://brooker.co.za/blog/2026/07/29/lorenz-and-little.html title: "Lorenz and Little: How Much Does Your Tail Cost?" author: Marc Brooker date_fetched: 2026-08-01 date_published: 2026-07-29
Marc Brooker's "Amateur Statistics Corner" post applying the empirical Lorenz curve (from economics, measuring inequality) to latency percentiles, then connecting to Little's law from queueing theory.
For a latency percentile P, 1 โ L(P) answers: how much do requests at or above that percentile contribute to the mean latency?
From raw samples: L = sum(sorted(x)[:k]) / sum(x)
def OneMinusL(q, p):
assert len(q) == len(p)
assert p[0] == 0
assert all(q[i] > 0 for i in range(len(q)))
assert all(p[i] < p[i+1] for i in range(len(p)-1))
# Power-law interpolation between measured quantiles
# and extrapolation to the tail
alphas = []
for i in range(len(q) - 1):
if q[i+1] > q[i] and p[i+1] > p[i]:
alphas.append(
(p[i+1] - p[i]) / (q[i+1] - q[i])
)
# Estimate tail alpha (must be > 1 for finite mean)
if len(q) >= 2 and q[-1] > q[-2] and p[-1] < 1.0:
tail_alpha = (1.0 - p[-1]) / (q[-1] - q[-2])
else:
tail_alpha = 2.0 # conservative default
results = []
for i in range(len(p)):
if p[i] == 0:
results.append(1.0)
continue
# Compute contribution up to this percentile
contribution = 0.0
for j in range(i):
if q[j+1] > q[j] and p[j+1] > p[j]:
contribution += (p[j+1] - p[j]) * q[j]
# Add tail estimate
if p[i] < p[-1]:
contribution += (p[i] - p[-1]) * q[-1]
results.append(1.0 - contribution / sum(q))
return results
For quantiles [1, 10, 200, 10000, 20000] at percentiles [0, 0.5, 0.9, 0.99, 0.999]:
By Little's law, contribution to mean latency equals contribution to concurrency. If 1 โ L(p99) = 0.5, then 50% of busy threads are serving requests above the p99 threshold.
Brooker observes that in real services, 1 โ L(0.99) often exceeds 0.5 or even 0.75.
"We shouldn't make the mistake of trimming them off, because they're often the thing that's driving costs!"
Tails tend to be disproportionately expensive to serve. Optimizing the tail can reduce concurrency, capacity demand, and lock contention more than expected.
The page includes an interactive widget accepting p0, p50, p90, p99, and p99.9 latency inputs to display each percentile's share of mean latency and concurrency.