Module: StatisticalMethods::Core::Array
- Included in:
- Array
- Defined in:
- lib/statistical_methods/core/array.rb
Overview
Extending class
Instance Method Summary collapse
- #addition ⇒ Object
- #group_by_count ⇒ Object
- #harmonic ⇒ Object
- #multiplication ⇒ Object
- #power(exponent) ⇒ Object
Instance Method Details
#addition ⇒ Object
5 6 7 |
# File 'lib/statistical_methods/core/array.rb', line 5 def addition reduce(:+) end |
#group_by_count ⇒ Object
21 22 23 24 25 26 |
# File 'lib/statistical_methods/core/array.rb', line 21 def group_by_count reduce(Hash.new(0)) do |hash, item| hash[item] += 1 hash end end |
#harmonic ⇒ Object
17 18 19 |
# File 'lib/statistical_methods/core/array.rb', line 17 def harmonic map { |value| 1.0 / value } end |
#multiplication ⇒ Object
9 10 11 |
# File 'lib/statistical_methods/core/array.rb', line 9 def multiplication reduce(:*) end |
#power(exponent) ⇒ Object
13 14 15 |
# File 'lib/statistical_methods/core/array.rb', line 13 def power(exponent) map { |value| value**exponent } end |