def _weighted_percentile(array, sample_weight, percentile=50):
 sorted_idx = np.argsort(array)
 weight_cdf = stable_cumsum(sample_weight[sorted_idx])
 percentile_idx = np.searchsorted(weight_cdf, ((percentile / 100.0) * weight_cdf[(-1)]))
 return array[sorted_idx[percentile_idx]]

def _weighted_percentile ( array , sample_weight , percentile = 50 ) : sorted_idx = np . argsort ( array ) weight_cdf = stable_cumsum ( sample_weight [ sorted_idx ] ) percentile_idx = np . searchsorted ( weight_cdf , ( ( percentile / 100.0 ) * weight_cdf [ ( - 1 ) ] ) ) return array [ sorted_idx [ percentile_idx ] ]
compute the weighted percentile of array with sample_weight .