how to compute correlation coefficient without using any matlab functions Except the mean function?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
nesrine KEFIF
am 27 Dez. 2014
Beantwortet: Star Strider
am 27 Dez. 2014
how i can compute a correlation coefficient which accepts as input two arrays x and y of the same length representing the data sample and, returns their correlation coefficient (i loaded the x and y inputs as arrays). without using any matlab functions Except the mean function.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 27 Dez. 2014
x = randi(10,25,1); % Create Data
y = randi(10,25,1); % Create Data
xm = mean(x);
ym = mean(y);
[sxy,s2x,s2y] = deal(0,0,0);
for k1 = 1:length(x)
sxy = sxy + (x(k1)-xm)*(y(k1)-ym);
s2x = s2x + (x(k1)-xm)^2;
s2y = s2y + (y(k1)-ym)^2;
end
r = sxy / (sqrt(s2x)*sqrt(s2y));
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Descriptive Statistics and Visualization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!