How can I reproduce manually the random variables of the aPC function

2 次查看(过去 30 天)
Hello everyone. I am working with the PCA function. I am currently trying to do a manual version of the Karhunen-Loève expansion. Using PCA and data from realization_mat_merged I write:
[coeff, score, latent, tsquared, explained, mu]=pca(realization_mat_merged', 'Centered', false);
I can reproduce the scores by simply writing
C=cov(realization_mat_merged);
[U, d] = eig(C);
d = diag( d );
U= real(U);
d = real(d);
d = d(end:-1:1);
U = U(:,end:-1:1);
for 1=1:50
myScore(i)=sqrt(d(i))*U(:,i)
end
So, it is clear that the score is the eigenvector multiplied by the square root of the eigenvalue. Thus, the coeff is related to the random variable, which I have tried to reconstruct as
randVar=U'*realization_mat_merged';
However, the resulting matrix doesn't look at all like the coeff, so I don't know its relationship with the moment matrix of the covariance.
Can someone please tell me a way for me to reconstruct coeff by hand using the eigenvalues and-or eigenvectors of the covariance matrix of a stochastic process?
I am attaching a small sample of my code and data in case someone can help me.
Best regards.
Jaime.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by