pearson
Pearson product-moment correlation coefficient.
Syntax
Section titled “Syntax”v = pearson(array1, array2)Description
Section titled “Description”Returns the Pearson correlation coefficient — a value in [-1, 1] measuring linear dependence between two variables. 1 is perfect positive correlation, -1 perfect negative, 0 no linear correlation.
Examples
Section titled “Examples”pearson([1 2 3 4], [2 4 6 8]) % 1.0 (perfect linear)pearson([1 2 3 4], [4 3 2 1]) % -1.0 (anti-correlated)See also
Section titled “See also”rsq— Square of the Pearson correlation coefficient (R²).covariance_s— Sample covariance.slope— Slope of a linear regression line.intercept— Y-intercept of a linear regression line.