[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

singular value decompostion



I am trying to use the IDL routine SVDC to do principal component
analysis.  In order to understand SVD better I was doing an example I
found online.  However, the IDL SVD routine gives me different results
than the online example.

x = [[1,2],[3,4],[5,6],[7,8]]

matlab, which uses linpac gives (to two decimal places):

[U,S,V] = svd(x)  where X = U S transpose(V)

U = .15   .82  -.39  -.38
        .35  .42     .24   .80
         .55   .02   .70   .46
       .74   -.38   -.54  .04

S = 14.3    0
        0        .62

V = .64   -.77
        .77   .64

IDL gives

svdc, x,w,u,v,/column

w =  14.2691     0.626828

u =  -0.641423    -0.767187
    -0.767187     0.641423
      0.00000      0.00000
      0.00000      0.00000

v =  -0.152483    -0.349918    -0.547354    -0.744789
     0.822647     0.421375    0.0201032    -0.381169
     0.547723    -0.730297    -0.182574     0.365149
      0.00000     0.408249    -0.816496     0.408248

clearly the eigenvalues are the same but the u and v matricies are
exchanged.  But what really bothers me is that some values are changed
from positive to negative.  And the IDL V does not have the same values
as the MATLAB U.

What am I doing wrong?  Even if I leave out the /column in the call to
svdc, I don't get the right answers.

The eigenvalues do not correspond to the eigenvalues returned by the IDL
routine pcomp which calculates principal components.  I thought PCA
could be done using SVD but I don't see the correspondence.

Any help would be appreciated.

Thanks.

Dave
bazell@home.com