hotteling转型并没有给期望的结果
问题描述:
我想霍特林转换应用于给予载体,并使实践我自己,那为什么我写了下面的MATLAB代码hotteling转型并没有给期望的结果
function [Y covariance_matrix]=hotteling_trasform(X)
% this function take X1,X2,X3,,Xn as a matrix and apply hottleing
%transformation to get new set of vectors y1, y2,..ym so that covariance
%matrix of matrix consiist by yi vectors are almost diagonal
%% determine size of given matrix
[m n]=size(X);
%% compute mean of columns of given matrix
means=mean(X);
%% substract mean from given matrix
centered=X-repmat(means,m,1);
%% calculate covariance matrix
covariance=(centered'*centered)/(m-1);
%% Apply eigenvector decomposition
[V,D]=eig(covariance);
%% determine dimension of V
[m1 n1]=size(V);
%% arrange matrix so that eigenvectors are as rows,create matrix with size n1 m1
A1=zeros(n1,m1);
for ii=1:n1
A1(ii,:)=V(:,ii);
end
%% applying hoteling transformation
Y=A1*centered; %% because centered matrix is original -means
%% calculate covariance matrix
covariance_matrix=cov(Y);
然后我把它检测到给定矩阵
A
A =
4 6 10
3 10 13
-2 -6 -8
和运行代码
[Y covariance_matrix]=hotteling_trasform(A);
covariance_matrix
covariance_matrix =
8.9281 22.6780 31.6061
22.6780 66.5189 89.1969
31.6061 89.1969 120.8030
后肯定这不是对角矩阵,所以错在哪里?在此先感谢
答
当你处理行向量而不是列,您需要在特征值/特征向量,decomposiiton来调整它载体。而不是Y=A1*centered
你需要Y=centered*V
。然后你会得到
covariance_matrix =
0.0000 -0.0000 0.0000
-0.0000 1.5644 -0.0000
0.0000 -0.0000 207.1022
所以你会得到两个非零组件这是你可以从三维空间只有三个百分点的期望。 (它们只能形成一架飞机,但不能成为一架飞机。)
+0
在我读过的书中,有人提到将列向量更改为行向量,所以您的意思是首先我必须计算协方差矩阵的奇异值分解,然后将右奇异矩阵乘法到中心矩阵? –
+0
我明白了,在此先感谢 –
你从哪里找到你实现的算法?我认识的人看起来完全不同。 (在'for ii = 1:n1'-loop中,你只是计算'V'的转置,这只是'V'') – flawr
你能告诉我算法的确切形式吗?关于转置权我只是复杂:D –
到目前为止,我只知道使用奇异值分解,这可能会更稳定一些。 – flawr