Skip to content
QFT.org

Search QFT.org

Enter a word or phrase.

    You can also browse the main navigation and chapter contents.

    Correlated Least Squares and Regularization

    A spectral reconstruction can predict every measured correlator reasonably well and still give an unusable density. Regularization controls the poorly measured directions, but its strength and reference spectrum become part of the estimator. Estimating the covariance introduces another source of uncertainty.

    This article derives correlated least squares, truncated SVD and Tikhonov regularization, then applies them to one fixed noisy experiment. The results include a failure: a predeclared generalized-cross-validation rule occasionally chooses extreme underregularization. We retain those cases and compare their predictive accuracy with their spectral errors. An exact two-parameter fit shows what additional model information can buy.

    Preparation: the positive spectral benchmark and whitened singular directions, covariance, and constrained optimization. For explicitly positive estimators, continue to maximum entropy; for a target chosen before inversion, see smeared spectra.

    The observation model determines the residual norm

    Our continuous truth is the normalized two-triangle spectrum

    s(E;d,w)=w pb(E;2−d/2)+(1−w)pb(E;2+d/2),pb(E;μ)=(1−∣E−μ∣/b)+/b,b=0.2.\begin{aligned} s(E;d,w)&=w\,p_b(E;2-d/2)+(1-w)p_b(E;2+d/2),\\ p_b(E;\mu)&=(1-|E-\mu|/b)_+/b, \qquad b=0.2. \end{aligned}

    The true parameters are (d,w)=(1.2,0.6)(d,w)=(1.2,0.6); all support lies in [0,4][0,4]. Its exact correlator is

    C(t;d,w)=[sinh⁡(bt/2)bt/2]2e−2t[wedt/2+(1−w)e−dt/2].C(t;d,w)= \left[\frac{\sinh(bt/2)}{bt/2}\right]^2 e^{-2t}\left[we^{dt/2}+(1-w)e^{-dt/2}\right].

    At ti=0.15it_i=0.15i, i=1,…,16i=1,\ldots,16, observe y=C+ϵy=C+\epsilon, where ϵ∼N(0,Σ)\epsilon\sim N(0,\Sigma). We use

    Σij=δ2CirefCjref[12e−∣i−j∣/2+12δij].\Sigma_{ij}=\delta^2 C_i^{\rm ref}C_j^{\rm ref} \left[\tfrac12e^{-|i-j|/2}+\tfrac12\delta_{ij}\right].

    The fixed reference is the primary truth at the nominal times. It does not change with fitted parameters. The three declared noise levels are δ=0.003\delta=0.003, δ=0.01\delta=0.01, and δ=0.03\delta=0.03.

    For a proposed mean f(θ)f(\theta), the negative Gaussian log likelihood, up to constants independent of θ\theta, is

    12χ2(θ)=12[y−f(θ)]TΣ−1[y−f(θ)].\frac12\chi^2(\theta) =\frac12[y-f(\theta)]^T\Sigma^{-1}[y-f(\theta)].

    Writing Σ=LLT\Sigma=LL^T gives χ2=∥L−1[y−f(θ)]∥2\chi^2=\lVert L^{-1}[y-f(\theta)]\rVert^2. Solve with the triangular factor; an explicit covariance inverse is unnecessary. Whitening accounts for both unequal variances and correlations. Replacing Σ\Sigma by its diagonal changes the statistical problem.

    Normalization and the reference spectrum

    Represent a density by MM constant bins of width h=4/Mh=4/M using the orthonormal functions ej=1j/he_j=\mathbf1_j/\sqrt h. Let xjx_j be its coefficients. Then

    ∥sM∥L22=xTx,Kij=e−tiEj−e−tiEj+1tih.\lVert s_M\rVert_{L^2}^2=x^Tx,\qquad K_{ij}=\frac{e^{-t_iE_j}-e^{-t_iE_{j+1}}}{t_i\sqrt h}.

    The exact normalization constraint is aTx=1a^Tx=1, with aj=ha_j=\sqrt h. Choose a normalized reference xrefx_{\rm ref} and an orthonormal basis ZZ for aTZ=0a^TZ=0:

    x=xref+Zz,A=L−1KZ,dy=L−1(y−Kxref).x=x_{\rm ref}+Zz,\qquad A=L^{-1}KZ,\qquad d_y=L^{-1}(y-Kx_{\rm ref}).

    This removes the constraint before fitting. Our main reference is the uniform density. We also test the normalized density 3E(4−E)/323E(4-E)/32, integrated into the bins.

    The bin truth used for parameter errors is the orthogonal projection of the continuous triangle spectrum. Its bin masses are obtained from the exact triangular CDF. Since the generating density is not constant in each bin, the forward discrepancy Kxproj−CtrueKx_{\rm proj}-C_{\rm true} and the projection error are separate from noise.

    In particular,

    ∥sest−strue∥L22=∥xest−xproj∥2+∥sproj−strue∥L22.\lVert s_{\rm est}-s_{\rm true}\rVert_{L^2}^2 =\lVert x_{\rm est}-x_{\rm proj}\rVert^2 +\lVert s_{\rm proj}-s_{\rm true}\rVert_{L^2}^2.

    The second term is independent of the estimator. It equals 0.1083330.108333, 0.02708330.0270833, and 0.006770830.00677083 for M=40M=40, M=80M=80, and M=160M=160, respectively. This comparison avoids generating truth on the same grid used for inversion.

    Truncation and damping of singular directions

    Let A=Udiag⁡(σk)VTA=U\operatorname{diag}(\sigma_k)V^T. With no regularization, a coefficient along vkv_k contains (ukTdy)/σk(u_k^Td_y)/\sigma_k. A small singular value amplifies unit-variance whitened noise.

    Truncated SVD retains only rr directions:

    z^r=∑k=1rukTdyσkvk.\widehat z_r=\sum_{k=1}^{r} \frac{u_k^Td_y}{\sigma_k}v_k.

    Tikhonov regularization instead minimizes

    ∥Az−dy∥2+α2∥z∥2,\lVert Az-d_y\rVert^2+\alpha^2\lVert z\rVert^2,

    and gives

    z^α=∑kσkσk2+α2(ukTdy)vk,Hα=Udiag⁡(σk2σk2+α2)UT.\begin{aligned} \widehat z_\alpha &=\sum_k\frac{\sigma_k}{\sigma_k^2+\alpha^2} (u_k^Td_y)v_k,\\ H_\alpha&= U\operatorname{diag}\left( \frac{\sigma_k^2}{\sigma_k^2+\alpha^2} \right)U^T. \end{aligned}

    Here HαdyH_\alpha d_y is the fitted whitened mean. Truncation makes a sharp choice of directions; Tikhonov damps them continuously. Both formulas are evaluated by SVD, without forming ATAA^TA. P. C. Hansen, §§2.2–2.4 (PDF).

    For a fixed filter, write the result in original data coordinates as

    x^=xref+B(y−Kxref).\widehat x=x_{\rm ref}+B(y-Kx_{\rm ref}).

    Then

    E[x^]=xref+B(Ctrue−Kxref),Cov⁡(x^)=BΣBT.\begin{aligned} \mathbb E[\widehat x] &=x_{\rm ref}+B(C_{\rm true}-Kx_{\rm ref}),\\ \operatorname{Cov}(\widehat x)&=B\Sigma B^T. \end{aligned}

    The reference contribution is essential. If Ctrue=KxtrueC_{\rm true}=Kx_{\rm true}, the bias is

    E[x^]−xtrue=(BK−I)(xtrue−xref).\mathbb E[\widehat x]-x_{\rm true} =(BK-I)(x_{\rm true}-x_{\rm ref}).

    An unconstrained direction remains at its reference value. A covariance formula describes fluctuations about the estimator's expectation; it does not remove this bias. Changing the reference can change spectral features with little effect on predicted data.

    Choose the rule before inspecting truth

    Our main selection rule is generalized cross-validation:

    GCV⁡=∥(I−H)dy∥2[16−tr⁡H]2.\operatorname{GCV} =\frac{\lVert(I-H)d_y\rVert^2} {[16-\operatorname{tr}H]^2}.

    Its motivation is prediction of omitted data, with an orthogonally invariant approximation to the prediction penalty. It is not an optimization of unknown spectral error. P. C. Hansen, §2.9, Eq. (2.62) (PDF).

    The finite experiment fixes the following choices before sampling:

    • Tikhonov uses 67 logarithmically spaced values of α/σ1\alpha/\sigma_1, from 10−1010^{-10} to 1010.
    • TSVD uses r=0,…,min⁡(15,rnum)r=0,\ldots,\min(15,r_{\rm num}), where rnumr_{\rm num} counts σk>100ϵmachσ1\sigma_k>100\epsilon_{\rm mach}\sigma_1. This arithmetic guard is not a physical resolution criterion.
    • Minimize GCV on these grids; exact ties favor more regularization. Retain endpoint minima.
    • Repeat the same observations at M=40M=40, M=80M=80, and M=160M=160. The main grid is M=80M=80.
    • Independently declared fixed controls use α/σ1=10−6\alpha/\sigma_1=10^{-6}, α/σ1=10−4\alpha/\sigma_1=10^{-4}, and α/σ1=10−2\alpha/\sigma_1=10^{-2}.

    No positivity constraint is imposed on these linear reconstructions. Negative bins are reported. Clipping them and renormalizing would define a different nonlinear estimator with different bias and variance.

    An actual GCV failure: prediction can remain good

    For each noise level, generate 256 independent observations and 256 independent predictive replicates from the same true spectrum. Methods share the actual observed arrays. Independent predictive errors are evaluated using the true covariance.

    At δ=0.01\delta=0.01 and M=80M=80, the frozen calculation gives:

    SelectionMedian L2L^2 errorL2L^2 RMSEPredictive χ2/16\chi^2/16
    TSVD, GCV1.1281.1284.16×1094.16\times10^91.342±0.0351.342\pm0.035
    Tikhonov, GCV1.1321.1322.55×1052.55\times10^51.303±0.0321.303\pm0.032
    Fixed α/σ1=10−2\alpha/\sigma_1=10^{-2}—1.1351.1352.413±0.0492.413\pm0.049

    The last column reports the mean over independent repeats and its standard error. The RMSE includes every repeat. It is not an error bar on one fitted spectrum.

    The enormous difference between median error and RMSE is real: TSVD chooses the largest allowed rank, r=13r=13, in 14 of 256 cases. Tikhonov chooses its smallest allowed α\alpha in two cases, with additional severe underregularized cases nearby. These rare results dominate squared spectral and target errors while adding only moderately to prediction error. All 256 linear reconstructions contain negative bins. Narrowing the candidate grid after observing this outcome would be a new procedure; it was not done.

    The fixed control illustrates a different tradeoff: it has larger predictive error but avoids those huge spectral excursions. For the normalized Gaussian target centered at E=2E=2 with width 0.50.5, its RMSE is 0.01770.0177. That good value concerns this particular target and truth. It does not make the visibly biased spectrum generally accurate or establish an optimal rule.

    Predictive errors remain moderate while the frozen GCV reconstructions have very large spectral root-mean-square errors; a separate panel compares covariance effects on finite-family parameter errors.

    The retained comparisons use all 256 observations at each noise level, including extreme GCV selections. The spectral RMSE and median summarize different parts of a heavy-tailed error distribution. The covariance comparison reuses the same nominal-noise observations with independent calibration samples. These are finite synthetic experiments, not measured lattice spectra.

    The large coefficients also expose arithmetic cancellation. Although the parameterization enforces normalization algebraically, the worst binary64 TSVD output at M=80M=80 has a normalization defect 7.87×10−67.87\times10^{-6}. Directly multiplying its coefficients by KK differs from the more stable SVD prediction by at most 6.25×10−66.25\times10^{-6}, or 0.01370.0137 in Mahalanobis norm. The corresponding Tikhonov maxima are 5.60×10−105.60\times10^{-10} for normalization and 5.66×10−105.66\times10^{-10} for prediction. The original outputs are retained; an extra normalization repair is not silently applied.

    For the three fixed-alpha controls, the empirical variances of the six Gaussian targets are between about 0.900.90 and 1.131.13 times their analytic values across 256 repeats. This supports the implemented fixed-filter covariance calculation. It does not justify applying that covariance unmodified after GCV selection: the selected filter depends on the same noisy vector.

    What a correct finite family supplies

    Now assume the spectrum really belongs to the two-triangle family with d∈[0.4,1.6]d\in[0.4,1.6] and w∈[0.2,0.8]w\in[0.2,0.8]. Fit its exact continuous transform by correlated least squares. This gives genuine parameter errors rather than assigning peak labels to a signed bin reconstruction.

    With F(t)=[sinh⁡(bt/2)/(bt/2)]2e−2tF(t)=[\sinh(bt/2)/(bt/2)]^2e^{-2t}, the needed derivatives are

    ∂dC=t2F(t)[wedt/2−(1−w)e−dt/2],∂wC=F(t)[edt/2−e−dt/2].\begin{aligned} \partial_d C &=\frac t2F(t)\left[we^{dt/2}-(1-w)e^{-dt/2}\right],\\ \partial_w C&=F(t)\left[e^{dt/2}-e^{-dt/2}\right]. \end{aligned}

    The companion uses nine fixed starts, with dd chosen from 0.50.5, 11, and 1.51.5, and ww from 0.250.25, 0.50.5, and 0.750.75. It retains every optimizer outcome. All three stopping tolerances are 10−1010^{-10}, with at most 300 function evaluations per start. A successful change-in-cost or step-size termination is distinguished from reaching the requested gradient tolerance. SciPy 1.13.1, bounded least squares.

    Noise δ\deltaRMSE of ddRMSE of wwLocal 95% ellipse coverage
    0.0030.0030.006370.006370.003730.00373242/256242/256
    0.010.010.020870.020870.012460.01246240/256240/256
    0.030.030.058700.058700.035590.03559242/256242/256

    No selected fit touches a parameter boundary. All starts return a successful optimizer termination, but only 9, 6, and 0 selected fits, respectively, meet the gradient tolerance. Those distinctions remain in the output. An exact noiseless control recovers the parameters to 2.23×10−162.23\times10^{-16}.

    The local covariance is computed from the SVD of the whitened Jacobian, J=UJdiag⁡(sJ)VJTJ=U_J\operatorname{diag}(s_J)V_J^T:

    Cθlocal=VJdiag⁡(sJ−2)VJT.C_\theta^{\rm local} =V_J\operatorname{diag}(s_J^{-2})V_J^T.

    The displayed ellipses use the local quadratic approximation and the 95th percentile of χ22\chi_2^2. The coverage estimates from repeated data have binomial uncertainty. The finite family's information does not refute the positive nonuniqueness construction outside that family.

    A covariance estimate is another random input

    At nominal noise, independently draw 128 calibration vectors for each of the 256 observed data sets. Estimate covariance from either the first 32 or all 128 vectors, subtracting the sample mean and dividing by Ncal−1N_{\rm cal}-1. Refit the same observations with each estimate.

    For pp components and independent Gaussian calibration samples,

    E[Σ^−1]=Ncal−1Ncal−p−2Σ−1,Ncal>p+2.\mathbb E[\widehat\Sigma^{-1}] =\frac{N_{\rm cal}-1}{N_{\rm cal}-p-2}\Sigma^{-1}, \qquad N_{\rm cal}>p+2.

    Thus an unbiased sample covariance does not have an unbiased inverse. The scalar factor (Ncal−p−2)/(Ncal−1)(N_{\rm cal}-p-2)/(N_{\rm cal}-1) corrects the mean precision matrix under these assumptions. It does not make the covariance known or supply a generally correct parameter likelihood. Hartlap, Simon and Schneider, §3.1, Eqs. (16)–(17) (PDF).

    For our p=16p=16 experiment:

    Covariance inputRMSE of ddRMSE of wwLocal 95% ellipse coverage
    Known Σ\Sigma0.020870.020870.012460.01246240/256240/256
    Ncal=32N_{\rm cal}=320.028810.028810.017290.01729145/256145/256
    Ncal=128N_{\rm cal}=1280.022470.022470.013380.01338222/256222/256

    The ellipses in the latter rows use the uncorrected plug-in covariance. These rows expose its limitation rather than advertising valid 95% intervals. The mean dimensionless precision trace is 2.192±0.0202.192\pm0.020 for 32 samples, compared with the analytic factor 31/14=2.21431/14=2.214; for 128 samples it is 1.1551±0.00251.1551\pm0.0025, compared with 127/110=1.1545127/110=1.1545.

    A scalar precision correction cannot improve these point estimates: it multiplies the whole GLS objective by a constant. For our relative-alpha GCV grid it also rescales all singular values and candidate alphas together, leaving the mathematical selection unchanged. A binary64 diagnostic differs by 7.04×10−77.04\times10^{-7} relatively in a sensitive reconstruction, which is recorded as an arithmetic effect. Correcting an average scale is not a substitute for accounting for covariance uncertainty and regularization selection.

    The companion repeats the bin reconstructions with these estimated covariances too. Their extreme GCV cases persist, and their nominal fixed-filter intervals omit selection, bias and covariance uncertainty. Their measured coverage is reported with that qualification.

    Reproduce the finite experiment

    From the source distribution:

    python3 examples/computational-qft/inverse-problems/spectral_data.py
    python3 examples/computational-qft/inverse-problems/regularized_spectra.py
    

    The first command generates the frozen primary archive. Observation seeds are [931025,10,noise id,replica][931025,10,\text{noise id},\text{replica}]; independent predictive seeds use family 11, and covariance calibration uses [931025,12,replica][931025,12,\text{replica}]. The companion retains these settings, selected observations, diagnostics and all optimizer statuses. Exact-family fits are computed once per observation/covariance and reused across bin comparisons. Its checkpoint validates the data and fitting settings before reuse.

    Summary

    Correlated least squares supplies the correct data metric; regularization supplies a controlled preference in weakly observed spectral directions. Neither makes spectral accuracy equivalent to a good correlator fit. The reference, selection rule and estimated covariance all affect the estimator. Repeated prediction and parameter checks reveal failures that a training residual or optimizer success flag can miss.

    Exercises

    1. Bias, variance and an invisible reference component

    In a whitened singular direction, suppose dk=σkzk+ηkd_k=\sigma_k z_k+\eta_k, with ηk\eta_k of mean zero and variance one. For z^k=fkdk/σk\widehat z_k=f_kd_k/\sigma_k, derive the mean-square error. What happens in an exact null direction?

    Solution

    For σk>0\sigma_k>0,

    E[z^k]−zk=(fk−1)zk,Var⁡(z^k)=fk2σk2.\mathbb E[\widehat z_k]-z_k=(f_k-1)z_k, \qquad \operatorname{Var}(\widehat z_k)=\frac{f_k^2}{\sigma_k^2}.

    Consequently,

    E[(z^k−zk)2]=(1−fk)2zk2+fk2σk2.\mathbb E[(\widehat z_k-z_k)^2] =(1-f_k)^2z_k^2+\frac{f_k^2}{\sigma_k^2}.

    The first term decreases as the signal is retained, while the second increases. If the true zkz_k were known, the minimizing filter would be

    fkoracle=σk2zk21+σk2zk2.f_k^{\rm oracle} =\frac{\sigma_k^2z_k^2}{1+\sigma_k^2z_k^2}.

    This is an explanatory bound on what a filter could achieve, not a usable rule based on unknown truth.

    For σk=0\sigma_k=0, the data distribution is independent of zkz_k. The usual minimum-norm reconstruction sets the deviation coordinate to zero, so the original spectrum retains its reference component in that direction. Its reported noise variance can be zero while its bias is nonzero. Adding the reference term to the expectation makes this distinction explicit.

    2. Independent prediction and spectral accuracy

    Let C^(y)\widehat C(y) be any estimator from the observed data, including a data-selected regularizer. An independent observation is ynew=Ctrue+ϵnewy_{\rm new}=C_{\rm true}+\epsilon_{\rm new}, with known covariance Σ=LLT\Sigma=LL^T. Prove

    E ⁣[∥L−1(ynew−C^)∥2]=p+E ⁣[∥L−1(Ctrue−C^)∥2].\mathbb E\!\left[ \lVert L^{-1}(y_{\rm new}-\widehat C)\rVert^2 \right] =p+\mathbb E\!\left[ \lVert L^{-1}(C_{\rm true}-\widehat C)\rVert^2 \right].
    Solution

    Condition on the fitted data, so C^\widehat C is fixed relative to the independent new noise. Expanding the square gives the squared mean-prediction error, the squared whitened noise, and a cross term. The cross term averages to zero; the noise term has expectation tr⁡I=p\operatorname{tr}I=p. Averaging over the original data proves the identity. Linearity of the estimator is not required.

    The identity uses the true covariance and an independent new observation. A training residual uses noise already available to the fit and need not obey it. Replacing Σ\Sigma by a random estimate also changes the expectation unless its randomness and independence are handled.

    Finally, prediction error controls a spectral direction only through its singular value. If δz\delta z lies in a weak direction, its whitened prediction error is σk2(δz)2\sigma_k^2(\delta z)^2. A moderate predictive score can therefore coexist with an enormous coefficient error. An exact null direction costs no prediction error at all.

    References

    • P. C. Hansen, Regularization Tools: A Matlab Package for Analysis and Solution of Discrete Ill-Posed Problems, Version 4.1 (March 2008), author's manual (PDF), §§2.2–2.4 and §2.9, especially Eqs. (2.61)–(2.63). Reference terms, SVD filters and parameter-choice rules.
    • J. Hartlap, P. Simon and P. Schneider, “Why your model parameter confidences might be too optimistic: unbiased estimation of the inverse covariance matrix,” Astronomy & Astrophysics 464, 399–404 (2007), arXiv:astro-ph/0608064v2 (PDF), §§2.1 and 3.1, Eqs. (16)–(17). Gaussian sample-covariance and inverse-covariance assumptions.
    • SciPy developers, SciPy 1.13.1 Manual, bounded nonlinear least squares, trust-region reflective method, Jacobian and termination criteria. The numerical experiment uses the installed version and reports its distinct stopping conditions.

    Scrollable formula. Use Left and Right arrow keys to reveal hidden content.

    Scrollable table. Use Left and Right arrow keys to reveal hidden columns.

    Scrollable figure. Use Left and Right arrow keys to reveal hidden content.