我有一个相当大的矩阵(大约50K行),我想打印矩阵中每行之间的相关系数.我编写了这样的Python代码:
for i in xrange(rows): # rows are the number of rows in the matrix.
for j in xrange(i, rows):
r = scipy.stats.pearsonr(data[i,:], data[j,:])
print r
Run Code Online (Sandbox Code Playgroud)
请注意,我正在使用pearsonrscipy模块提供的功能(http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.pearsonr.html).
我的问题是:有更快的方法吗?我可以使用一些矩阵分区技术吗?
谢谢!