Regularisation, and the answer that is chosen

When the answer is a choice

A backward-stable least-squares solve of this problem returns an answer whose relative error is 5.5·10⁸. Nothing went wrong. The singular values decay exponentially with no gap anywhere in them, the data does not determine the answer, and something outside the data has to choose — which is the computation rather than a preliminary to it.

Worth reading first: The projection and the right angle · The best approximation there is.

Every solve on this site so far has had one answer, and the only question was how accurately it was reached. Even the valley with no bottom, which found that the coefficients of a degree-9 fit can be moved 39% of their own size along the worst singular direction before the residual changes in the sixth digit, was measuring how flat a minimum is — there was still a minimum.

This field is about the problems where that is false. The data is consistent with a range of solutions differing by orders of magnitude, no arithmetic can choose between them, and something outside the data has to.

The choice is the computation. It is not a preliminary to it, it is not a matter of taste, and it cannot be avoided by using better arithmetic — which is what makes this field belong on a site whose premise is that the algorithm’s contribution and the problem’s are separately measurable. Here the algorithm’s contribution is zero and the answer is still wrong by eight orders of magnitude.

Two filters on one sum, λ = 0.01The weight each term of the solution is given, against its index. Truncation is a step: one for the first 26 terms and zero after. Tikhonov is σ²/(σ² + λ²), which falls smoothly through the same place. The unregularised solution is the constant one, which is why it divides noise by a σ of 1.7·10⁻¹³.081624324048566400.250.50.751index kfilter factor fₖno regularisation: fₖ = 1truncationTikhonovthe same sum, three weightsTikhonov, relative error0.11truncation, relative error0.11no filter at all5.5·10⁸both filters are one expression with a different weightfₖ = 1 is the catastrophe
Fig. 1 The weight each term of the solution is given, against its index. Truncation is a step: one for the first terms and zero after. Tikhonov is σ²/(σ² + λ²), which falls smoothly through the same place. The unregularised solution is the constant one — which is why it explodes.

The problem

A one-dimensional deconvolution. A signal is blurred by a Gaussian kernel and the blurred version is measured with 0.1% noise; the task is to recover the signal.

The signal is two smooth bumps and a step, and the step is deliberate: a smooth signal is recovered well by every method here and would hide the differences between them. The blur matrix is symmetric Toeplitz — the same object the structure field is built on, arriving here for a completely different reason — with each row normalised to sum to one, so the operator preserves a constant and the difficulty is entirely about the smoothing.

The exact signal is known because the problem was constructed, so the forward error is known rather than estimated. That is the same move exact.js makes with the Hilbert matrix and it is worth as much here: without it, every parameter-choice rule in the third essay could only be compared with the others.

Ill-posed is not the same as ill-conditioned

The distinction is the field’s foundation and it is routinely collapsed.

An ill-conditioned problem has a large condition number. It amplifies perturbations, the amplification is computable, and the site has been measuring it since its foundation phase: a 13×13 Hilbert system with κ = 1.7·10¹⁸ returns 0.049 where 8 belongs, and the algorithm is blameless.

An ill-posed problem is worse in a specific way. Its singular values decay to zero smoothly, with no gap anywhere, so there is no rank to find and no threshold to set. Three measurements say so here:

The decay is exponential rather than a power. Fitting log σ against k gives R² = 0.930; fitting it against log k gives 0.610. A matrix whose σ fall like 1/k is ill conditioned and has a numerical rank; one whose σ fall like exp(−k²) has neither.

There is no gap. The largest ratio between consecutive singular values over the usable range is under 4. Rank is a decision establishes that a numerical rank is a decision about a gap and that the gap is worth printing beside it. Here the point is that there is not one — every threshold is as defensible as every other, which is the same statement as the answer is a choice.

And the unregularised answer is worse than returning zero. A Householder least-squares solve — the best-conditioned route this site has, the one the road that squares the problem recommends over the normal equations — returns a relative error of 5.5·10⁸. Not 5.5, not 550. Five hundred and fifty million times the size of the signal it was asked to recover.

