vector correlation using standard deviation

6 visualizzazioni (ultimi 30 giorni)
Argumanh
Argumanh il 30 Mag 2018
Modificato: Argumanh il 30 Mag 2018
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

Risposte (0)

Prodotti


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by