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

Jérôme Kieffer google at terre-adelie.org
Mon Feb 11 15:34:13 EST 2013


Dear Scipy Community,

I am looking at the scipy.stats.linregress code and see:
    # average sum of squares:
    ssxm, ssxym, ssyxm, ssym = np.cov(x, y, bias=1).flat
    r_num = ssxym
    r_den = np.sqrt(ssxm*ssym)
    if r_den == 0.0:
        r = 0.0
    else:
        r = r_num / r_den
        if (r > 1.0): r = 1.0 # from numerical error

if the slope is negative, the correlation factor R is -1, not one so one should add:
        
        if (r < -1.0): r = -1.0 # from numerical error

or did I completely mis-understood the code ?

Cheers,


-- 
Jérôme Kieffer <google at terre-adelie.org>



More information about the SciPy-User mailing list