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

Emin.shopper Martinian.shopper emin.shopper at gmail.com
Wed Nov 7 15:37:28 EST 2007


Ahh, good point. I was using numpy version 1.0 and scipy version
0.5.2. I guess its time to upgrade.

Thanks,
-Emin

On Nov 7, 2007 10:36 AM, Steve Schmerler <elcorto at gmx.net> wrote:
>
> 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'
>
>
> --
> cheers,
> steve
>
> Random number generation is the art of producing pure gibberish as quickly as
> possible.
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list