κ is 5.7·10¹². The algorithm’s backward error is at the level of rounding. The identity forward error ⪅ condition number × backward error accounts for the whole of it, and the account contains no error on anybody’s part.

What a rank-10 approximation can achieve, by spectrumA semi-logarithmic plot of singular value against index for three spectra — geometric decay, algebraic decay, and flat — with the rank-ten approximation error marked on each.1112131415110⁻³10⁻²10⁻¹1index jσⱼσ11geometric, 0.85ʲalgebraic, j^−0.00flatmeasured, and equal to σ₁₁rank-10 error, geometric0.2rank-10 error, algebraic1rank-10 error, flat160×60, spectrum chosen rather than the entriesthe matrix decides, not the method
Fig. 2 Which of three cases a matrix is in, from the randomised field. A spectrum with a gap has a rank; one that decays as a power is compressible; one that decays smoothly to rounding with no gap anywhere is this field’s subject, and no threshold in it is more defensible than any other.

One expression, two filters

Both standard methods are the same sum with a different weight:

x_reg  =  Σₖ fₖ · (uₖᵀb / σₖ) · vₖ

Truncated SVD: fₖ = 1 for the first K terms and 0 after. Tikhonov: fₖ = σₖ²/(σₖ² + λ²), which is nearly one when σ ≫ λ and nearly σ²/λ² when σ ≪ λ. No regularisation at all: fₖ = 1 for every k.

That last line is the diagnosis. The unregularised solution is the same sum with every weight set to one, so its last terms are uₖᵀb divided by a σ of 10⁻¹⁶ — and uₖᵀb down there is not signal, it is the noise. Dividing noise by 10⁻¹⁶ is the whole of the 5.5·10⁸.

Writing the two methods as one expression is not tidying-up. It makes the comparison between them a comparison of weights rather than of methods, and it is enforced by there being exactly one implementation of the sum in lib/regular.js: both routines produce an f and hand it to the same function. Two methods that differ by one line cannot differ in any way the essay has not accounted for.

It is also what makes the figure possible. A plot of two solution vectors would show two curves that both roughly resemble the signal; a plot of two filters shows what the methods actually do, which is decide how much of each singular direction to believe.

How far the coefficients can move without changing the fit, degree 9Relative increase in the residual against relative change in the coefficients, along the least determined direction. The residual does not move measurably until the coefficients have changed by more than a factor of one.10⁻⁴10⁻³10⁻²10⁻¹110¹10²10³10⁻¹⁶10⁻¹³10⁻¹⁰10⁻⁷10⁻⁴10⁻¹relative change in the coefficients, along the worst directionrelative increase in the residualcoefficients doubled39% change, fit unmoved in the sixth digit308×: the third digit movesκ(A) = 3.6·10⁶. Exact arithmetic would pick one point on this floor. It would not raise it.24 points, degree 9, monomial basisthe data leaves them free
Fig. 3 The measurement this field is the answer to. A degree-9 fit’s coefficients can be moved 39% of their own size along the worst singular direction before the residual changes in the sixth digit — the minimum is real and the valley round it is flat, and something outside the data has to choose a point in it.

The two routes

The filter-factor sum goes through the SVD. A solver takes a different route entirely: form the stacked least-squares problem

[ A  ]        [ b ]
[ λI ] x  ≈   [ 0 ]

and solve it with a QR. Same answer, no SVD anywhere, and the arithmetic shares nothing with the first route.

They agree to a relative difference of 4.4·10⁻¹⁵ at λ = 0.1, rising to 5.2·10⁻¹² at λ = 10⁻⁴ — which is the two routes to a number habit doing what it is for, and is what makes the filter picture safe to build the field’s whole exposition on.

The stacked route has something the sum does not, and it is worth more than a second opinion. Its condition number has a closed form: the singular values of [A; λI] are √(σₖ² + λ²), so

