-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
numpy.linalg.lstsq gives empty residual #4438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Isn't this an issue of the documentation and not the function? |
It is just an issue with documentation. It will only return a non-empty residuals when the equations are over-determined. I put in a PR #4457 to fix the documentation |
Maybe there is a good reason for returning an empty list as residual error for well determined equations, but won't returning |
@qnzhou The reason is that for under-determined or well-determined equation sets there really is no meaning of residual error (there is no residual to compute). Only with over-determined equations could there exist a residual error. |
Doc updated by gh-4457. |
It may be far too late to change anything here (especially since it has now been documented as implemented for so long), but it's not helpful to have the shape of a return value depend on the values of the input. If I provide a calculated |
Agreed, this behavior is ridiculous, and makes #8720 impossible (#8720 (comment)) |
python version: 2.7.6
numpy version: 1.8.0
Here is a short example:
Since
a
is 2x2 matrix of rank 2, I expect the residual to be 0 instead of empty list according to the doc (http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.lstsq.html). But here is what I get:The text was updated successfully, but these errors were encountered: