from statistics import pstdev, mean


# Original code: https://stackoverflow.com/a/17389980
def pearson(x, y):
    sx = []
    sy = []

    # Calculate mean and stdev now so we don't have to calculate
    # it every time we come across another value.
    # Size and content of `x` and `y` shouldn't change so this should be fine.
    mx = mean(x)
    my = mean(y)

    stdx = pstdev(x)
    stdy = pstdev(y)

    for i in x:
        sx.append((i - mx) / stdx)

    for j in y:
        sy.append((j - my) / stdy)

    return sum([i * j for i, j in zip(sx, sy)]) / len(x)

@@ -29,16 +29,44 @@
 v, mean%0A
+from decimal import Decimal%0A
 %0A%0A# Orig
@@ -132,16 +132,111 @@
 (x, y):%0A
+    # Fix floating point shit%0A    x = %5BDecimal(i) for i in x%5D%0A    y = %5BDecimal(j) for j in y%5D%0A%0A
     sx =
@@ -459,15 +459,24 @@
 x = 
+Decimal(
 mean(x)
+)
 %0A   
@@ -485,15 +485,24 @@
 y = 
+Decimal(
 mean(y)
+)
 %0A%0A  
@@ -510,16 +510,24 @@
  stdx = 
+Decimal(
 pstdev(x
@@ -527,16 +527,17 @@
 stdev(x)
+)
 %0A    std
@@ -540,16 +540,24 @@
  stdy = 
+Decimal(
 pstdev(y
@@ -557,16 +557,17 @@
 stdev(y)
+)
 %0A%0A    fo
@@ -673,13 +673,10 @@
    r
-eturn
+ =
  sum
@@ -718,8 +718,29 @@
  len(x)%0A
+%0A    return float(r)%0A

Fix floating point shit