[SciPy-User] scipy.stats.linregress

Jerome Kieffer Jerome.Kieffer at esrf.fr
Tue Feb 12 02:59:27 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
On-Line Data analysis / Software Group 
ISDD / ESRF
tel +33 476 882 445



More information about the SciPy-User mailing list