As mentioned in the comments, you need to use the left inverse.
This is described in this question.
To summarize (imitatio, aemulatio):
- Use
linalg.lstsq(A,y)
in general. - You can use
linalg.solve(A,y)
if you knowA
meets the right conditions.
Question
In Matlab, using the inv() function is often discouraged due to numerical instability (see description section in http://www.mathworks.com/help/matlab/ref/inv.html). It is suggested to replace an expression like:
inv(A)*B
(where both A and B are matrices), with:
A\B
This becomes critical when the inverted matrix A is close to singular.
Is there a nice way to write this in numpy / scipy? (would solve() work?)
La solution
As mentioned in the comments, you need to use the left inverse.
This is described in this question.
To summarize (imitatio, aemulatio):
linalg.lstsq(A,y)
in general. linalg.solve(A,y)
if you know A
meets the right conditions.