Sha256: 7e014b884d632e72258f303f7c434f7587d49d86e625a79a7bf8dd59be095837
Contents?: true
Size: 388 Bytes
Versions: 4
Compression:
Stored size: 388 Bytes
Contents
class Range # Calculate the kth n-tile in a range. # # If n=4 the quantity is called a quartile, and if n=100 # it is called a percentile. # # @uncommon # require 'facets/range/quantile' # # @return [Integer] the kth n-tile def quantile(k, n=100) return 1 if k < first return n if k >= last ((k - first) / ((last - first) / n.to_f)).to_i + 1 end end
Version data entries
4 entries across 4 versions & 2 rubygems