class StatisticalMethods::SummaryStatistic::Location::Mode

Public Class Methods

new(array) click to toggle source
# File lib/statistical_methods/summary_statistic/location/mode.rb, line 5
def initialize(array)
  @array = array
end

Public Instance Methods

find() click to toggle source
# 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