2

I would like to calculate the Covariance matrix of two distributions, what could be the possible ways to calculate them in python?

Mark Lakata
  • 19,989
  • 5
  • 106
  • 123
pacodelumberg
  • 2,214
  • 4
  • 25
  • 32

1 Answers1

6

You should use numpy.

>>> from numpy import cov
>>> cov([1, 2, 3], [2, 12, 14])
array([[  1.        ,   6.        ],
       [  6.        ,  41.33333333]])
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
David Robinson
  • 77,383
  • 16
  • 167
  • 187