I am writing an algorithm in Python to fit a data (I need to write my own algorithm). But I have a problem with the arrays. For example:
import math
x=[2,1]
a=sum([x[i]*x[i] for i in range(len(x))])
It is working. However when I tried to divide, it is not working.
import math
x=[2,1,5]
y=[3,2,5]
a=sum(([y[i]*y[i] for i in range(len(x))])/([x[i]*x[i] for i in range(len(x))]))
How can I fix it? Do you have any idea?