When the problem arrives again

A correction that reads every row

A sliding least-squares window moves its answer by the update its entering and leaving rows imply and then corrects it once against all 24 rows it holds. The proposal was to read only the rows of highest leverage, a quarter of them, predicted to recover most of the full correction on a stationary stream. On every noisy stream it does the opposite: the answer ends with a relative error of order one — 2.8 at a noise level of one, where reading every row leaves 3.3·10⁻⁹ and not correcting at all leaves 9.4·10⁻⁴. Choosing the rows at random, by age or in rotation changes nothing. Leaving out one row of 24, the one of least leverage, still leaves 0.29. A correction is a Newton step whose fixed point is the answer only because the residual is orthogonal to all the columns summed over every row; read from some of the rows, its fixed point moves by the omitted rows' share of the residual, and the window settles there. Only on a stream with no noise, where every row's residual is zero at the answer, does a partial correction work.

Worth reading first: Stable once, and three thousand times · The projection and the right angle · Buying the accuracy back.

The step the two rows owe built a sliding least-squares window’s answer from the previous one. When the window drops its oldest row and takes a new one, the exact answer moves by (ATA)−1(A^{\mathsf T}A)^{-1} times the change those two rows make to the normal equations’ right-hand side, and that update costs two triangular solves with the factor the window keeps. It was not enough on its own: an update alone, corrected only every second step, sat a thousand times above the answer it could have had. One correction after it — compute the residual of all 24 rows, solve with the factor, add — ended 2.9 to 440 times below a fresh solve’s.

The essay asked whether the correction needs all 24 rows. “Between the two is a correction against the rows most likely to carry the error — the rows of highest leverage in the window … The prediction with a sign is that it recovers most of it on a stationary stream and little of it where the leverage moves.” A quarter of the rows would make the correction a quarter of the cost, and the update and the quarter together would read eight rows a step instead of twenty-six.

It recovers none of it. On every stream with noise in it, a correction against a quarter of the rows leaves an answer worse than no correction at all, by three orders of magnitude. The reason has nothing to do with which quarter.

The window and its reference

The streams are the earlier essays’: six columns of large integers, every column the first plus a perturbation of a chosen size, so that the columns are nearly collinear — κ(A)=3⋅106\kappa(A) = 3 \cdot 10^6 at the smaller perturbation and 3⋅1043 \cdot 10^4 at the larger — and a response formed from the columns plus integer noise at a stated level relative to the rows. A window of 24 rows slides along 1,024 of them. It keeps a Cholesky factor of ATAA^{\mathsf T}A updated and downdated a row at a time, moves its answer by the two-row update at every step, and then corrects it: compute the residual r=y−Aβr = y - A\beta of the rows chosen, form ASTrSA_S^{\mathsf T}r_S, solve with the factor, add. Every fiftieth step the answer is compared with the window’s exact coefficients, computed in rational arithmetic from the integer data, and the error is the largest relative error over the six coefficients.

A sliding least-squares window at κ(A) = 3·10⁶: the median error of its answer when each step's correction reads only the rows of highest leverage, against how many of the 24 it reads, at four noise levelsnoise 1: 6 rows 2.8, 12 rows 1.71, 18 rows 1.55, 23 rows 0.286, 24 rows 3.3·10⁻⁹; noise 10⁻⁴: 6 rows 3.07, 12 rows 2.35, 18 rows 0.902, 23 rows 0.284, 24 rows 6.06·10⁻⁹; noise 10⁻⁶: 6 rows 0.144, 12 rows 0.108, 18 rows 0.0393, 23 rows 0.0131, 24 rows 2.74·10⁻¹⁰; no noise: 6 rows 2.95·10⁻¹¹, 12 rows 1.88·10⁻¹¹, 18 rows 1.59·10⁻¹¹, 23 rows 1.58·10⁻¹¹, 24 rows 1.39·10⁻¹¹. With no correction at all, at noise 1, the error is 9.39·10⁻⁴.κ(A) = 3·10⁶23 of 24 rows, noise 10.29all 24, noise 13.3·10⁻⁹no correction, noise 19.4·10⁻⁴612182410⁻¹²10⁻¹⁰10⁻⁸10⁻⁶10⁻⁴10⁻²1rows the correction reads, of 24relative error, medianno correction, noise 1noise 1noise 10⁻⁴noise 10⁻⁶no noisethe last row is worth nine decadesa correction needs every row
Fig. 1 The median error of the window’s answer when each step’s correction reads only the rows of highest leverage, against how many of the 24 it reads, at four noise levels.

