Correlation: is this correct?

回答 (1 件)

George Papazafeiropoulos
George Papazafeiropoulos 2013 年 3 月 8 日

0 投票

Dear Nuchto,
See this:
x=rand(4,30); y=10*x+5; corr=sum(zscore(x',1).*zscore(y',1))'/size(x,2)
this is different from your version, where zscore scales X using the sample standard deviation, with n - 1 in the denominator of the standard deviation formula. zscore(X,0) is the same as zscore(X). In the above version zscore(X,1) scales X using the population standard deviation,with n in the denominator of standard deviation formula. This is the right way since the correlation coefficient r is given by [Σ(xi*yi)-(Σxi)*(Σyi)/N]/{[Σxi^2-(Σxi)^2/N]*[Σyi^2-(Σyi)^2/N]}^(1/2) and after some mathematical operations gives the above formula.
Greetings,
George Papazafeiropoulos

3 件のコメント

Nuchto
Nuchto 2013 年 3 月 8 日
Thanks! I actually never understood where this size(x,2) comes from. I thought it should be already included in the zscore part. But my knowledge of this is very basic.
George Papazafeiropoulos
George Papazafeiropoulos 2013 年 3 月 8 日
Alternatively, look at the function corrcoef(X). Good luck!
George Papazafeiropoulos
George Papazafeiropoulos
George Papazafeiropoulos 2013 年 3 月 8 日
Because in the denomimators of the original formula N appears, not N-1.

サインインしてコメントする。

タグ

質問済み:

2013 年 3 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by