κ  =  √((σ₁² + λ²)/(σₙ² + λ²))

which is asserted as an equality against the measured κ and agrees to fifteen digits. Regularising does not only change the answer that comes back; it changes the problem handed to the solver. At λ = 0.1 the stacked system’s κ is 10.07 against the original’s 2.9·10¹².

The first version of that assertion used the bound everyone quotes, κ ≤ σ₁/λ, and failed: 10.0659 measured against 10.0161 claimed. The bound is too tight by exactly the +λ² in the numerator. A closed form has no such approximation in it, and this is the reason to prefer one over the memorable version.

What regularisation actually does to the signal

The honest presentation, and the one a filter plot cannot give.

The recovered signal at three λ, 0.10% noiseThree recovered signals against the truth. At the best λ the two bumps are recovered and the step is rounded off. Fifty times smaller and the answer is dominated by amplified noise; fifty times larger and the step has gone entirely. The step is the feature that costs the most to represent and it is the first thing any filter loses.0816243240485600.511.5positionvaluethe truthbest λtoo littletoo mucheither side of the bestbest λ, relative error0.11fifty times smaller0.73fifty times larger0.15the step is the first thing every filter losesand it does not come back
Fig. 4 The recovered signal at three λ against the truth. At the best available λ the two bumps are recovered and the step is rounded off. Fifty times smaller and the answer is dominated by amplified noise; fifty times larger and the step has gone entirely.

Even at the best λ available, the step never comes back sharp. That is not a failure of the parameter choice and no better rule fixes it: the blur has destroyed the components that represent an edge, and no filter over the remaining ones can put them back. What less noise buys is a better rounded corner, not a corner.

So regularisation does not remove noise. It removes the ability to represent whatever the filter cut off, and the signal pays too. The essay’s title is meant literally: choosing λ is choosing which features of the answer to give up, and there is no value of it that gives up none.

The two failure directions are not symmetric either, and the figure asserts both. Under-regularised, the answer’s norm is larger than the truth’s — the amplified noise has to go somewhere. Over- regularised, it is smaller. That asymmetry is what the L-curve of the third essay is a picture of.

Least squares by QR and by the normal equations in binary32Relative error of the computed coefficients against epsilon, on log axes. The QR route is a flat line near the bottom; the normal-equations route climbs and then stops, at the epsilon where the cross-product matrix becomes exactly singular.10⁻⁸10⁻⁷10⁻⁶10⁻⁵10⁻⁴10⁻³10⁻²10⁻¹10⁻⁹10⁻⁷10⁻⁵10⁻³10⁻¹10¹ε in Läuchli's matrix (smaller ε, larger κ)relative error in the coefficientsAᵀA exactly singularnormal equationsQRκ from 1.7·10⁸ to 17the cliff is at √u = 2.4·10⁻⁴
Fig. 5 The advice that does not help here. Forming AᵀA squares the condition number and the QR route avoids it — a real improvement, worth taking, and invisible next to a forward error of 5.5·10⁸. Both routes return useless answers to this problem in slightly different ways.

Why a better solver is not the answer

The refusal at the end of lib/regular.js is fed the claim that a backward-stable method solves an ill-posed problem accurately, and requires it to fail.

That refusal is doing more work than most on this site, because the claim is the natural reading of everything the earlier fields establish. The road that squares the problem says: do not use the normal equations, use QR. Two Gram–Schmidts says: use Householder, not the classical process. Each of those is a real improvement and each is worth taking.

None of them touches this. The QR route and the normal-equations route on this problem return answers that are both useless, in slightly different ways, and the difference between them is invisible next to the 5.5·10⁸ they share. There is a whole class of problem on which every piece of advice the earlier fields give is correct and irrelevant, and recognising which class a problem is in is the first thing this field is for.

The knob is not the knob

One more refusal, and it is about the parameter rather than the method. λ = 0 is not the gentle end of the regularisation knob — it is off the end of it, and returns the 5.5·10⁸ catastrophe. The generator refuses it rather than drawing it as a mild case.

