I have two arrays: 900x421 and 900x147. I need to correlate all columns from these arrays so that the output is 421x147. In Matlab function corr()
does it, but I can't find a function that does the same in python.
the numpy.corrcoef
function is the way to go. You need both arguments x
and y
to be of the same shape. You can do so by concatenate the two arrays. Let's say arr1
is of shape 900x421 and arr2
is of shape 900x147. You can do the following
import numpy as np
two_arrays = np.concatenate((arr1, arr2), axis=1) # 900x568
corr = np.corrcoef(two_arrays) # 568x568 array
desired_output = corr[0:421][422:]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.