Re: EOF explained variance
- From: "Roger Stafford" <ellieandrogerxyzzy@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 16 Jul 2008 00:13:02 +0000 (UTC)
"Leandro Calil" <leandro@xxxxxxxxxxxxxxxx> wrote in message <g5j7ua$s3l
$1@xxxxxxxxxxxxxxxxxx>...
Sorry, I forgot to say that I just considering curl
magnitudes. I am dealing the curl as one scalar quantity, as
you thought.
This is the problem:
%MY DATA MATRIX SHOULD BE: Z(position,time)
Z = 126 x 8036 -> I have 126 positions and 8036 times
% CALCULATE MEAN FOR EACH LINE (SPATIAL DEPENDENT MEAN) - ZM(jj)
zm = mean(z');
% SUBTRACT THE MEAN FROM ORIGINAL DATA - Z(jj,nn)
jj = length(Z(:,1));
for j=1:jj; z(j,:)=z(j,:)-zm(j); end
% CALCULATE COVARIANCE MATRIX (Z'*Z) - C(nn,nn)
c = z'*z; -> result in a 8036 x 8036 matrix
% EXTRACT EIGENVALUES AND EIGENVECTORS USING SVD
[u,s,v] = svd(c); -> In this part “out of memory”
%[u,s,v] = svd(c,'econ'); -> I also tried
% CALCULATE EXPLAINED VARIANCE
lamb = diag(s);
ev = lamb/trace(c);
*this is a part of professor Paiva routine
Thanks
There appear to be two things wrong with the code you show here. In zm =
mean(z') you are taking the mean along the 8036-element rows of Z and
obtaining 126 different mean values. This means, as I suspected, that in the
language of covariances, each column of Z is an observation (at a particular
time) and each row is a variable (curl magnitude at a position throughout
time.) Therefore your covariance matrix should be of size 126 x 126, where
you are comparing all the various pairs of variables (positions.) However, you
have generated a 8036 x 8036 matrix which would be comparing different
pairs of times as positions varied. I am sure that was not your intent. You
have your observations and variables interchanged! If you wanted to get the
covariance, you should call on 'cov' with cov(Z'), not cov(Z).
However, I believe there is no need to find the covariance if you are going to
use singular value decomposition. Just call on 'svd' directly, but not with Z.
You must use Z' with the mean having been subtracted as you have done
above.
[U,S,V] = svd(Z','econ');
This way U would be 8036 x 126, and both S and V are 126 x 126. This
ought not to run you into memory problems.
The rest of the calculations I leave to you. (Remember that the variances are
obtained from the squares of the diagonal terms in S if you do things this
way.)
Roger Stafford
.
- Follow-Ups:
- Re: EOF explained variance
- From: Leandro Calil
- Re: EOF explained variance
- References:
- EOF explained variance
- From: Leandro Calil
- Re: EOF explained variance
- From: Roger Stafford
- Re: EOF explained variance
- From: Leandro Calil
- Re: EOF explained variance
- From: Roger Stafford
- Re: EOF explained variance
- From: Leandro Calil
- Re: EOF explained variance
- From: Roger Stafford
- Re: EOF explained variance
- From: Leandro Calil
- EOF explained variance
- Prev by Date: Re: vectorization without repmat
- Next by Date: Re: making an independent copy of a matlab object
- Previous by thread: Re: EOF explained variance
- Next by thread: Re: EOF explained variance
- Index(es):
Relevant Pages
|