user1681664
user1681664

Reputation: 1811

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?

Upvotes: 22

Views: 60815

Answers (1)

CT Zhu
CT Zhu

Reputation: 54340

You need numpy.corrcoef:

In [8]:

np.corrcoef(a1,a2)
Out[8]:
array([[ 1.        ,  0.98198051],
       [ 0.98198051,  1.        ]])

Upvotes: 43

Related Questions