The correlation coefficient of 2 variables is

r = (S(xy) over all x,y 1..N)/sqrt(S(x*x)*S(y*y))

If SXY is sum of Xi*Yi over all i, SX2 is sum of
Xi*Xi and SY2 is sum of Yi*Yi, and SX is sum of Xi and
SY is sum of Yi then

r=(N*SXY-SX*XY)/SQRT((N*SX2-SX*SX)*(N*SY2-SY*SY))


