Sha256: 15037975efd9f1d737db1b049f18173c27f2f5cc9cab2ff906f0e00a296c0fe2

Contents?: true

Size: 292 Bytes

Versions: 10

Compression:

Stored size: 292 Bytes

Contents

module Enumerable

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

  def mode
    max = 0
    c = Hash.new 0
    each {|x| cc = c[x] += 1; max = cc if cc > max}
    c.select {|k,v| v == max}.map {|k,v| k}
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/enumerable/mode.rb
facets-2.8.3 lib/core/facets/enumerable/mode.rb
facets-2.8.2 lib/core/facets/enumerable/mode.rb
facets-2.8.1 lib/core/facets/enumerable/mode.rb
facets-2.8.0 lib/core/facets/enumerable/mode.rb
facets-2.7.0 lib/core/facets/enumerable/mode.rb
facets-2.6.0 lib/core/facets/enumerable/mode.rb
facets-2.5.1 lib/core/facets/enumerable/mode.rb
facets-2.5.0 lib/core/facets/enumerable/mode.rb
facets-2.5.2 lib/core/facets/enumerable/mode.rb