Skip to content
Snippets Groups Projects
Commit 224bca9d authored by Matthew Webster's avatar Matthew Webster
Browse files

working version

parent 0d95c88c
No related branches found
No related tags found
No related merge requests found
......@@ -2127,9 +2127,7 @@ ReturnMatrix cov_r(const Matrix& data, const Matrix& weights2, int econ)
SymmetricMatrix res;
res << zeros(data.Nrows(),data.Nrows());
Matrix meanM(mean(data,weights,2));
int N=1-weights.SumSquare();//As weights.Sum() is equal to 1
double N=(1-weights.SumSquare());//As weights.Sum() is equal to 1
if ( econ < 1 )
econ=data.Ncols();
for(int startCol=1; startCol <= data.Ncols(); startCol+=econ) {
......@@ -2140,24 +2138,7 @@ ReturnMatrix cov_r(const Matrix& data, const Matrix& weights2, int econ)
}
res << res + suba*suba.t()/N;
}
write_ascii_matrix("data.mat",data);
write_ascii_matrix("weights.mat",weights);
write_ascii_matrix("nonorm",cov_r(data,false));
write_ascii_matrix("old.mat",res);
//res.Release();
Matrix Data2=data;
for(int ctr=1; ctr <= data.Ncols(); ctr++)
Data2.Column(ctr)*=weights(ctr);
Matrix res2 = oldcov(Data2.t(),1);
res << res2;
write_ascii_matrix("new.mat",res);
exit(1);
res.Release();
return res;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment