I am calculating Pearson Correlation. At the end I have the result (correlation1) like below. I wonder why I have 0.0 for all the second coefficient as a result in correlation1. Is there anybody who could explain? Moreover, my correlation code is working slow. How I can make it fast?
Result (sample):
(0.52543523179249552, 0.0), (0.52543905756911169, 0.0), (0.52544196572206603, 0.0), (0.52545010637443945, 0.0)...
from scipy.stats import pearsonr
s1_list = []
s2_list = []
s3_list = []
s4_list = []
zip_list1 = []
zip_list2 = []
correlation1 = []
for x, y in zip(speed1_list, speed2_list):
zip1 = {"s1": float(x), "s2": float(y)}
s1_list.append(zip1["s1"])
s2_list.append(zip1["s2"])
zip_list1.append(zip1)
correlation1.append(pearsonr(s1_list,s2_list))
print correlation1
Inputs:
speed1_list:
[113.0, 116.0, 120.0, 120.0, 117.0, 127.0, 124.0, 118.0, 124.0, 128.0, 128.0, 125.0, 112.0, 122.0, 125.0, 133.0, 128.0, 129.0, 126.0, 123.0, 120.0, 118.0, 114.0, 119.0, 129.0, 127.0, 128.0, 122.0, 120.0, 125.0, 119.0...]
speed2_list:
[125.0, 123.0, 120.0, 115.0, 124.0, 120.0, 120.0, 119.0, 119.0, 122.0, 121.0, 116.0, 116.0, 119.0, 116.0, 113.0, 113.0, 115.0, 120.0, 122.0, 122.0, 113.0, 118.0, 121.0, 120.0, 119.0, 116.0...]
correlation1: (0.52543523179249552, 0.0), (0.52543905756911169, 0.0), (0.52544196572206603, 0.0), (0.52545010637443945, 0.0)...