[Numpy-discussion] linear algebra help

Sebastian Walter sebastian.walter at gmail.com
Mon May 18 04:05:21 EDT 2009


Alternatively, to solve A x = b you could do

import numpy
import numpy.linalg

B = numpy.dot(A.T, A)
c = numpy.dot(A.T, b)
x = numpy.linalg(B,c)

This is not the most efficient way to do it but at least you know
exactly what's going on in your code.



On Sun, May 17, 2009 at 7:21 PM,  <josef.pktd at gmail.com> wrote:
> On Sun, May 17, 2009 at 12:14 PM, Quilby <quilby at gmail.com> wrote:
>> Right the dimensions I gave were wrong.
>> What do I need to do for m>=n (more rows than columns)?  Can I use the
>> same function?
>>
>> When I run the script written by Nils (thanks!) I get:
>>    from numpy.random import rand, seed
>> ImportError: No module named random
>>
>> But importing numpy works ok. What do I need to install?
>
> This should be working without extra install. You could run the test
> suite, numpy.test(), to see whether your install is ok.
>
> Otherwise, you would need to provide more information, numpy version, ....
>
> np.lstsq works for m>n, m<n and m=n, however the meaning of the
> solution is different in the 3 cases.
> m>n (more observations than parameters) is the standard least squares
> estimation problem.
>
> Josef
>
>
>>
>> Thanks again!
>>
>> On Sun, May 17, 2009 at 1:51 AM, Alan G Isaac <aisaac at american.edu> wrote:
>>> On 5/16/2009 9:01 AM Quilby apparently wrote:
>>>> Ax = y
>>>> Where A is a rational m*n matrix (m<=n), and x and y are vectors of
>>>> the right size. I know A and y, I don't know what x is equal to. I
>>>> also know that there is no x where Ax equals exactly y.
>>>
>>> If m<=n, that can only be true if there are not
>>> m linearly independent columns of A.  Are you
>>> sure you have the dimensions right?
>>>
>>> Alan Isaac
>>>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list