Numpy Covariance Matrix numpy.cov
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Magical Minnie Puzzles
--
Chapters
00:00 Question
01:03 Accepted answer (Score 16)
01:23 Answer 2 (Score 1)
01:46 Thank you
--
Full question
https://stackoverflow.com/questions/4317...
Accepted answer links:
[documentation]: https://docs.scipy.org/doc/numpy/referen...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #matlab #numpy #sympy #covariance
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Magical Minnie Puzzles
--
Chapters
00:00 Question
01:03 Accepted answer (Score 16)
01:23 Answer 2 (Score 1)
01:46 Thank you
--
Full question
https://stackoverflow.com/questions/4317...
Accepted answer links:
[documentation]: https://docs.scipy.org/doc/numpy/referen...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #matlab #numpy #sympy #covariance
#avk47
ACCEPTED ANSWER
Score 17
Amazingly, the documentation might tell you. You should pass rowvar=False to indicate that columns represent variables.
>>> data.shape
(768, 8)
>>> numpy.cov(data, rowvar=False).shape
(8, 8)
ANSWER 2
Score 1
as per default, each row is observation, each column is feature, which is swaped in numpi per definition, so all you need to do is transpose, where R is matrix
np.cov(R.T)
or
np.cov(R, rowvar = False)