Search code examples
pythonnumpymatrixcovariancenormalize

Numpy covariance matrix nonrmalisation


I know that numpy.cov calculates the covariance given a N dimensional array.

I can see from the documentation on GitHub that the normalisation is done by (N-1). But for my specific case, the covariance matrix is given by:

enter image description here

where xi is the quantity. i and j are the bins.

As you can see from the above equation, this covariance matrix is normalised by (N-1)/N.

TO GET THE ABOVE NORMALISATION

Can I simply multiply the covariance matrix obtained from numpy.cov by (N-1)**2 / N to get the above normalisation? Is that correct?

Or Should I use the bias parameter inside numpy.cov? If so how?


Solution

  • There are two ways of doing this.

    1. We can call np.cov with bias=1 and then multiply the result by N-1

    or

    1. We can multiply the overall covariance matrix obtained by (N-1)**2/N