view 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
line wrap: on
line source

"""
distance functions; really the `N` norm
"""

def distance(x, y, N=2):
    assert len(x) == len(y)
    return sum([(_x - _y)**N
                for _x, _y in zip(x, y)])**(1./N)