import numpy as np
X = np.arange(6).reshape(2,3)
np.cov(X)
#Results in:
array([[1., 1.],
[1., 1.]])
While it should output:
array([[0.66666667, 0.66666667],
[0.66666667, 0.66666667]])
As mentioned in comments, the default cov
is normalized by N-1
which is an unbiased estimate. To get simple average you can do either of these solutions:
np.cov(X,bias=True)
or
np.cov(X,ddof=0)
output:
[[0.66666667 0.66666667]
[0.66666667 0.66666667]]