How numpy.cov() function is implemented?

后端 未结 1 1595
粉色の甜心
粉色の甜心 2021-02-14 05:33

I have my own implementation of the covariance function based on the equation:

\"enter

1条回答
  •  清歌不尽
    2021-02-14 05:50

    The numpy function has a different normalization to yours as a default setting. Try instead

    >>> np.cov([X, Y], ddof=0)
    array([[ 273.88888889,  190.61111111],
           [ 190.61111111,  197.88888889]])
    

    References:

    • http://docs.scipy.org/doc/numpy/reference/generated/numpy.cov.html
    • http://en.wikipedia.org/wiki/Covariance#Calculating_the_sample_covariance

    0 讨论(0)
提交回复
热议问题