comparison tvii/distance.py @ 81:990a27e125f2

add distance norm function
author Jeff Hammel <k0scist@gmail.com>
date Sun, 17 Dec 2017 13:44:37 -0800
parents
children
comparison
equal deleted inserted replaced
80:3c7927f59b05 81:990a27e125f2
1 """
2 distance functions; really the `N` norm
3 """
4
5 def distance(x, y, N=2):
6 assert len(x) == len(y)
7 return sum([(_x - _y)**N
8 for _x, _y in zip(x, y)])**(1./N)