This figure reads the rows of highest leverage — each row’s aT(ATA)−1aa^{\mathsf T}(A^{\mathsf T}A)^{-1}a, computed from the factor the window already has, which the factor a sparse code keeps anyway showed is free — and varies how many: 6, 12, 18, 23 or all 24.

Three orders worse than doing nothing

At a noise level of one, reading 6 rows of highest leverage leaves a median error of 2.80; 12 rows, 1.71; 18 rows, 1.55; 23 rows, 0.286. Reading all 24 leaves 3.30⋅10−93.30 \cdot 10^{-9}. Not correcting at all leaves 9.39⋅10−49.39 \cdot 10^{-4}. So every partial correction measured is worse than none, and the last row is worth nine decades: from 23 rows to 24 the error falls from 0.286 to 3.3⋅10−93.3 \cdot 10^{-9}.

The noise level barely matters until it is very small. At 10−410^{-4} the partial errors are 3.07, 2.35, 0.902 and 0.284 — still of order one — against 6.06⋅10−96.06 \cdot 10^{-9} for all 24. At 10−610^{-6} they are 0.144, 0.108, 0.039 and 0.013, still ten million times the full correction’s 2.7⋅10−102.7 \cdot 10^{-10}. Only with no noise at all do they come down, to 3.0⋅10−113.0 \cdot 10^{-11}, 1.9⋅10−111.9 \cdot 10^{-11}, 1.6⋅10−111.6 \cdot 10^{-11} and 1.6⋅10−111.6 \cdot 10^{-11} — level with the full correction’s 1.4⋅10−111.4 \cdot 10^{-11}.

The median error of a sliding window's answer at κ(A) = 3·10⁶ for six ways of choosing the rows each step's correction reads, on a stream with noise and on a consistent oneno correction: noise 1 9.39·10⁻⁴, no noise 1.17·10⁻⁸; all 24 rows: noise 1 3.3·10⁻⁹, no noise 1.39·10⁻¹¹; 6 of highest leverage: noise 1 2.8, no noise 2.95·10⁻¹¹; 6 newest: noise 1 3.32, no noise 4.77·10⁻¹¹; 6 at random: noise 1 1.52, no noise 2.4·10⁻¹¹; a rotating quarter: noise 1 1.77, no noise 1.99·10⁻¹¹.10⁻¹²10⁻⁹10⁻⁶10⁻³10⁰relative error, median, logarithmicno correctionall 24 rows6 of highest leverage6 newest6 at randoma rotating quarternoise 1no noisethe choice of rows changes littleonly all of them, or no noise
Fig. 2 The median error for six ways of choosing the rows each step’s correction reads, at κ(A) = 3·10⁶, on a stream with noise one and on one with no noise.

The leverage was not the problem either. Choosing the 6 newest rows leaves 3.32 at noise one, 6 at random 1.52, and a rotating quarter — the rows whose index falls in the step’s residue class modulo four, so that every row is read once in four steps — 1.77. With no noise every one of them lands between 2.0⋅10−112.0 \cdot 10^{-11} and 4.8⋅10−114.8 \cdot 10^{-11}. Which rows are read changes the error by a factor of two. Whether all of them are read changes it by eight orders of magnitude, and whether there is noise by eleven.

Where a partial correction points

A correction is one step of Newton’s method on the window’s least-squares problem. With G=ATAG = A^{\mathsf T}A and the current answer β\beta, it adds d=G−1AT(y−Aβ)d = G^{-1}A^{\mathsf T}(y - A\beta). At the exact answer β∗\beta^\ast the residual r∗=y−Aβ∗r^\ast = y - A\beta^\ast is orthogonal to every column — that is the definition of the least-squares answer, the right angle the projection and the right angle measured to 10−1610^{-16} — so ATr∗=0A^{\mathsf T}r^\ast = 0, d=0d = 0, and the exact answer is the correction’s fixed point.

