Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

correlation between arrays in python

I have 2 arrays.

 a1 = [1,2,4]
 a2 = [3,4,5]

how would I find the correlation between these 2 arrays using python.

In matlab, you would do:

corr(a1,a2)

How to do this in python?

like image 799
user1681664 Avatar asked Feb 21 '14 01:02

user1681664


1 Answers

You need numpy.corrcoef:

In [8]:

np.corrcoef(a1,a2)
Out[8]:
array([[ 1.        ,  0.98198051],
       [ 0.98198051,  1.        ]])
like image 116
CT Zhu Avatar answered Oct 06 '22 09:10

CT Zhu