That is the same shape as tau = 0 in the sparse pivoting field, where the threshold rule accepts a pivot created by fill and cancellation, ‖PA − LU‖/‖A‖ reaches 2.5·10¹¹ and the solve returns infinities. Both knobs look continuous and both have a point at one end where the method stops being the method. Every real code has a floor for the same reason.

The condition number is not the whole story either

Worth being precise, because κ = 5.7·10¹² is the number a reader will reach for and it does not by itself say ill-posed.

The 13×13 Hilbert matrix has κ = 1.7·10¹⁸ — six orders of magnitude worse — and its system is perfectly well posed: there is one right answer, this site knows it exactly through exact.js, and the reason the float solve fails to find it is entirely accounted for by the amplification. Give the same system to a solver with enough precision and the answer comes back.

Give this one more precision and it does not. The obstruction is the noise in b, and no amount of arithmetic removes it: the coefficients of the noise in the trailing singular directions are what they are, and they get divided by σ ≈ 10⁻¹⁶ in exact arithmetic just as surely as in floating point. A hundred-digit solve of this problem returns a hundred-digit-accurate answer to the wrong question.

That is the sharpest available statement of the difference. Ill-conditioning is a property of the matrix and precision is its remedy. Ill-posedness is a property of the matrix and the data together, and there is no remedy — only a choice about what to give up.

It is also why this field’s essays report the forward error throughout and the earlier fields report the backward one. A backward error here is uninformative by construction: every method in this field has one at the level of rounding, including the one that returns 5.5·10⁸.

What each filter is good at

Neither is uniformly better, which is why both are still in use, and the figure’s drag is what shows it rather than an argument.

Truncation is a decision and Tikhonov is a weighting. Truncation keeps K terms whole and discards the rest, so its answer lies exactly in a K-dimensional subspace and can be reported as such — which matters when the components are interpretable. Tikhonov keeps a fraction of everything, so its answer has a component in every direction, most of them tiny.

Truncation has a discrete parameter. There are only n choices and they can all be tried, which is what makes the Picard analysis of the next essay possible at all. Tikhonov’s λ is continuous, and choosing it is the third essay.

And Tikhonov never has to form the SVD. The stacked route above is a QR of a 2n×n matrix, which is affordable at sizes where an SVD is not, and is what any large-scale implementation actually does. The filter picture is the right way to understand both methods and the wrong way to compute either at scale.

The measured errors on this problem, at the matched parameters the figure draws, are within a few per cent of each other. The choice between them is about what the answer is for rather than about accuracy.

Backward and forward error against the condition numberA log–log plot over twelve decades of condition number. The backward error is a flat line at ten to the minus sixteen; the forward error rises in proportion to the condition number.110²10⁴10⁶10⁸10¹⁰10¹²10¹⁴10⁻¹⁷10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²10¹condition number κ(A)relative errorforward errorbackward errorpredicted: κ · u8×8, 20 seeds per κ; dashed is the worstthe problem worsens, not the method
Fig. 6 The identity this field’s headline number is accounted for by. The backward error sits flat at the level of rounding across twelve decades while the forward error climbs with κ — and on an ill-posed problem the first is uninformative by construction, which is why every essay here reports the second.

What the blur is standing in for

The problem drawn is a one-dimensional Gaussian deconvolution, and the choice of it is a simplification worth naming.

Every real instance of this is at least two-dimensional. An image restored from a blurred photograph, a computed tomogram, a seismic inversion, an unfolding of a detector response — all of them are integral equations of the first kind discretised, and all of them have singular values that decay to zero with no gap, which is the only property this field uses. What the two-dimensional versions add is size: a 512×512 image is a quarter of a million unknowns, and forming an SVD of the operator is impossible.

