So I want to solve the equation z= a + b*y +c*x,. getting a,b,c.
ie: making a (plane) surface fit to a load of scatter points in 3D space.
But I can’t seem to find anything! I thought there would be a simple module for such a simple problem.
I have tried, where x,y,z are arrays;
ys=zip(x,y)
(coeffs, residuals, rank, sing_vals) = np.linalg.lstsq(ys,z)
am I right in thinking coeffs = b,c?
Or am I going completely in the wrong direction. I just can’t seem to find anything else that will work in 3d…
I think you’re on the right track. You could still try following the example of the
scipy.linalgdocumentation, in particular the Solving least-squares…` section(we added a column of 1 for the constant).