Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们在 python 中有这些数组:
a1 = [0, 1, 2, 3] a2 = [0, 1.1, 2.2, 3.1]
并想找到a1和a2之间的偏差。抱歉,我们不知道这种偏差的名称是什么,但可能你们中的一些人知道。
sum()您可以使用and找到平方距离的总和(如评论中所述)zip():
sum()
zip()
distance = sum([(elem1 - elem2)**2 for elem1, elem2 in zip(a1, a2)])