def numersum(test_median, data_point):
"""Provides the denominator of the weiszfeld algorithm depending on whether you are adjusting the candidate x or y."""
try:
return 1 / vincenty(test_median, data_point).kilometers
except ZeroDivisionError:
return 0 # filter points that equal the median out (otherwise no convergence)
except ValueError:
# Vincenty doesn't always converge so fall back on great circle distance which is less accurate but always converges
return 1 / great_circle(test_median, data_point).kilometers
评论列表
文章目录