vector correlation using standard deviation
5 views (last 30 days)
Show older comments
Dear MATLAB users,
I am trying to see the correlation between two vectors. I define vectors, then I shuffle one of them. take the dot product's standard deviation and calculate the comparison in terms of sigma(by dividing it by sigma). When I add a command to normalize these vectors, the answer changes, I wonder where I did wrong! since I believe that it should not change by normalizing vectors.
% Sample Vectors
x=[1,12,45,46,58,61,7,8];
y=[4,5,6,34,54,23,94,200];
% Length of the Vectors
N=8;
%%%Definng Cell arrays for Vectors
x_rand=cell(N,1);
y_rand=cell(N,1);
miu=cell(N,1);
% random shuffle using cell array
for i=1:N
x_rand{i}=x(randperm(N));
y_rand{i}=y(randperm(N));
miu{i}=((dot(x_rand{i},y_rand{i})));
end
Miu=mean(cell2mat(miu));
dotProduct=dot(x,y);
% Standard Deviation
numerator=((x_rand{i}.*y_rand{i})-Miu).^2;
NumSum=sum(numerator);
sigma=sqrt(NumSum/N);
% Comparison in terms if sigma
Comp=(dotProduct-Miu)/sigma
I would highly appreciate any kind of help.
Best,
Armin
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!