class Gremlin::Quantile::Percentile
Attributes
percent[RW]
Public Class Methods
new(percent)
click to toggle source
# File lib/gremlin/quantile/percentile.rb, line 6 def initialize(percent) @percent = percent raise unless @percent end
Public Instance Methods
calculate(sorted_values)
click to toggle source
# File lib/gremlin/quantile/percentile.rb, line 17 def calculate(sorted_values) sorted_values[(@percent * sorted_values.count).to_i] end
serialize()
click to toggle source
# File lib/gremlin/quantile/percentile.rb, line 21 def serialize to_h.to_json end
to_h()
click to toggle source
# File lib/gremlin/quantile/percentile.rb, line 11 def to_h { percent: @percent, } end