[SciPy-user] Is this a bug: scipy.cov([0,1]) = 0

Steve Schmerler elcorto@gmx....
Wed Nov 7 09:36:33 CST 2007

Emin.shopper Martinian.shopper wrote:
> Dear Experts,
> I recently noticed some strange behavior with scipy (and numpy as
> well). Doing scipy.cov([0,1]) returns 0 which I believe is incorrect.
> Doing scipy.cov([0.0,1.0]) returns a more reasonable answer so I
> suspect that the problem is that scipy is using integer math.
> Is this considered a bug?
> I can see no good reason to do integer math when computing a covariance.

Works here.

In [14]: scipy.stats.cov([0,1])
Out[14]: 0.5

In [15]: scipy.cov([0,1])
Out[15]: array(0.5)

In [16]: numpy.cov([0,1])
Out[16]: array(0.5)

In [17]: numpy.cov([0.,1.])
Out[17]: array(0.5)

In [18]: scipy.cov([0.,1.])
Out[18]: array(0.5)

In [19]: scipy.stats.cov([0.,1.])
Out[19]: 0.5

In [20]: scipy.__version__
Out[20]: '0.7.0.dev3498'

In [21]: numpy.__version__
Out[21]: '1.0.5.dev4407'


Random number generation is the art of producing pure gibberish as quickly as 

More information about the SciPy-user mailing list