matlab化简数值结果,matlab – 如何使用简化数据 – 主成分分析的输出

我发现很难将理论与实施联系起来.我很感激帮助知道我的理解错误.

符号 – 粗体大写的矩阵和粗体字母小写字母的向量

9344850ac759c10302007da262a00e7f.png98d7309514519fa01ab11c40c4bbb9fa.png观测的数据集,每个a23e0db1410449d5d003a43d446fdfba.png变量.因此,给定这些观察到的e7c571e9ff8e0cebe7b0fb447b87b444.png维数据向量,32de49752695923d56d0993895e5bbce.png维主轴为GWp8m.png,4c0f8dc10ea8998f35d71128e136e5c0.pngfd9bcc9f317bf85fea488485cce24bf7.png,其中a8ddeedcca262a6c84910b3bb2529f2c.png为目标维度.

观测数据矩阵的12548d927cfa584bac36869990c4b192.png主成分将是e8447910cd24b35fb6b8a6dddc20908b.png,其中矩阵538de2c9879fd8d39f9fb882c7ab5170.png,矩阵e9686ba8469e54f0c3465727eba30689.png和矩阵77982c8fc49e2ca3684df2222f11c276.png.

a13529c895aae74003ab6f22c6b44fcc.png的列形成2e4494099d0bac54faed00006d5a6113.png特征的正交基础,输出dd7afcb696f8bcde2df6166f43400e01.png是最小化平方重建误差的主要组件投影:

22d91b4e36c89271bf0f126c18fb141a.png

2878682a1439465d48a821c4c4d5bede.png给出了c50ec8be8b804645cda7f62b1a014c8d.png的最佳重建.

数据模型是

X(i,j) = A(i,:)*S(:,j) + noise

其中PCA应在X上完成以获得输出S. S必须等于Y.

问题1:简化数据Y不等于模型中使用的S.我的理解在哪里错了?

问题2:如何重建以使错误最小化?

请帮忙.谢谢.

clear all

clc

n1 = 5; %d dimension

n2 = 500; % number of examples

ncomp = 2; % target reduced dimension

%Generating data according to the model

% X(i,j) = A(i,:)*S(:,j) + noise

Ar = orth(randn(n1,ncomp))*diag(ncomp:-1:1);

T = 1:n2;

%generating synthetic data from a dynamical model

S = [ exp(-T/150).*cos( 2*pi*T/50 )

exp(-T/150).*sin( 2*pi*T/50 ) ];

% Normalizing to zero mean and unit variance

S = ( S - repmat( mean(S,2), 1, n2 ) );

S = S ./ repmat( sqrt( mean( Sr.^2, 2 ) ), 1, n2 );

Xr = Ar * S;

Xrnoise = Xr + 0.2 * randn(n1,n2);

h1 = tsplot(S);

X = Xrnoise;

XX = X';

[pc, ~] = eigs(cov(XX), ncomp);

Y = XX*pc;

更新[8月10日]

根据答案,这里是完整的代码

clear all

clc

n1 = 5; %d dimension

n2 = 500; % number of examples

ncomp = 2; % target reduced dimension

%Generating data according to the model

% X(i,j) = A(i,:)*S(:,j) + noise

Ar = orth(randn(n1,ncomp))*diag(ncomp:-1:1);

T = 1:n2;

%generating synthetic data from a dynamical model

S = [ exp(-T/150).*cos( 2*pi*T/50 )

exp(-T/150).*sin( 2*pi*T/50 ) ];

% Normalizing to zero mean and unit variance

S = ( S - repmat( mean(S,2), 1, n2 ) );

S = S ./ repmat( sqrt( mean( S.^2, 2 ) ), 1, n2 );

Xr = Ar * S;

Xrnoise = Xr + 0.2 * randn(n1,n2);

X = Xrnoise;

XX = X';

[pc, ~] = eigs(cov(XX), ncomp);

Y = XX*pc; %Y are the principal components of X'

%what you call pc is misleading, these are not the principal components

%These Y columns are orthogonal, and should span the same space

%as S approximatively indeed (not exactly, since you introduced noise).

%If you want to reconstruct

%the original data can be retrieved by projecting

%the principal components back on the original space like this:

Xrnoise_reconstructed = Y*pc';

%Then, you still need to project it through

%to the S space, if you want to reconstruct S

S_reconstruct = Ar'*Xrnoise_reconstructed';

plot(1:length(S_reconstruct),S_reconstruct,'r')

hold on

plot(1:length(S),S)

该图是509886f0deebfe03cdae7b7524f95bbf.png,与答案中显示的图非常不同.只有S的一个组件与S_reconstructed的组件完全匹配.不应该重建源输入S的整个原始二维空间吗?

即使我切断了噪音,那么S的一个组成部分也是精确重建的.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值