[SciPy-User] scipy.stats.mstats.linregress bug?

josef.pktd at gmail.com josef.pktd at gmail.com
Fri Jun 24 11:35:25 EDT 2011


On Fri, Jun 24, 2011 at 11:28 AM, Andreas <lists at hilboll.de> wrote:
> Hi there,
>
> I found a peculiarity in scipy.stats.mstats.linregress. It doesn't give
> the same results as scipy.stats.linregress on a numpy.array (see below).
>
> Is this a bug or a feature?
>
> Cheers,
> Andreas.
>
> In [1]: import numpy
>
> In [2]: import scipy
>
> In [3]: numpy.__version__
> Out[3]: '1.5.1'
>
> In [4]: scipy.__version__
> Out[4]: '0.9.0'
>
> In [5]: import scipy.stats
>
> In [6]: import scipy.stats.mstats
>
> In [7]:
>
> In [8]: data = numpy.array([5.28511864e+15, 4.87487615e+15,
> 5.56279671e+15,
>   ...:                     4.72866954e+15, 5.08328669e+15,
> 4.06702155e+15,
>   ...:                     4.99224913e+15, 6.29268616e+15,
> 9.16149273e+15,
>   ...:                     5.47843819e+15, 5.86477063e+15,
> 6.96145031e+15,
>   ...:                     7.25725121e+15, 6.52453707e+15,
> 6.01766151e+15])

try to rescale, take away the e15, small numerical differences are
possible because of the different way the results are calculated.
There might still be a difference in the definition of the returns,
but I haven't checked recently.

Josef

>
> In [9]:
>
> In [10]: x = numpy.arange(data.shape[0])
>
> In [11]:
>
> In [12]: scipy.stats.linregress(x,data)
> Out[12]:
> (149163178178571.41,
>  4832678167416667.0,
>  0.53093100793359638,
>  0.041709303490156953,
>  66031024254034.961)
>
> In [13]: scipy.stats.mstats.linregress(x,data)
> Out[13]:
> (149163178178571.44,
>  4832678167416667.0,
>  0.53093100793359627,
>  masked_array(data = 0.0417093034902,
>             mask = False,
>       fill_value = 1e+20)
> ,
>  1028615575651548.9)
>
>
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list