对于以下示例代码,我将获得2x2协方差矩阵。我如何获得3x3协方差矩阵呢?

a = [3,9,8,2]
b = [4,7,2,5]
c = [3,4,6,7]

cov_abc = np.cov(a,b,c)

print cov_abc

最佳答案

尝试

x = np.vstack([a,b,c])
cov = np.cov(x)

关于python - 如何在Python中获取n个数组的n x n个协方差矩阵?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30051582/

10-11 16:47