def weighted_median(points, weights):
sorted_indices = sp.argsort(points)
points = points[sorted_indices]
weights = weights[sorted_indices]
cs = sp.cumsum(weights)
median = sp.interp(.5, cs - .5*weights, points)
return median
评论列表
文章目录