Fundamentals / Numerical mathematics / Inverse problems and least squares

Constraints, sparse signals and edge-preserving penalties

Derive a solution at a bound, a soft-threshold rule and the behaviour of a total-variation penalty at a material interface.

From first principles

Derive thresholding from an absolute-value penalty

A coefficient that can physically vanish can be estimated by balancing squared measurement mismatch against a penalty on its absolute magnitude. For a scalar reading \(y\), consider \(F(x)=\tfrac12(x-y)^2+\lambda|x|\) with \(\lambda\ge0\). On either open half-line the derivative is ordinary, giving candidates

\[x=y-\lambda\quad(x>0),\]
\[x=y+\lambda\quad(x<0).\]

When neither candidate has the assumed sign, the kink at zero must be checked. The left derivative at zero is \(-y-\lambda\) and the right derivative is \(-y+\lambda\). A convex minimum occurs there if these enclose zero, namely if \(|y|\le\lambda\). Combining the cases gives

\[x_*=\operatorname{sign}(y)\max(|y|-\lambda,0).\]

The shrinkage creates exact zeros and biases surviving amplitudes toward zero. Applying a similar penalty to differences between adjacent field values instead of to the field itself favours neighbouring sites that share one value while permitting isolated jumps.

Derivation and applications

Shrink a two-dimensional gradient while preserving its direction

At an image pixel or a mesh cell the inferred gradient can have two measured components. If the physical surface has no preferred coordinate axes, a rotationally invariant local penalty is proportional to the Euclidean length of the gradient vector. Consider the local optimization with equally scaled and equally precise components,

\[\min_{g\in\mathbb R^2}\ \frac12\|g-y\|_2^2+\lambda\|g\|_2,\qquad \lambda\ge0 .\]

For a fixed trial length \(r=\|g\|\), the data mismatch is minimized by making \(g\) parallel to \(y\), since this maximizes their dot product. For \(y\ne0\) write \(g=r y/\|y\|\). The remaining one-dimensional constrained problem is

\[\min_{r\ge0}\ \frac12(r-\|y\|)^2+\lambda r,\qquad r_*=\max(\|y\|-\lambda,0).\]

Thus both gradient components are attenuated by a common factor; if \(y=0\), the solution is zero directly. The componentwise absolute-value penalty gives a different rule,

\[g_*=\max(1-\lambda/\|y\|,0)y,\qquad (g_{\rm component})_i=\operatorname{sign}(y_i)\max(|y_i|-\lambda,0).\]

The first expression is for \(y\ne0\). A local gradient shrinkage step is used inside some total-variation algorithms, but arbitrary independently shrunk gradient vectors need not be differences of one global image. A full reconstruction must enforce consistency with the field and the measurement equations. Different component units or uncertainties likewise require a corresponding metric.

Worked example

Compare an inclined edge under two penalties

For measured gradient \(y=(3,4)\) and \(\lambda=2\), the isotropic solution has length \(5-2=3\) and vector \((1.8,2.4)\); its angle is unchanged. Applying componentwise shrinkage gives \((1,2)\) with angle \(63.4^\circ\), compared with the measured \(53.1^\circ\). The choice of penalty can therefore affect an estimated orientation.

Second application

Test whether a detection threshold depends on the grid axes

A second gradient has length \(1.2\) with \(\lambda=1\). Along an axis, both rules return length \(0.2\). Rotating it by \(45^\circ\) gives coordinates \((0.849,0.849)\). The isotropic rule still returns length \(0.2\), whereas componentwise thresholding returns zero because neither coordinate reaches one. An orientation-dependent disappearance can therefore be introduced by the estimator itself.

Physical constraints change the optimality test

An attenuation coefficient cannot be negative. In a convex inversion with lower bound zero, the unconstrained least-squares normal equations need not hold at a valid constrained solution. Consider minimising a differentiable \(F(x)\) with \(x_j\ge0\). At a free component the derivative must be zero. At a zero component only positive feasible perturbations exist, so the derivative must be nonnegative. Negative reconstructed cells cannot generally be repaired by clipping after inversion because the forward operator couples neighbouring parameters.

For example minimise \(\tfrac12[(x_1+x_2-1)^2+(x_1+1)^2]\) under \(x_i\ge0\). The unconstrained solution is \((-1,2)\). Clipping gives \((0,2)\), which overpredicts the first observation. On the active face \(x_1=0\), the minimising \(x_2\) is 1. At \((0,1)\) the gradient is \((1,0)\) and the bound conditions hold. The price of feasibility appears in the data residual; it is important to show which observations the constrained model cannot fit.

Derive the soft-threshold rule

For a scalar coefficient with observation \(b\), minimise \(\tfrac12(x-b)^2+\lambda|x|\). On \(x>0\) the stationary point is \(b-\lambda\), feasible there only when \(b>\lambda\); on \(x<0\) it is \(b+\lambda\). At zero, the admissible slopes of the absolute value range from \(-1\) to 1, so zero solves the condition when \(|b|\le\lambda\). Together these give

\[x=\operatorname{sign}(b)\max(|b|-\lambda,0).\]

Even retained coefficients shrink by \(\lambda\), a real amplitude bias. With \(b=(-0.2,0.7,2.4)\) and \(\lambda=0.5\), the estimate is \((0,0.2,1.9)\) for an identity forward map.

Penalise changes in a field

In one dimension discrete total variation is \(\sum_j|x_{j+1}-x_j|\). A single large jump and several monotone small steps spanning the same overall change have equal total variation. In contrast a squared difference penalty favours spreading the jump over several sites. That explains why total variation can preserve an abrupt edge when the data localise it. It can also create nearly constant plateaus in a field that really changes smoothly.

