9951 explained code solutions for 126 technologies


python-numpyGet correlation of two Numpy arrays


import numpy as np

a1 = np.array([1,1,2,1,2])
a2 = np.array([2,2,4,2,4])

cor = np.corrcoef(a1, a2)ctrl + c
import numpy as np

load Numpy module for Python

a1

first sample array

a2

second sample array

.corrcoef(

return Pearson product-moment correlation coefficients of specified arrays

cor

will contain generated coefficients matrix