module Nuggets::Range::QuantileMixin

Public Instance Methods

quantile(value[, order]) → anInteger click to toggle source

Determines the order-quantile of value in range.

# File lib/nuggets/range/quantile_mixin.rb, line 35
def quantile(value, order = 100)
  value < first ? 1 : value >= last ? order :
    ((value - first) / ((last - first) / order.to_f)).to_i + 1
end