def correlation(a,b):
    #mean subtract
    a = a - a.mean()
    b = b - b.mean()

    #unit length - avoid dev by zero
    a = (1.0/sqrt((a*a).sum()+0.000001))*a
    b = (1.0/sqrt((b*b).sum()+0.000001))*b
                
    # correlation
    c = (a*b).sum()
    
    return c
Compute the correlation of two vectors
dataset/ETHPy150Open bolme/pyvision/src/pyvision/other/distance.py/correlation