I am using Python library scipy to calculate Pearson's correlation for two float arrays. The returned value for coefficient is always 1.0, even if the arrays are different. For example:
[-0.65499887 2.34644428]
[-1.46049758 3.86537321]
I am calling the routine in this way:
r_row, p_value = scipy.stats.pearsonr(array1, array2)
The value of r_row
is always 1.0. What am I doing wrong?
Pearson's correlation coefficient is a measure of how well your data would be fitted by a linear regression. If you only provide it with two points, then there is a line passing exactly through both points, hence your data perfectly fits a line, hence the correlation coefficient is exactly 1.