Home > chronux_1_50 > spikesort > pcasvd.m

pcasvd

PURPOSE ^

PCASVD Principal Components Analysis via (mean-subtracted) SVD.

SYNOPSIS ^

function [proj,u,s,v] = pcasvd(data)

DESCRIPTION ^

PCASVD            Principal Components Analysis via (mean-subtracted) SVD.
   PROJ = PCASVD(DATA), where DATA is an M x N matrix, returns the M x N
   matrix PROJ where the (M,N)th entry is the projection of the Mth row
   of DATA onto the Nth eigenvector of the covariance matrix COVDATA
   formed from the rows of DATA (i.e., COVDATA = DATA' * DATA).

   [PROJ,U,S,V] = PCASVD(DATA) also returns matrices U, S, V such that
   DATA = U * S * V' and PROJ = DATA * V.

   PCASVD always first subtracts the mean from each column of DATA.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [proj,u,s,v] = pcasvd(data)
0002 %PCASVD            Principal Components Analysis via (mean-subtracted) SVD.
0003 %   PROJ = PCASVD(DATA), where DATA is an M x N matrix, returns the M x N
0004 %   matrix PROJ where the (M,N)th entry is the projection of the Mth row
0005 %   of DATA onto the Nth eigenvector of the covariance matrix COVDATA
0006 %   formed from the rows of DATA (i.e., COVDATA = DATA' * DATA).
0007 %
0008 %   [PROJ,U,S,V] = PCASVD(DATA) also returns matrices U, S, V such that
0009 %   DATA = U * S * V' and PROJ = DATA * V.
0010 %
0011 %   PCASVD always first subtracts the mean from each column of DATA.
0012 
0013 % Very simple code -- basically just a macro.
0014 data = removeoffset(data,1,'mean'); % remove mean row
0015 [u,s,v] = svd(data, 0);             % SVD the data matrix
0016 proj = data * v;                    % compute (mean-subtracted) pca projections?

Generated on Mon 09-Oct-2006 00:54:52 by m2html © 2003