Frechet Distance
Frechet distance 是法国数学家 Maurice Rene Frechet 在1906年提出的一种路径空间相似形描述,直观理解,Frechet Distance 就是狗绳距离:主人走路径A,狗走路径B,各自走完这两条路径过程中所需要的最短狗绳长度。
以下是对于一维数据,两条曲线进行弗雷歇距离计算,作为曲线相似度的度量值一:
def calculate_euclid(point_a, point_b):
"""
Args:
point_a: a data point of curve_a
point_b: a data point of curve_b
Return:
The Euclid distance between point_a and point_b
"""
return math.sqrt((point_a - point_b)**2)
def calculate_frechet_distance(dp,i,j ,curve_a, curve_b):
"""
Args:
dp: The distance matrix
i: The index of curve_a
j: The index of curve_b
curve_a: The data sequence of curve_a
curve_b: The data sequence of curve_b
Return:
The frechet distance between curve_a[i] and curve_b[j]
"""
if dp[i][j] > -1:<