Read from a subset SS of the rows, the correction adds G−1AST(yS−ASβ)G^{-1}A_S^{\mathsf T}(y_S - A_S\beta) instead. At the exact answer that is G−1ASTrS∗G^{-1}A_S^{\mathsf T}r_S^\ast, and it is not zero. The sum ATr∗A^{\mathsf T}r^\ast vanishes because the rows’ contributions cancel, and a subset of them does not cancel. So the partial correction’s fixed point is not the answer: it is wherever ASTrSA_S^{\mathsf T}r_S vanishes, and the window, corrected every step, settles there.

For every subset size, noise level and conditioning: the sliding window's median error when corrected against the rows of highest leverage, against the error the same partial correction leaves when applied to the exact answerκ 3·10⁶, noise 1, 6 rows: drift 2.8, displacement 1.36; κ 3·10⁶, noise 1, 12 rows: drift 1.71, displacement 1.46; κ 3·10⁶, noise 1, 18 rows: drift 1.55, displacement 1.43; κ 3·10⁶, noise 1, 23 rows: drift 0.286, displacement 0.287; κ 3·10⁶, noise 0.0001, 6 rows: drift 3.07, displacement 1.24; κ 3·10⁶, noise 0.0001, 12 rows: drift 2.35, displacement 1.17; κ 3·10⁶, noise 0.0001, 18 rows: drift 0.902, displacement 0.911; κ 3·10⁶, noise 0.0001, 23 rows: drift 0.284, displacement 0.269; κ 3·10⁴, noise 1, 6 rows: drift 3.61, displacement 1.83; κ 3·10⁴, noise 1, 12 rows: drift 2.82, displacement 2.32; κ 3·10⁴, noise 1, 18 rows: drift 1.6, displacement 1.12; κ 3·10⁴, noise 1, 23 rows: drift 0.269, displacement 0.268; κ 3·10⁴, noise 0.0001, 6 rows: drift 0.129, displacement 0.0629; κ 3·10⁴, noise 0.0001, 12 rows: drift 0.0998, displacement 0.0593; κ 3·10⁴, noise 0.0001, 18 rows: drift 0.0341, displacement 0.0307; κ 3·10⁴, noise 0.0001, 23 rows: drift 0.0157, displacement 0.0149.10⁻²10⁻¹110¹10⁻²10⁻¹110¹displacement of the exact answer by one partial correctionthe window's drift, medianκ 3·10⁶, noise 1κ 3·10⁶, noise 10⁻⁴κ 3·10⁴, noise 1κ 3·10⁴, noise 10⁻⁴dashed: a factor of three either waythe drift is the fixed point
Fig. 3 For every subset size, noise level and conditioning: the window’s median error when corrected against the rows of highest leverage, against the error the same partial correction leaves when applied once to the exact answer.

The displacement can be measured directly: take the exact answer, apply one partial correction to it, and see how far it moves. Across all sixteen noisy cells — two conditionings, two noise levels, four subset sizes — the window’s median error is within a factor of 2.5 of that displacement, and on nine of them within a factor of 1.3. At κ(A)=3⋅106\kappa(A) = 3 \cdot 10^6, noise one and 23 rows, the displacement is 0.287 and the window sits at 0.286. The window is not drifting. It has converged, to the wrong fixed point, and stays there.

The size of the displacement is G−1G^{-1} applied to the omitted rows’ share of ATr∗A^{\mathsf T}r^\ast, which is to say the residual those rows carry, amplified by the inverse of a Gram matrix whose condition number is the square of 3⋅1063 \cdot 10^6. On a stream with noise of the size of the data, the omitted rows’ residual is of the size of the data too, and nine to twelve orders of amplification take it far past the size of the answer — which is why the error saturates at order one rather than growing further. A relative error of one is an answer of the wrong size altogether, and every noise level down to 10−410^{-4} produces one.

