Hello everyone. I have generated a code in which I use a Gaussian correlation kernel to generate 1000 realizations of a stochastic process and then, perform PCA over the resulting process. The result is a matrix of 501*1000.
However, when I perform the PCA over this matrix, the results contradict the help at https://la.mathworks.com/help/stats/pca.html
In the info it says that if one inrtoduces a n*p matrix, coeff will be a p*p matrix and score an n*p. Here, I get different results, coeff is a p*n matrix and score a p*p; the weird thing is that the process is reconstructed propperly. Can anyone tell me what is happening?
Thanks.
Additionally, reading theory, coeffs should be standard normal random variables; if I plot the histograms, the resulting variables are normal but not standard. If someone could tell me why these are not standard I would be very thankfull.
The code in question:
close allclearclc [X,Y] = meshgrid(0:0.002:1,0:0.002:1);Z=exp((-1)*abs(X-Y));tam=size(X, 1);number_realizations=1000;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);endfigurehold onfor 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);reconstruction_process=score*coeff';diference=reconstruction_process-realizacion_mat;figureplot(diference)for i=1:5 figure histogram(coeff(:,i), 20)end
Best Answer