Is there a way to find a deviation between a1=[] and a2=[] in Python?

88 Views Asked by At

We have these arrays in python:

a1 = [0, 1, 2, 3]
a2 = [0, 1.1, 2.2, 3.1]

and want to find the deviation between a1 and a2. And sorry, we do not know what's such a type of deviation is named, but probably some of you do know.

1

There are 1 best solutions below

0
BrokenBenchmark On

You can find the sum of squared distances (as clarified in the comments) by using sum() and zip():

distance = sum([(elem1 - elem2)**2 for elem1, elem2 in zip(a1, a2)])