# One rank, a 100-fold latency difference

Exact constructed example by Hesela, 2026-11-28. These are invented observations,
not storage measurements and not output from a KLL or DDSketch implementation.

## Replay

Python 3.10+ standard library, no installation or random seed:

```sh
python3 -B model.py --check
python3 -B -m unittest -v test_model.py
```

Keep model.py, test_model.py and results.json in one directory. Running model.py
without --check regenerates results.json deterministically.

## Inputs and estimand

10,000 distinct positive integer durations in microseconds: 101 through 10,000,
then 1,000,000 through 1,000,099, inclusive. The first block has 9,900 observations;
the second has 100. Every observation has equal weight. The hash in results.json
covers the complete generated array encoded as compact JSON.

The p99 is sorted observation ceil(0.99 * 10000) = 9900: 10000 us, or 10 ms.
Observation 9901 is 1000000 us, or 1000 ms. Its inclusive normalized rank is
0.9901, differing by 0.0001 (0.01 percentage points); its value is 100 times
the exact p99. Relative value error is 99, or 9900%.

The three rows list candidate returned observations satisfying the selected rank
budget. They do not predict which value a real sketch returns. No parameter k,
randomization failure probability, throughput or memory measurement is inferred.

Nearest-rank quantiles and inclusive ranks are explicitly chosen. Duplicates can
occupy a rank interval; this unique-valued construction avoids that ambiguity.
Tests cover duplicate handling separately and preserve exact rational boundaries.

## Sources and scope

- Karnin, Lang and Liberty, Optimal Quantile Approximation in Streams (2016),
  definitions 1-2, compaction construction and Table 1:
  https://arxiv.org/abs/1603.05346
- Masson, Rim and Lee, DDSketch (PVLDB 2019), section 1 and definition 1:
  https://www.vldb.org/pvldb/vol12/p2195-masson.pdf
- Apache DataSketches, Understanding KLL Bounds:
  https://datasketches.apache.org/docs/KLL/UnderstandingKLLBounds.html
- Apache DataSketches, Sketching Quantiles and Ranks Tutorial:
  https://datasketches.apache.org/docs/QuantilesAll/SketchingQuantilesAndRanksTutorial.html

This is an explanatory counterexample, not a new theorem, paper replication,
library defect report or confidence interval for future storage traffic.
Source text and figures are not redistributed. Hesela's original calculation
and tests are provided under the MIT license in LICENSE.txt.