The fixed point is the subset’s own answer

The displacement has a simpler description than the formula, and it is worth measuring rather than deriving. A correction from rows SS with the whole window’s Gram matrix as its step is a linear iteration, β←β+G−1AST(yS−ASβ)\beta \leftarrow \beta + G^{-1}A_S^{\mathsf T}(y_S - A_S\beta), and since ASTASA_S^{\mathsf T}A_S is a part of GG the iteration contracts: its limit is the β\beta that makes AST(yS−ASβ)A_S^{\mathsf T}(y_S - A_S\beta) vanish, which is the least-squares answer of the rows in SS alone. A window corrected from a subset is solving a smaller problem — the subset’s — and solving it well.

So the drift should be the distance from the subset’s answer to the window’s, and both can be computed exactly in rationals from the integer data. At κ(A)=3⋅106\kappa(A) = 3 \cdot 10^6 and noise one, the 23-row subset’s answer is 0.303 from the window’s, and the window sits at 0.286; the 18-row subset’s is 1.63 away and the window at 1.55; the 12-row subset’s 2.37 and the window 1.71. At noise 10−410^{-4}, 0.283, 0.868 and 2.47 against 0.284, 0.902 and 2.35; at κ(A)=3⋅104\kappa(A) = 3 \cdot 10^4, 0.0158, 0.0363 and 0.115 against 0.0157, 0.0341 and 0.0998. On all nine the window is within a factor of 1.4 of the subset’s own answer. Leaving out the row of least leverage is asking for the least-squares fit of the other 23. The observation that cannot be removed found the quantity that governs taking one row out of a fit, 1−h1 - h for a row of leverage hh, as both a factorisation’s breakdown condition and a statistician’s warning, and one minus a leverage is a subtraction wrote the deletion’s effect on the answer as the omitted row’s residual divided by 1−h1 - h and carried through G−1G^{-1}. A small leverage makes that denominator close to one; it does not make the move small, because the move’s size is set by the residual and by G−1G^{-1}, and here G−1G^{-1} carries a condition number of 101310^{13}.

That is also why choosing rows by leverage, which sounded like the careful choice, is no better than choosing them at random. Leverage ranks rows by how much each pulls the fit; the subset’s answer differs from the window’s by how much the omitted rows pull, and on noisy collinear data even the gentlest pull, amplified that much, moves the answer by a sizeable fraction of itself. The quarter of highest leverage omits the three quarters of lowest, and three quarters of small pulls add to a large one.

No noise forgives everything

The sliding window's median error against the noise level at κ(A) = 3·10⁶, with no correction, with every step's correction reading 18 rows of highest leverage, and reading all 24no correction: 1: 9.39·10⁻⁴, 0.01: 9.44·10⁻⁴, 0.0001: 7.11·10⁻⁴, 0.000001: 3.45·10⁻⁵; 18 rows of highest leverage: 1: 1.55, 0.01: 1.57, 0.0001: 0.902, 0.000001: 0.0393; all 24 rows: 1: 3.3·10⁻⁹, 0.01: 3.42·10⁻⁹, 0.0001: 6.06·10⁻⁹, 0.000001: 2.74·10⁻¹⁰. With no noise at all: no correction 1.17·10⁻⁸, 18 rows of highest leverage 1.59·10⁻¹¹, all 24 rows 1.39·10⁻¹¹.10⁻⁶10⁻⁴10⁻²110⁻¹¹10⁻⁹10⁻⁷10⁻⁵10⁻³10⁻¹10¹noise, relative to the rowsrelative error, medianno correction18 rows of highest leverageall 24 rowsthe partial correction saturates at the answer's own sizeno noise is the only safe noise
Fig. 4 The window’s median error against the noise level at κ(A) = 3·10⁶: with no correction, with each step’s correction reading 18 rows of highest leverage, and reading all 24.

