Skip to main content

Module least_squares

Module least_squares 

Source
Expand description

Linear least squares, min ‖A x − b‖₂ for a tall A, two ways.

The normal equations AᵀA x = Aᵀb come straight from setting the gradient to zero and are solved cheaply with Cholesky, but forming AᵀA squares the condition number. QR writes A = Q R, so ‖A x − b‖ = ‖R x − Qᵀb‖ in the column space, and solves the triangular system R x = Qᵀb directly, with error proportional to κ(A) rather than κ(A)².

See the book entry Linear least squares.

Functions§

normal_equations
Solves the normal equations AᵀA x = Aᵀb with Cholesky: L y = Aᵀb, then Lᵀ x = y.
qr_least_squares
Solves R x = Qᵀb with the Householder QR factorisation.