I'm trying to create a function that can calculate the sum of products in Python.
I have two lists:
x1 = [3, 1, 3, 1, 3, 13]
x2 = [2, 3, 31, 3, 13, 3]
My idea is to take the mean of both of them:
m1 = mean(x1)
m2 = mean(x2)
And then calculate:
(x1[0] - m1) * (x2[0] - m2)+(x1[1] - m1) * (x2[1] - m2)+(x1[2] - m1)*(x2[2] - m2)... until the end of both of the lists.