The exception is exact. On a stream with no noise, every window’s rows are consistent: there is a β\beta with y=Aβy = A\beta exactly, and at it every row’s residual is zero, not merely their weighted sum. Then ASTrS∗=0A_S^{\mathsf T}r_S^\ast = 0 for every subset, the partial correction’s fixed point is the answer, and the only difference between reading 6 rows and 24 is how fast the window gets there — which, step after step, it does. The answer the last window left met the same divide from the other side: carrying the previous step’s answer forward won only on data that agreed exactly, because only there did the exact answer stand still.

It is a sharp line rather than a gradual one. Between no noise and noise 10−610^{-6} the 18-row correction’s error goes from 1.6⋅10−111.6 \cdot 10^{-11} to 3.9⋅10−23.9 \cdot 10^{-2}, nine and a half decades, while the full correction’s moves from 1.4⋅10−111.4 \cdot 10^{-11} to 2.7⋅10−102.7 \cdot 10^{-10}. Any residual at all, amplified by G−1G^{-1}, is too much.

One row is not optional

The sliding window's median error with every step's correction reading 23 of its 24 rows, the one of least leverage left out, and reading all 24, against the noise level, at two conditionings23 of 24, κ 3·10⁶: 1: 0.286, 0.01: 0.287, 0.0001: 0.284, 0.000001: 0.0131; all 24, κ 3·10⁶: 1: 3.3·10⁻⁹, 0.01: 3.42·10⁻⁹, 0.0001: 6.06·10⁻⁹, 0.000001: 2.74·10⁻¹⁰; 23 of 24, κ 3·10⁴: 1: 0.269, 0.01: 0.335, 0.0001: 0.0157, 0.000001: 1.65·10⁻⁴; all 24, κ 3·10⁴: 1: 2.15·10⁻¹², 0.01: 1.65·10⁻¹², 0.0001: 1.64·10⁻¹³, 0.000001: 1.37·10⁻¹³.10⁻⁶10⁻⁴10⁻²110⁻¹²10⁻¹⁰10⁻⁸10⁻⁶10⁻⁴10⁻²1noise, relative to the rowsrelative error, median23 of 24, κ 3·10⁶all 24, κ 3·10⁶23 of 24, κ 3·10⁴all 24, κ 3·10⁴dashed: the better-conditioned streamone row is not optional
Fig. 5 The window’s median error with each step’s correction reading 23 of its 24 rows, the one of least leverage left out, and reading all 24, against the noise level, at two conditionings.

The better-conditioned stream softens this and does not remove it. At κ(A)=3⋅104\kappa(A) = 3 \cdot 10^4 the full correction reaches 10−1210^{-12} to 10−1310^{-13}, and leaving out the single row of least leverage leaves 0.269 at noise one, 0.335 at 10−210^{-2}, 1.6⋅10−21.6 \cdot 10^{-2} at 10−410^{-4} and 1.65⋅10−41.65 \cdot 10^{-4} at 10−610^{-6} — falling with the noise now, because the amplification is a hundred times smaller and the displacement no longer saturates, but nine orders above the full correction at every level.

Leverage cannot rescue a single omission because leverage measures how much a row moves the fit, and the displacement is the omitted row’s residual moved by the inverse Gram matrix. A row of low leverage with an ordinary residual still contributes a r∗a\,r^\ast to a sum that has to cancel exactly. Influence is decided before the data showed that leverage is a property of the design and not of the response; a correction’s target is a property of the response, row by row.

Three ways to economise, and the one that does not exist

A correction against every row at every step costs 24 row reads a step. There are three ways to read fewer. Read none, and the update’s own rounding is never removed: 9.4⋅10−49.4 \cdot 10^{-4} at noise one. Read all of them less often, as the step the two rows owe measured: correcting every second step leaves 7.9⋅10−57.9 \cdot 10^{-5} between corrections, twenty thousand times the every-step error, because the update’s rounding returns after a single unaided step. Or read some of them every step, as here, and the window solves a different problem: 0.29 to 3.3. The second is the least bad and the third is the worst, worse than doing nothing, because the first two leave the right answer’s error uncorrected while the third replaces the answer.

