Conformal Prediction

Demonstration

Steinitz balancing

Order a zero-sum population so that every prefix sum stays inside a fixed ball. A random order wanders like \(\sqrt t\); a balanced order does not wander at all.

Take \(N\) vectors \(z_1,\dots,z_N\) in the plane with \(\sum_i z_i = 0\) and \(\|z_i\|\le 1\). Walk through them in some order and watch the running sum. Steinitz (1913) proved that a permutation always exists whose every prefix sum stays inside a ball whose radius depends on the dimension but not on \(N\). Divide by \(t\) and the running average is within \(C/t\) of zero at every step. That is the bounded-ledger mechanism: the error never accumulates, so the average dies at the fast rate.

The first panel shows the prefix-sum path through the plane for orderings of the same population: a uniformly random shuffle and a greedy balanced ordering (each step picks the remaining vector that keeps the running sum smallest). The second panel plots the prefix norm \(\|\sum_{j\le t} z_{\pi(j)}\|\) against \(t\). Random orderings grow like \(\sqrt t\); the balanced one hugs the floor. A checkbox adds an adversarial ordering (sorted by angle, so the walk goes on one long excursion before the zero sum drags it home); it grows linearly, and its scale is why it is off by default. The greedy rule shown is a heuristic; the Steinitz lemma guarantees that a bounded ordering exists, and in one dimension the balanced ordering is explicit (the next demo).

Takeaway. The population is fixed; only the order changes. Balance is a property of the permutation, and a good permutation makes the running average accurate at rate \(1/t\) with no randomness anywhere. This is the primal side of the duality in the note: conformal placements are exactly such a zero-sum population, and the next demo orders them.

How Steinitz proved it

The lemma has a lovely origin. Riemann’s rearrangement theorem says a conditionally convergent series of real numbers can be reordered to sum to anything. Lévy and then Steinitz asked what happens for series of vectors, and the answer, the Lévy–Steinitz theorem, is that the achievable sums form an affine subspace. The prefix-bounded ordering lemma was Steinitz’s workhorse: to steer a rearranged series toward a target you must walk through blocks of vectors without the partial sums escaping, and the lemma is that steering license.

The obstacle, visible in this demo, is that greedy cannot see the future: it minimizes the current prefix norm and can walk into a corner where every remaining vector points the wrong way. The proof (in the modern form of Grinberg and Sevastyanov, which gets the constant \(d\) in \(d\) dimensions) makes “the future is still fine” a maintained invariant. Build the ordering backwards, and at every stage keep a fractional escrow of the remaining walk: for the current set of \(t\) remaining vectors, weights \(\lambda_i\in[0,1]\) with \(\sum\lambda_i=t-d\) and \(\sum\lambda_i z_i=0\). In words: fractionally, all but \(d\) units of the remaining mass can already be arranged to cancel exactly.

Two facts finish it. The weights always exist and survive peeling: the feasible \(\lambda\) form a polytope cut out by only \(d+1\) equalities, and a vertex of such a polytope has at most \(d+1\) coordinates strictly between 0 and 1, so one element with small weight can always be removed and the rest re-certified. Peel one element at a time; the peeled order, reversed, is the ordering. And the bound falls out in one line: the actual sum of the \(t\) remaining vectors equals \(\sum(1-\lambda_i)z_i\), since the \(\lambda\)-weighted part cancels, and \(\sum(1-\lambda_i)=t-(t-d)=d\), each vector of norm at most 1, so every prefix sum has norm at most \(d\). The dimension enters exactly once, as the number of coordinates a polytope vertex can leave fractional.

The moral: greedy keeps the past small; Steinitz keeps a certificate that the future can still be balanced, and only takes steps that preserve the certificate. That look-ahead is what the scalar conformal case does not need: with two values and one dimension, the balanced word writes the future down explicitly. The sharp constant is still unknown: in the Euclidean plane it is \(\sqrt5/2\), in general dimension the Grinberg–Sevastyanov \(d\) is essentially the record, and whether \(O(\sqrt d)\) is possible is open, next door to the Komlós conjecture in discrepancy theory.

Using conformal prediction in your own project? Tell Claude: “Read https://conformalprediction.net/SKILL.md and create a project skill from it.” It adds a check for whether your coverage is conditionally trustworthy.