Class: StatisticalMethods::SummaryStatistic::Location::Mode
- Inherits:
-
Object
- Object
- StatisticalMethods::SummaryStatistic::Location::Mode
- Defined in:
- lib/statistical_methods/summary_statistic/location/mode.rb
Instance Method Summary collapse
- #find ⇒ Object
-
#initialize(array) ⇒ Mode
constructor
A new instance of Mode.
Constructor Details
#initialize(array) ⇒ Mode
Returns a new instance of Mode.
5 6 7 |
# File 'lib/statistical_methods/summary_statistic/location/mode.rb', line 5 def initialize(array) @array = array end |
Instance Method Details
#find ⇒ Object
9 10 11 12 13 14 |
# File 'lib/statistical_methods/summary_statistic/location/mode.rb', line 9 def find return if @array.empty? hash = @array.group_by_count max = hash.values.max hash.keep_if { |_key, value| value == max }.keys end |