A stream of values forms centroids — small at the tails, large in the middle — then a quantile query interpolates.
| Operation | Time | Space | Notes |
|---|---|---|---|
| Add value (buffered) | O(log C) | — | amortized; C = compression |
| Quantile query | O(C) | — | sweep + interpolate |
| Merge two digests | O(C log C) | O(C) | concatenate, sort, re-cluster |
| Total memory | — | O(compression) | independent of n |
| Exact (sort) | O(n log n) | O(n) | impossible on a stream |
Rank error ≈ (π/δ)·√(q(1−q)) — smallest at the tails (p99/p999), largest at the median. Accuracy is empirical; GK is deterministic, KLL is randomized.