NLA-lib Explorer

Linear least squares

Library · Source module

Linear least squares

NLAlib.IsLeastSquaresSolution A b x says that \mathbf{x} minimises \|\mathbf{b} - \mathbf{A}\mathbf{x}\| over all vectors. It is the interface for "\mathbf{x} solves the least-squares problem": a theorem about a solver concludes it, and a theorem about a solution takes it. The minimisers are characterised by the normal equations and by \mathbf{A}\mathbf{x} being the projection of \mathbf{b} onto the column space; the pseudoinverse gives the one of smallest norm, and the residual is (\mathbf{I} - \mathbf{P}_{\mathbf{A}})\mathbf{b}, with \mathbf{P}_{\mathbf{A}} the orthogonal projector onto the range of \mathbf{A} (rangeProjector).

Sketch-and-solve replaces the problem by the one sketched by \mathbf{S}; its solution NLAlib.sketchAndSolve A S B, written \mathsf{sketchAndSolve}(\mathbf{A}, \mathbf{S}, \mathbf{B}), has fitted values the oblique projection \mathbf{\Pi}_{\mathbf{A},\mathbf{S}}\mathbf{B}, and when \mathbf{S} keeps the rank of \mathbf{A} it is the exact minimum-norm solution plus the sketched solution for the optimal residual. The solution does not change when the sketch is multiplied by a nonzero scalar, so the normalisations of Gaussian and Haar sketches do not matter for it.

Main definitions

* NLAlib.IsLeastSquaresSolution: \mathbf{x} minimises \|\mathbf{b} - \mathbf{A}\mathbf{x}\|. * NLAlib.sketchAndSolve: the sketch-and-solve solution.

Main results

* NLAlib.isLeastSquaresSolution_iff_normal_equations: the normal equations. * NLAlib.isLeastSquaresSolution_iff_mulVec_eq_rangeProjector_mulVec: \mathbf{A}\mathbf{x} = \mathbf{P}_{\mathbf{A}}\mathbf{b}. * NLAlib.isLeastSquaresSolution_pinv_mulVec: \mathbf{A}^{+}\mathbf{b} is a solution. * NLAlib.IsLeastSquaresSolution.norm_pinv_mulVec_le: it is the solution of smallest norm. * NLAlib.existsUnique_isLeastSquaresSolution_iff: uniqueness exactly for full column rank. * NLAlib.mul_sketchAndSolve, NLAlib.sketchAndSolve_eq_pinv_mul_add, NLAlib.HasOrthonormalCols.sketchAndSolve_eq_add: sketch-and-solve, its fitted values and its error decomposition. * NLAlib.sketchAndSolve_smul_sketch: rescaling the sketch does not change the solution.

Declarations