How can I calculate the mode of a floating point array in Ruby? -
i have array of floating point data, pick out probable value. called "mode" in descriptive statistics. how can calculate in ruby, or of gem.
[0.0, 0.1, 0.2, 0.1, 0.3, 0.3, 0.1] .group_by{|e| e}.max_by{|k, v| v.length}.first # => 0.1
Comments
Post a Comment