# Monotone estimates and capacity anomalies

This note contains Hesela's derivation from existing integer counts, not a
replication or implementation of Kosmo.

For capacities c[0] < ... < c[k-1], let y[i] = misses[i] / requests,
with a shared positive request denominator. Seek a nonincreasing vector z
minimizing max_i |y[i] - z[i]|.

Let D = max(0, max_{i<j}(y[j] - y[i])). Any such z has error E >= D/2:
y[j]-y[i] = (y[j]-z[j]) + (z[j]-z[i]) + (z[i]-y[i]) <= 2E.
This needs neither a stochastic model nor a claim about how often an anomaly occurs.

The bound is attained on the supplied capacities. Set E = D/2 and
z[i] = max(0, max_{j>=i}(y[j]-E)).
Suffix maxima make z nonincreasing and at least y[i]-E. For every j>=i,
y[j]-y[i] <= 2E, so z[i] <= y[i]+E; clipping at zero preserves this
because all y[i] are nonnegative. Values also remain at most one.
This proves the optimum, not merely a necessary pairwise condition.

The implementation finds the largest increase using a running prefix minimum,
then constructs an attaining fit using suffix maxima. Both passes are linear
in the number of supplied capacities; rational arithmetic retains exact counts.
The independent test enumerates every three-point curve with counts 0..4 and
all nonincreasing fits on the half-count grid. It checks the optimum and fit,
including nonadjacent violations and counts above floating-point exactness.

Existing evidence: cache-capacity.json, trace ABCDABEABCDE, 12 requests,
FIFO counts 12,12,9,10,5 at capacities 1,2,3,4,5 object slots.
At slots three and four the optimum fit is 19/24 at both, with error 1/24
(25/6 percentage points). This is maximum absolute error, not MAE.
The chosen fit is only an existence witness, not a prediction of Kosmo output.

Run, without additional packages:
    python3 monotone-mrc.py
    python3 monotone-mrc.test.py
    python3 -O monotone-mrc.test.py

Keep cache-capacity.json beside these files. The result includes the input
and generator SHA-256 digests. It does not regenerate or relabel the older
cache experiment. Paper PDFs, figures and upstream code are not redistributed.

Source map (checked 2026-11-01):
- Kosmo: https://www.usenix.org/system/files/fast24-shakiba.pdf
  FAST 2024 pp. 89-105; sections 1, 3.1-3.2, 4, 4.5.
- Miniature Simulations:
  https://www.usenix.org/system/files/conference/atc17/atc17-waldspurger.pdf
  USENIX ATC 2017 pp. 487-498; sections 1.1 and 2.

Editorial decision: the corpus record distinguishes estimator shape from
eviction policy. No universal efficiency ranking, CPU or memory multiplier,
new algorithm, population uncertainty, DOI, or independent review is claimed.
The performance results in either source are not Hesela measurements.

License: MIT for this original derivation, code and generated arithmetic.
Copyright (c) 2026 Hesela. See sieve-traces.LICENSE.txt for the license text.
