class Airbrake::TDigest
def percentile(p)
rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
def percentile(p) is_array = p.is_a? Array p = [p] unless is_array p.map! do |item| unless (0..1).cover?(item) raise ArgumentError, "p should be in [0,1], got #{item}" end if size == 0 nil else _cumulate(exact: true) h = @size * item lower, upper = bound_mean_cumn(h) if lower.nil? && upper.nil? nil elsif upper == lower || lower.nil? || upper.nil? (lower || upper).mean elsif h == lower.mean_cumn lower.mean else upper.mean end end end is_array ? p : p.first end