[Numpy-discussion] Linear least squares
Wed Jan 9 02:29:20 CST 2013
Nathaniel Smith <njs <at> pobox.com> writes:
> An obvious thing is that it always computes residuals, which could be
> costly; if your pinv code isn't doing that then it's not really
> comparable. (Though might still be well-suited for your actual
> Depending on how well-conditioned your problems are, and how much
> speed you need, there are faster ways than pinv as well. (Going via qr
> might or might not, going via cholesky almost certainly will be.)
You are right. With calculating the residuals, the speedup goes
down to a factor of 2. I had to calculate the residuals anyways because
lstsq only returns the squared sum of the residuals, while i need every
residual (as an input to optimize.leastsq).
Josef is also right, it is shape depended. For his example, lstsq is faster.
Maybe it is possible to make lstsq to choose its method automatically?
Or some keyword to set the method and making other decompositions
More information about the NumPy-Discussion