假设现在有一个数据矩阵
X
,其大小是
n×p
,其中
n
is the number of samples and
现在,不失普遍性地,让我们假设 X is centered, 即 column means have been subtracted and are now equal to zero。如果 X is not centered,也不要紧,我们可以通过计算其与centering matrix H 之间的乘法来对其中心化。 H=I−eeT/p , 其中 e is a 每个元素都是1的 column vector。
基于上述条件,可知
如果
X
和
and correlation is:
因此 covXY=σXY=ρXYσXσY 。
如果
X
are centred data matrices of dimension
n×p
,an unbiased estimator of the covariance matrix (sample covariance matrix)
另一方面,如果 the column means were known a-priori, 则有
最后,在MATLAB中计算covariance matrix 和 correlation matrix的方法可以参见【5】。
现在我们知道,
C=XTX/(n−1)
是一个对称矩阵,因此它可以对角化,即
其中, V is a matrix of eigenvectors (each column is an eigenvector) and Λ is a diagonal matrix with eigenvalues λi in the decreasing order on the diagonal。
Any matrix has a singular value decomposition, so we have
应该注意到
这其实是特征值分解的结果,我们更进一步,把 C 引入,则有
也就是说,Covariance matrix C 的特征值 λi 与 矩阵 X 的奇异值 σi 之间的关系是 σ2i=(n−1)λi 。 X 的右singular matrix V 中的列是与上述主成分相对应的主方向(principal directions)。最后,
则表明, UΣ 就是主成分(PC)。
参考文献
【1】https://stats.stackexchange.com/questions/134282/relationship-between-svd-and-pca-how-to-use-svd-to-perform-pca
【2】https://intoli.com/blog/pca-and-svd/
【3】https://en.wikipedia.org/wiki/Estimation_of_covariance_matrices
【4】https://en.wikipedia.org/wiki/Covariance_and_correlation
【5】http://www.mathworks.com/help/stats/corrcov.html?s_tid=gn_loc_drop
【6】http://blog.csdn.net/baimafujinji/article/details/6474273
【7】http://blog.csdn.net/baimafujinji/article/details/79376378