Module: DescriptiveStatistics::Dispersion
- Included in:
- AllMethods
- Defined in:
- lib/descriptive-statistics/dispersion.rb
Instance Method Summary collapse
Instance Method Details
#percentile_from_value(value) ⇒ Object
9 10 11 12 |
# 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 ⇒ Object
3 4 5 6 7 |
# 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) ⇒ Object
14 15 16 17 18 |
# 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 |