Re: fit plane to xz axis of data

*To*: mathgroup at smc.vnet.net*Subject*: [mg89626] Re: fit plane to xz axis of data*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Sun, 15 Jun 2008 06:14:26 -0400 (EDT)*Organization*: The Open University, Milton Keynes, UK*References*: <g30399$mes$1@smc.vnet.net>

will parr wrote: [snip] >> The following will find the best-fitting (i.e., >> least-squares) plane: >> >> m = Mean[data]; {u,w,v] = >> = SingularValueDecomposition[#-m&/@data]; >> >> v is a rotation matrix. Tr[w,List] (i.e., the >> diagonal elements of w) >> gives the norms of the projections of the points onto >> the new axes. >> They are in decreasing order, so >> >> ({x,y,z}-m).v[[All,3]] == 0 >> >> gives the equation which the best-fitting plane >> satisfies. >> > > I'm really interested in this solution, but when I to use this method, I get an answer that I don't really understand, and cannot display (in the form of a plane). > > using the original data in this message: > > In[122]:= m = Mean[data]; {u, w, v} = > SingularValueDecomposition[# - m & /@ data]; > > In[123]:= Tr[w, List] > > Out[123]= {16.3822, 9.63356, 5.71769} > > In[124]:= ({x, y, z} - m).v[[All, 3]] == 0 > > Out[124]= > 0.984797 (-9.86988 + x) + 0.134151 (0.269052+ y) + > 0.110358 (-1.44535 + z) == 0 > > I don't understand this output, it is not of the form: > > ax + by + cz [snip] Solve the equation returned by ({x, y, z} - m).v[[All, 3]] == 0 for z. For instance, plane = z /. Solve[%, z][[1]] // Expand returns 89.1934- 8.92363 x - 1.2156 y Regards, - Jean-Marc