The rotating quarter shows that reading every row eventually is not the same as reading every row at once. Over four steps it reads all of them, and its error is 1.77. Each step moves the answer toward one quarter’s answer, the next step toward another’s, and the window chases four different fixed points in turn without ever being asked to satisfy all the rows at the same time. The cancellation that defines the answer happens inside one sum, and a sum split across steps has an answer that moves between its parts.

What the window was asking for

The sliding window's relative error every fifty steps along a stream at κ(A) = 3·10⁶ and noise 1, with three correctionsall 24 rows: median 3.3·10⁻⁹, worst 1.74·10⁻⁷; no correction: median 9.39·10⁻⁴, worst 0.00511; 18 of highest leverage: median 1.55, worst 6.85.noise 1all 24 rows, median3.3·10⁻⁹no correction, median9.4·10⁻⁴18 of highest leverage, median1.60200400600800100010⁻¹¹10⁻⁹10⁻⁷10⁻⁵10⁻³10⁻¹10¹steprelative errorall 24 rowsno correction18 of highest leverageevery fiftieth stepa steady displacement, not a drift
Fig. 6 The window’s relative error every fifty steps along a stream at κ(A) = 3·10⁶, with three corrections. The dial sets the noise.

Along the stream at noise one the three corrections never cross. All 24 rows hold the error between 4⋅10−114 \cdot 10^{-11} and 1.7⋅10−71.7 \cdot 10^{-7}; no correction lets the update’s rounding sit between 1.3⋅10−41.3 \cdot 10^{-4} and 5.1⋅10−35.1 \cdot 10^{-3}; 18 rows hold it between 0.145 and 6.85. The partial correction’s error is not accumulating — it is as large at the hundredth step as the thousandth — which is what a displaced fixed point looks like and what a drift does not.

So the earlier essay’s cost comparison was the wrong way round. The update reads two rows and is cheap and insufficient; the correction reads every row and that is what it is for. It is the step that checks the answer against all the data the window holds, and the repair the drift did not need found the same single correction from the window’s own rows reaching Householder’s accuracy because it read them all. A cheaper correction has to find its economy elsewhere — less often, as the earlier essay measured and found costly too, or in cheaper arithmetic for the residual — but not in fewer rows.

What one stream family does not show

One family of streams, collinear integer rows with a single response, at two conditionings and five noise levels, with a window of 24 rows over six columns. A window much wider than its column count holds more rows per unknown, and a quarter of a wider window is still many rows; the cancellation in ATr∗A^{\mathsf T}r^\ast is still exact only over all of them, but the displacement from omitting a few would be relatively smaller. The noise here is independent from row to row; noise correlated along the stream would make neighbouring rows’ residuals cancel partly among themselves, and a correction against the newest rows might do less badly. The error is the largest relative error over the six coefficients against an exact reference, so it reports the worst coefficient; on these streams the coefficients are of similar size and the worst is representative. And the subsets are chosen by leverage, age, chance or rotation; a subset chosen by the size of each row’s current residual would be a different rule, though its fixed point would still be a subset’s answer.

Still open: a residual that is cheaper, and a window that is wider

A residual computed in lower precision. A correction’s cost is reading every row and forming the residual. Computed in single precision and accumulated in double, the residual costs less to form and still sums over every row. The prediction with a sign is that a full correction with a single-precision residual ends within a factor of ten of the double-precision one at κ(A)=3⋅104\kappa(A) = 3 \cdot 10^4 and more than a hundred times above it at 3⋅1063 \cdot 10^6, where the residual’s own rounding, amplified by G−1G^{-1}, is the larger term.

A wider window. With 96 rows over the same six columns, the omitted rows’ share of ATr∗A^{\mathsf T}r^\ast is a smaller fraction of a sum with more terms. The prediction is that a correction reading 72 of the 96 rows still ends at least a thousand times above the full correction at noise one and κ(A)=3⋅106\kappa(A) = 3 \cdot 10^6, because the displacement shrinks only like the square root of the omitted rows’ count while the amplification stays at the square of the conditioning.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

Exact ground truthFixed-point iterationIterative refinementLeast-squaresLeverageLow-rank updateNormal equations