def get_composition_distance(self, comp_vect1, comp_vect2):
"""
Returns the normalized distance between two composition vectors, which
is defined as the L1 norm of their difference, divided by 2 to
normalize (so the maximum distance is 1 and the minimum distance is 0).
Args:
comp_vect1: the first composition vector, as a numpy array
comp_vect2: the second composition vector, as a numpy array
"""
# compute the different between the two composition vectors
diff_vector = np.subtract(comp_vect1, comp_vect2)
# compute the L1 norm of the difference vector
return 0.5*np.linalg.norm(diff_vector, ord=1)
评论列表
文章目录