[SciPy-user] using linalg.lstsq

Robert Kern robert.kern at gmail.com
Wed May 10 22:36:06 EDT 2006


Mitchell Timin wrote:
> --- Robert Kern <robert.kern at gmail.com> wrote:
> 
>>Mitchell Timin wrote:
>>
>>>I'm brand new to numpy & scipy, and my linear algebra is pretty weak also.  I'm
>>
>>hoping
>>
>>>someone will show me how to fit a plane to some points.  I need to work in higher
>>>dimensional space, but I think If I understand the 3-D case I will be OK.
>>>So, suppose I have, say, half a dozen points in 3-space.  I want to find values for
>>
>>c1,
>>
>>>c2 & c3 so that x3 = c1*x1 + c2*x2 + c3 passes close to all the points in the least
>>>square sense.
>>>
>>>I think that linalg.lstsq will solve that problem, but I don't know how to set it
>>
>>up.
>>
>>Did my explanation on comp.lang.python not help you? You said it did.
> 
> Yes, it was helpful in that it showed me how to call lstsq() without errors, but I was
> not able to convert my problem into the correct form to get a solution.  It is not
> obvious how to go from the form above into a pair of matrices that work with lstsq().

The example I showed you *was* in the form above (with an extra dimension).

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the SciPy-User mailing list