For two observed values \(b_1,b_2\), use the variables \(m=(x_1+x_2)/2,\ d=(x_2-x_1)/2\). With objective \(\tfrac12\sum(x_i-b_i)^2+\lambda|x_2-x_1|\), the optimal mean is the observed mean and half-difference is the soft-thresholded observed half-difference with threshold \(\lambda\). When \(|b_2-b_1|\le2\lambda\) the two estimated levels fuse. This concrete loss of resolution should be reported when interpreting a uniform patch in a reconstructed image.

Make an edge claim testable

Generate test fields both with a sharp jump and with a smooth ramp. Pass them through the same sensor model and noise level, then fit with the same strength-selection procedure used for real data. Measure contrast bias and edge-location error separately; an image can put an edge in the correct place but suppress its amplitude. For a nonnegative material field inspect the gradient at active zeros alongside the residual. The regulariser and the bounds each supply information that the instrument may not have measured.

Follow total variation through three coupled cells

Consider three ordered cell values observed directly with equal independent precision. Minimise \(\tfrac12\sum_i(x_i-b_i)^2+\lambda(|x_2-x_1|+|x_3-x_2|)\). Introduce edge variables \(s_1,s_2\) equal to the signs of nonzero differences. At a zero difference either variable may take any value between minus one and one. Differentiation with these admissible subgradients gives the three balances \(x_1-b_1-\lambda s_1=0,\ x_2-b_2+\lambda(s_1-s_2)=0,\ x_3-b_3+\lambda s_2=0\). A candidate solution must satisfy all three balances and must agree with the sign choices that produced it.

Adding the balances eliminates both internal edge forces. Consequently the reconstructed values have exactly the same sum as the observations, regardless of the penalty strength. The quadratic part is strictly convex, so any feasible sign assignment satisfying the balances proves that the state is the unique minimiser. Adding lower bounds can introduce reactions and break the sum identity. Unequal precision also changes which weighted average is conserved. The calculation depends on the observation operator being the identity; after blurring, the first derivative of the data term already couples all cells.

Derive the complete fusion path for a short profile

Take \(b=(0,1,5)^T\). For small positive \(\lambda\), both differences remain positive, so

\[s_1=s_2=1.\]

The equations give

\[x=(\lambda,1,5-\lambda)^T.\]

The first two coordinates meet at \(\lambda=1\), while the second and third are still unequal. Assume those first two now form a plateau of height \(a\), with \(s_2=1\). Adding their balances gives \(2a-1-\lambda=0\), hence \(a=(1+\lambda)/2\). The first equation then requires

\[s_1=a/\lambda=(1+\lambda)/(2\lambda),\]

which lies in the permitted interval exactly when \(\lambda\ge1\).

The third coordinate stays \(5-\lambda\). Equating it to the plateau gives \((1+\lambda)/2=5-\lambda\), or \(\lambda=3\). Beyond this value all three cells coincide, and sum conservation fixes them at two. The required subgradients are \(s_1=2/\lambda\) and \(s_2=3/\lambda\), both admissible for \(\lambda\ge3\). This completes the path without numerical optimisation. At strengths 0.5, 2 and 4 the respective profiles are \((0.5,1,4.5)\), \((1.5,1.5,3)\) and \((2,2,2)\).

The thresholds record when the data imbalance inside a proposed plateau can be supported by the admissible edge subgradients. A flat patch at the second strength is therefore compatible with unequal raw values of zero and one. Conversely, a visible third-cell edge at that strength has already lost much of its amplitude. A reconstruction report that uses one threshold for declaring the existence of a jump and another for estimating its amplitude should explain both decisions.

Checking the final all-fused solution using only its observed mean would miss the second edge constraint. For example at strength two that constant candidate would require \(s_2=1.5\), outside the admissible unit interval, despite reproducing total mass perfectly. The failed local balance tells which boundary of the candidate plateau has to reopen. This provides a simple hand diagnostic for more complicated one-dimensional reconstructions when an apparently reasonable flat interval has been proposed.

Choose how weak coefficients enter a reconstruction

For unit forward gain, minimise half squared data error plus either \(0.5|x|\) or \(0.5x^2/2\). Solve the derivative equation away from zero and use the subgradient at zero for the absolute-value penalty. Here the plotted input is the measured datum.

Choose how weak coefficients enter a reconstruction. Horizontal axis: Measured scalar coefficient. Vertical axis: Reconstructed coefficient. Data follow the figure.
A reading of 0.4 is suppressed entirely by the absolute-value penalty but becomes about 0.267 with quadratic shrinkage. A reading of 2 becomes 1.5 or 1.333 respectively. The weighting conventions matter when comparing penalties.
Read values from the plot
Reconstructed coefficient at selected values of Measured scalar coefficient.
Measured scalar coefficientUnpenalisedSoft threshold λ = 0.5Quadratic penalty λ² = 0.5
−2.2−2.2−1.7−1.4667
−1.1−1.1−0.6−0.73333
0000
1.11.10.60.73333
2.22.21.71.4667

Download all 301 plotted samples (CSV)

Change parameters · Choose how weak coefficients enter a reconstruction

Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.

Study the full derivation

Recovering sparse coefficients without hiding amplitude bias · Inferring parameters and fields from observations

A sensor records a linear mixture of a few active components. Derive the soft-threshold map, use it in an iterative reconstruction and decide when correlated response columns make an apparently sharp sparse answer ambiguous.