[Scilab-users] spatial correlation coefficient: Is the MATLAB corrcoef function doing the job?
Heinz
heinznabielek at me.com
Thu Feb 8 20:13:26 CET 2018
Thanks. While not giving me ONE number, the analysis shows that my random
generated xyz positions are uncorrelated as they should. Can one estimate
the error bars for the xy xz and yz correlations?
Now, I can use this approach for actual measurements in real objects.
Heinz
//START
function Y=corrmatrix(M)
C = cov(M); // covariance matrix
D = sqrt(diag(C)); // standard deviations
D = inv(diag(D));
Y = D*C*D; // correlation matrix
endfunction
n=10000;
r=23;
radius = r*grand(n,1,'def').^(1/3);
phi = 2*%pi*grand(n,1, 'def');
costheta = 1 - 2*grand(n,1, 'def');
radsintheta = radius.*sin(acos(costheta));
X = [radsintheta.*cos(phi),radsintheta.*sin(phi), radius.*costheta];
Y = corrmatrix(X)
1. 0.0058073 0.0078778
0.0058073 1. 0.0014375
0.0078778 0.0014375 1.
//END
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Rafael
Guerra
Sent: 08 February 2018 18:55
To: Users mailing list for Scilab <users at lists.scilab.org>
Subject: Re: [Scilab-users] spatial correlation coefficient: Is the MATLAB
corrcoef function doing the job?
Hi Heinz,
Scilab computes the covariance matrix and from which the correlation matrix
can be obtained using formula in
https://en.wikipedia.org/wiki/Covariance_matrix
Check implementation below:
//START OF CODE
// https://en.wikipedia.org/wiki/Covariance_matrix
function Y=corrmatrix(M)
C = cov(M); // covariance matrix
D = sqrt(diag(C)); // standard deviations
D = inv(diag(D));
Y = D*C*D; // correlation matrix
endfunction
M = grand(9,3,"def")
M(:,2) = M(:,1)*2;
Y = corrmatrix(M);
disp(M,"M")
disp(Y,"Y")
// END OF CODE
Regards,
Rafael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180208/f50cd44d/attachment.htm>
More information about the users
mailing list