fitting a linear surface with numpy least squares

前端 未结 2 815
再見小時候
再見小時候 2021-01-20 17:51

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.

2条回答
  •  失恋的感觉
    2021-01-20 18:40

    I think you're on the right track. You could still try following the example of the scipy.linalg documentation, in particular the Solving least-squares...` section

    A = np.column_stack((np.ones(x.size), x, y))
    c, resid,rank,sigma = np.linalg.lstsq(A,zi)
    

    (we added a column of 1 for the constant).

提交回复
热议问题