That does not change any statement in this field and it changes every implementation of them. The filter picture is still the right way to understand what Tikhonov does; it is not the way anybody computes it at that size. The stacked-QR route scales further, and past that the methods are iterative — conjugate gradients on the normal equations, stopped early, which turns out to be itself a regulariser with its own filter factors, and the iteration count becomes the parameter.

That last observation is the one this field most obviously does not reach, and it is a satisfying one: the iterative field’s whole subject is how fast an error falls, and on an ill-posed problem the error falls and then rises, because the later iterations are reconstructing the noise. Stopping is the choice, and it is the same choice as choosing λ wearing different clothes.

Singular values of a rank-4 matrix with noise of relative size 10⁻⁸Ten singular values on a logarithmic axis. The first four sit near one; the rest sit at the noise level, and the vertical distance between the two groups is the evidence for the rank.1234567891010⁻¹⁸10⁻¹⁵10⁻¹²10⁻⁹10⁻⁶10⁻³1indexsingular valuecutoff, σ₁ · 10⁻¹⁰numerical rank 10gap 8.2·10⁶an opiniontrue rank 410×10, built with 4 nonzero valuesrank is a decision
Fig. 7 The case with a gap, for comparison. Ten nonzero singular values and a cliff, so a threshold anywhere in the cliff gives the same rank — a decision about a matrix. This field’s threshold is a decision about a measurement, and it moves with the noise on the same operator.

Two thresholds, side by side

Worth putting next to each other, because this site now has both and they are routinely confused.

Rank is a decision sets a threshold on σ to decide a rank: which directions the matrix genuinely spans. The matrix there has a gap — ten nonzero singular values and a cliff — and the decision is about where in the cliff to cut.

This field sets a threshold on σ to decide a filter: how much of each direction to believe. There is no cliff, so the threshold is not finding a structure in the matrix. It is trading two errors against each other, and the trade depends on the noise in the data rather than on the matrix at all.

The same arithmetic — compare σₖ against a number, keep or discard — answering two different questions, one about an operator and one about a measurement. Which is why the next essay is about the right-hand side rather than about the matrix.

Singular values and |uₖᵀb|, with and without 0.10% noiseThree curves against the index on a logarithmic vertical axis. The singular values fall exponentially to the level of rounding. With an exact right-hand side the coefficients fall faster and every term of the solution stays bounded. With noise they flatten at index 32, and from there on each term is noise divided by a σ of 6.8·10⁻⁴.081624324048566410⁻¹⁷10⁻¹⁴10⁻¹¹10⁻⁸10⁻⁵10⁻²10¹index kmagnitudethe floor: k = 32best truncation: k = 28σₖ|uₖᵀb| exact|uₖᵀb| with noisetwo different indicesthe crossing, from the data alone32the truncation that is actually best28relative error there0.11the exact coefficients never flattenthe noisy ones stop at ‖e‖/√n
Fig. 8 Where the weight should fall, which this essay does not say and the next one measures. The singular values fall whatever happens; the coefficients of the noisy right-hand side stop falling at the noise floor, and everything beyond that index is noise divided by something small.

What is left

Where the answer stops being in the data, which is the next essay: the Picard condition, which is computable from the data alone and says whether there is a solvable problem here at all — and which turns out to identify the wrong index by a consistent margin.

Choosing λ without knowing the answer, which is the third and is where the field’s measurements against an oracle live.

And the general-form problem. Everything here penalises ‖x‖, which is a statement that the answer should be small. The general form penalises ‖Lx‖ for some operator L — usually a derivative, which is a statement that the answer should be smooth — and it is what anybody solving a real deconvolution uses. The reduction to the standard form is a generalised SVD, and none of it is here; the choice of L is a stronger and less examinable assumption than the choice of λ, which makes it a subject rather than an omission.

What links here

Computed from the collection, not written here: the essays that point at this one.

Reads more easily once this is understood

Essays that name this one as worth reading first.

Named objects

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

Condition numberDeconvolutionFilter factorsIll posed problemRegularisationSingular value decompositionTikhonov regularisationTruncated svd