view tvii/distance.py @ 82:c05ce6b7f941

test distance calculations
author Jeff Hammel <k0scist@gmail.com>
date Sun, 17 Dec 2017 13:45:44 -0800
parents 990a27e125f2
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)