SVD与PCA之间的关系详解
2018-03-01 11:27
253 查看
假设现在有一个数据矩阵X,其大小是n×p,其中 n is the number of samples and p is the number of variables (或features)。这里,XT可以写成{x1,x2,⋯,xn},x1表示一个长度为p的列向量,也就是说,XT 包含 n independent observations x1,x2,⋯,xn,其中每个都是一个 p-dimensional 的列向量,这与【7】中的写法相一致。
现在,不失普遍性地,让我们假设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。
基于上述条件,可知p×p大小的协方差矩阵 covariance matrix C 可由 C=XTX/(n−1) 给出。此处,我们稍微补充一下协方差矩阵与相关性矩阵(correlation matrix )的一些内容。如果你对此已经非常了解,可以直接跳过这一部分。
如果 X 和 Y 是两个随机变量,with means (expected values) μX and μY and standard deviations σX and σY, respectively, then their covariance is
σXY=E[(X−μX)(Y−μY)]
and correlation is:
ρXY=E[(X−μX)(Y−μY)]/(σXσY)
因此 covXY=σXY=ρXYσXσY。
如果 X are centred data matrices of dimension n×p,an unbiased estimator of the covariance matrix (sample covariance matrix)
C=1n−1XTX
另一方面,如果 the column means were known a-priori, 则有
C=1nXTX
最后,在MATLAB中计算covariance matrix 和 correlation matrix的方法可以参见【5】。
现在我们知道,C=XTX/(n−1)是一个对称矩阵,因此它可以对角化,即
C=VΛVT
其中,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
X=UΣVT
应该注意到
XTX=(UΣVT)T(UΣVT)=VΣTUTUΣVT=V(ΣTΣ)VT
这其实是特征值分解的结果,我们更进一步,把C引入,则有
C=1n−1XTX=1n−1V(ΣTΣ)VT=VΣ2n−1VT
也就是说,Covariance matrix C的特征值 λi 与 矩阵X的奇异值σi之间的关系是 σ2i=(n−1)λi。X的右singular matrix V 中的列是与上述主成分相对应的主方向(principal directions)。最后,
XV=UΣVTV=UΣ
则表明,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
现在,不失普遍性地,让我们假设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。
基于上述条件,可知p×p大小的协方差矩阵 covariance matrix C 可由 C=XTX/(n−1) 给出。此处,我们稍微补充一下协方差矩阵与相关性矩阵(correlation matrix )的一些内容。如果你对此已经非常了解,可以直接跳过这一部分。
如果 X 和 Y 是两个随机变量,with means (expected values) μX and μY and standard deviations σX and σY, respectively, then their covariance is
σXY=E[(X−μX)(Y−μY)]
and correlation is:
ρXY=E[(X−μX)(Y−μY)]/(σXσY)
因此 covXY=σXY=ρXYσXσY。
如果 X are centred data matrices of dimension n×p,an unbiased estimator of the covariance matrix (sample covariance matrix)
C=1n−1XTX
另一方面,如果 the column means were known a-priori, 则有
C=1nXTX
最后,在MATLAB中计算covariance matrix 和 correlation matrix的方法可以参见【5】。
现在我们知道,C=XTX/(n−1)是一个对称矩阵,因此它可以对角化,即
C=VΛVT
其中,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
X=UΣVT
应该注意到
XTX=(UΣVT)T(UΣVT)=VΣTUTUΣVT=V(ΣTΣ)VT
这其实是特征值分解的结果,我们更进一步,把C引入,则有
C=1n−1XTX=1n−1V(ΣTΣ)VT=VΣ2n−1VT
也就是说,Covariance matrix C的特征值 λi 与 矩阵X的奇异值σi之间的关系是 σ2i=(n−1)λi。X的右singular matrix V 中的列是与上述主成分相对应的主方向(principal directions)。最后,
XV=UΣVTV=UΣ
则表明,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
相关文章推荐
- 关于JS面向对象中原型和原型链以及他们之间的关系及this的详解
- 从PCA和SVD的关系拾遗
- 详解php中空字符串和0之间的关系
- ALSA声卡驱动中的DAPM详解之五:建立widget之间的连接关系
- PCA和SVD关系
- java 类之间的四种关系详解
- (转)有关Auto encoder 和Denoising auto encoder分别和PCA之间的关系(学习笔记)
- 详解JVM,JRE,JDK之间之间的关系
- glibc库详解及与POSIX,systemV这些库之间的关系说明
- ALSA声卡驱动中的DAPM详解之五:建立widget之间的连接关系
- 矩阵奇异值分解(SVD)与主成份分析(PCA)详解
- ALSA声卡驱动中的DAPM详解之五:建立widget之间的连接关系
- java 类之间的四种关系详解
- 2.java面向对象类与类/类与对象之间关系详解
- pstree命令_Linux pstree 命令用法详解:以树状图的方式展现进程之间的派生关系
- js的 function, javascript内置对象apply,call,this概念及之间的关系详解
- java中类与类之间的关系 详解
- 操作系统 页式存储 页与块之间的关系详解
- ALSA声卡驱动中的DAPM详解之五:建立widget之间的连接关系
- ALSA声卡驱动中的DAPM详解之五:建立widget之间的连接关系