PCA more efficient
- From: "Jose " <jose.l.vega@xxxxxxxxx>
- Date: Tue, 9 Dec 2008 12:28:01 +0000 (UTC)
S=xsn;
Hi, I have this code to calcule the first components from the PCA.
Anyone, can help me to writte down it more efficently.
Specifically to obtain the vector Ex:
I have consider the sum of components (ax) reach the 65% of the total contribution of the components,
but there are other form more efficiently to write dow it?.
FT=cov(S);
[evecs,evals]=eig(FT);
[sev,I]=sort(diag(evals))
nsa=length(sev);
ax=0;
Ex=[];
for i=nsa:-1:1
ax= ax+sev(i)/sum(sev);
Ex=[Ex evecs(:,i)];
if ax>0.85 % The sum of components have to account for 65% of the data variation.
break % We do not have account the rest of components.
end
end
cheers,
Jose.
.
- Follow-Ups:
- Re: PCA more efficient
- From: Jose
- Re: PCA more efficient
- From: Pekka Kumpulainen
- Re: PCA more efficient
- Prev by Date: Re: plotting unequal length vectors
- Next by Date: Calculate a matriz
- Previous by thread: Re: plotting unequal length vectors
- Next by thread: Re: PCA more efficient
- Index(es):
Relevant Pages
|