
On 27.01.2012 10:47, Sturla Molden wrote:
Why is the non-linear LS solver in sp.optimize called leastsq, whereas the linear solver in sp.linalg is called lstsq? Wouldn't a consistent name be better?
Also I think the docstring for sp.optimize.leastsq should refer to the linear solver, because I have seen multiple examples of people using sp.optimize.leastsq to solve linear systems.
sp.linalg.lstsq uses SVD, by lapack driver *gelss. If we don't need singular values, solving by QR is faster (lapack driver *gels).
(I actually use Fortran just to get DGELS instead of DGELSS.)
Another thing is that the terminology here could be confusing. The docstring for lstsq uses the naming convention from linear algebra, i.e. sp.linalg.lstsq(a, b) will minimize 2-norm |b - Ax|. Those needing it for statistics (multiple regression) might not relize that b corresponds to y, A to X, and x to b. So fitting y = X * b by least squares is sp.linalg.lstsq(X, y). I think the docstring should be more explicit on this. Sturla