- #1

confused_engineer

- 39

- 2

- TL;DR Summary
- The results obtained from appying the pca command dont' match with the theoretical results. The obtained random variables should be standard gaussian. However, I don't obtain that.

Greetings everyone.

I have generated a gaussian random process composed of 500 realizations and 501 observations. The used random variables are gaussian normal.

I have then applied the pca analysis to that process (Mathwork's help). However, if I plot the histograms of the coeffs I don't find gaussian random variables, the variables are gaussian but not standard as specified in page 10 of the Followed article, just before section 6.

Is there something wrong with my code (see below) am I misunderstanding the article or the pca function from MATLAB?

I need help since I can't see a solution to this problem.

Thanks.

I have generated a gaussian random process composed of 500 realizations and 501 observations. The used random variables are gaussian normal.

I have then applied the pca analysis to that process (Mathwork's help). However, if I plot the histograms of the coeffs I don't find gaussian random variables, the variables are gaussian but not standard as specified in page 10 of the Followed article, just before section 6.

Is there something wrong with my code (see below) am I misunderstanding the article or the pca function from MATLAB?

I need help since I can't see a solution to this problem.

Thanks.

Problem:

```
close all
clear
clc
[X,Y] = meshgrid(0:0.002:1,0:0.002:1);
Z=exp((-1)*abs(X-Y));
tam=size(X, 1);
number_realizations=500;realizacion_mat=zeros(tam, number_realizations);
cov_mat=cov(Z);
[evec_mal, evalM_mal]=eig(cov_mat);
eval_mal=eig(evalM_mal);
num_eval=size(eval_mal,1);
for i=1:num_eval
eval(i)=eval_mal(num_eval-i+1);
evec(:,i)=evec_mal(:,num_eval-i+1);
end
figure
hold on
for j=1:number_realizations
realizacion=zeros(tam, 1);
for i=1:tam
v_a = normrnd(0,1);
realizacion=realizacion+sqrt(eval(i))*evec(:,i)*v_a;
end
realizacion_mat(:,j)=realizacion;
plot(realizacion)
clear('realizacion')
end
[coeff,score,latent,tsquared,explained,mu] = pca(realizacion_mat,'Centered',false);
realizaciones=size (realizacion_mat, 2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
number_figures=6;
number_bins=10;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%for i=1:number_figures
a= num2str(i);
figure
histogram(coeff(i,:), number_bins)
xlabel(['\omega'])
ylabel(['\xi_' ,num2str(i), '(\omega)'])
end
```