module DescriptiveStatistics::Dispersion

Public Instance Methods

percentile_from_value(value) click to toggle source
# File lib/descriptive-statistics/dispersion.rb, line 9
def percentile_from_value(value)
  return if length < 1
  (sort.index(value) / length.to_f * 100).ceil
end
range() click to toggle source
# File lib/descriptive-statistics/dispersion.rb, line 3
def range
  return if length < 1
  sorted = sort
  sorted.last - sorted.first
end
value_from_percentile(percentile) click to toggle source
# File lib/descriptive-statistics/dispersion.rb, line 14
def value_from_percentile(percentile)
  return if length < 1
  value_index = (percentile.to_f / 100 * length).ceil
  sort[value_index]
end