[SciPy-user] using linalg.lstsq

Mitchell Timin zenguyuno at yahoo.com
Wed May 10 22:50:59 EDT 2006


--- Robert Kern <robert.kern at gmail.com> wrote:

> 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).

I accept that, but I don't see how to put my problem into that form.  Suppose we are
given these 4 points only:
   x     y      z
   0     0      .5
   0     1      .6
   1     0      .4
   1     1      .55

What is the equation of the plane that passes closest to those 4 points?  It is of the
form z = a*x + b*y + c.  What are the values of a, b, & c?

Thanks,   


Mitchell Timin

I'm proud of http://ANNEvolve.sourceforge.net.  If you want to write software, or articles, or do testing, or research for ANNEvolve, let me know.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the SciPy-User mailing list