Re: [Numpy-discussion] 3d plane to point cloud fitting using SVD

2011-01-26 Thread Huan Liu
Hi,

I just confirmed Stefan's answer on one of the examples in 
http://www.mathworks.co.jp/matlabcentral/newsreader/view_thread/262996

matlab:

  A = randn(100,2)*[2 0;3 0;-1 2]';
  A = A + randn(size(A))/3;
  [U,S,V] = svd(A);
  X = V(:,end)

python:

  from numpy import *
  A = random.randn(100,2)*mat([[2,3,-1],[0,0,2]])
  A = A + random.randn(100,3)/3.0
  u,s,vh = linalg.linalg.svd(A)
  v = vh.conj().transpose()
  print v[:,-1] 

It works! Thanks Peter for bringing this up and Stefan for answering!

Huan




___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] 3d plane to point cloud fitting using SVD

2010-05-05 Thread Stéfan van der Walt
Hi Peter

On 5 May 2010 10:02, Peter Schmidtke pschmid...@mmb.pcb.ub.es wrote:
 u,s,vh=numpy.linalg.linalg.svd(M)

 Then in the matlab analog they use the last column of vh to get the a,b,c
 coefficients for the equation
 a,b,c=vh[:, -1] in numpy

Note that vh is the conjugate transpose of v.  You are probably
interested in the rows of vh (the columns of V in MATLAB parlance).

Regards
Stéfan
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion