class Airbrake::TDigest
def p_rank(x)
rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize
def p_rank(x) is_array = x.is_a? Array x = [x] unless is_array min = @centroids.first max = @centroids.last x.map! do |item| if size == 0 nil elsif item < min[1].mean 0.0 elsif item > max[1].mean 1.0 else _cumulate(true) bound = bound_mean(item) lower, upper = bound mean_cumn = lower.mean_cumn if lower != upper mean_cumn += (item - lower.mean) * (upper.mean_cumn - lower.mean_cumn) \ / (upper.mean - lower.mean) end mean_cumn / @size end end is_array ? x : x.first end