R = corrcoef(M) returns the matrix of correlation coefficients forM, where the columns of M represent random variables and the rows represent observations.
The Pearson correlation coefficient between variables X
and Y
is: rXY=σXσYcov(X,Y)=∑i=1n(xi−xˉ)2∑i=1n(yi−yˉ)2∑i=1n(xi−xˉ)(yi−yˉ)
where xˉ
and yˉ
are the sample means, and σX
, σY
are the standard deviations.
The correlation coefficient ranges from -1 to +1, where -1 indicates perfect negative correlation, +1 indicates perfect positive correlation, and 0 indicates no linear correlation.