# HG changeset patch # User Jeff Hammel # Date 1513547077 28800 # Node ID 990a27e125f2eb6876dceca92915e996880b7213 # Parent 3c7927f59b05ad3e6610e60994e8aa3e1b9d31e9 add distance norm function diff -r 3c7927f59b05 -r 990a27e125f2 tvii/distance.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tvii/distance.py Sun Dec 17 13:44:37 2017 -0800 @@ -0,0 +1,8 @@ +""" +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)