我想霍特林轉換應用於給予載體,並使實踐我自己,那爲什麼我寫了下面的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
後肯定這不是對角矩陣,所以錯在哪裏?在此先感謝
你從哪裏找到你實現的算法?我認識的人看起來完全不同。 (在'for ii = 1:n1'-loop中,你只是計算'V'的轉置,這只是'V'') – flawr
你能告訴我算法的確切形式嗎?關於轉置權我只是複雜:D –
到目前爲止,我只知道使用奇異值分解,這可能會更穩定一些。 – flawr