from the sciPy library I used: scipy.stats.stats import pearsonr to calculate the correlation coefficient for two arrays and I got a value of: (0.80751532276005755, 0.19248467723994242).
I thought that I would have just got one value within the range -1 to +1, so I’m unsure how to interpret these two results. These are my two arrays:
x = [50,500,1500,2500]
y = [17, 6, 6, 194]
and I did:
pearsonr(x,y)
Thanks
pearsonr()returns a two-tuple consisting of the correlation coefficient and the corresponding p-value:For a further discussion, see http://www.eecs.qmul.ac.uk/~norman/blog_articles/p_values.pdf
If you just need to the correlation coefficient, simply ignore the second element of the tuple (the p-value):
It might be worth mentioning that there’s also
numpy.corrcoef(), which computes the correlation matrix (without p-values).