Sha256: 85406ee33a0a1704c4c0f9fc1ede8fac5911a7f7cb2ef3afd239b7a4611763b3

Contents?: true

Size: 247 Bytes

Versions: 5

Compression:

Stored size: 247 Bytes

Contents

module Enumerable

  # In Statistics mode is the value that occurs most
  # frequently in a given set of data.
  #
  #  CREDIT: Trans

  def mode
    count = Hash.new(0)
    each {|x| count[x] += 1 }
    count.sort_by{|k,v| v}.last[0]
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
facets-2.4.0 lib/facets/enumerable/mode.rb
facets-2.4.1 lib/facets/enumerable/mode.rb
facets-2.4.4 lib/core/facets/enumerable/mode.rb
facets-2.4.2 lib/core/facets/enumerable/mode.rb
facets-2.4.3 lib/core/facets/enumerable/mode.rb