循环索引上的numpy数组并应用函数

时间:2017-05-11 18:38:16

标签: numpy

我通过循环矩阵的索引在时间序列上建立相关矩阵。目前,我的代码是

def make_correlation_matrix(ts):
    num_regions = ts.shape[0]
    corr_mat = np.zeros((num_regions, num_regions))
    for i in range(num_regions):
        for j in range(num_regions):
            corr_mat[i,j] = np.correlate(ts[i,:], ts[j,:])
    return corr_mat

有更好/更有效的方法吗?感谢。

0 个答案:

没有答案
相关问题