Returns the linear correlation coefficient of x and y.
r = nisp_corrcoef ( x , y )
a n-by-1 or 1-by-n matrix of doubles
a n-by-1 or 1-by-n matrix of doubles
a 1-by-1 matrix of doubles, the linear correlation coefficient.
Returns the linear correlation coefficient of x and y. This is sometimes called Pearson's product-moment coefficient.
It is defined by
// "Introduction to probability and statistics for // engineers and scientists." // Sheldon Ross // Chapter 2 Descriptive statistics // Example 2.6a x = [24.2;22.7;30.5;28.6;25.5;32;28.6;26.5;25.3;26;24.4;24.8;20.6;.. 25.1;21.4;23.7;23.9;25.2;27.4;28.3;28.8;26.6]; y = [25;31;36;33;19;24;27;25;16;14;22;23;20;25;25;23;27;30;33;32;35;24]; expected = 0.4189 r = nisp_corrcoef ( x , y ) // Draw the scatter plot scf(); plot(x,y,"bo") // "Introduction to probability and statistics for // engineers and scientists." // Sheldon Ross // Chapter 2 Descriptive statistics // Example 2.6b x = [12 16 13 18 19 12 18 19 12 14]; y = [73 67 74 63 73 84 60 62 76 71]; r = nisp_corrcoef ( x , y ) expected = -0.7638 // For properly chosen data, the linear correlation // coefficient can be close to zero. n = 1000; x = linspace(-%pi/2,3*%pi/2,n); y = sin(x)+grand(1,n,"nor",0,0.5); r = nisp_corrcoef ( x , y ) // This does not imply that there is no dependency // between the variables scf(); plot(x,y,"bo") | ![]() | ![]() |
"Introduction to probability and statistics for engineers and scientists.", Sheldon Ross
http://en.wikipedia.org/wiki/Correlation_and_dependence