Re:LU Factorization and Linear Systems for Programers
by R_haterade on Wednesday September 27, 2017 @06:57PM
(#15353108)
Excellent John D. Cook piece on the same subject: https://www.johndcook.com/blog/2010/01/19/dont-invert-that-m...
Re:LU Factorization and Linear Systems for Programers
by conistonwater on Wednesday September 27, 2017 @11:23PM
(#15354308)
That's a slightly different issue: the issue with solving normal equations directly is that the condition number of X^\top X is the square of the condition number of X, so it's much more significant than lu-vs-inv. It can matter a great deal for ill-conditioned linear regression problems where some features resemble each other.
Don't invert matrices.
For example, the solution for the least squares (=linear regression) problem is
and you might think that the best way to compute it is to compute X'X, invert it, do the multiplication, yada yada yada. But it's really better to just ask your library (Matlab, LAPACK, ...) to solve the problem for you, and it'll probably do a QR decomposition. For small problems, it doesn't really matter, but for big problems you'll be both faster and more accurate.