Skip to content

pearson

Pearson product-moment correlation coefficient.

v = pearson(array1, array2)

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.

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)
  • 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.