Skip to content

Commit

Permalink
Merge pull request #35 from cheerfulstoic/patch-3
Browse files Browse the repository at this point in the history
De-sum 2
  • Loading branch information
igrigorik authored Apr 6, 2018
2 parents 5ba86e0 + 5be22ab commit 2486d0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core_extensions/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Array
def entropy
each_with_object(Hash.new(0)) do |i, result|
result[i] += 1
end.values.sum do |count|
end.values.inject(0, :+) do |count|
percentage = count.to_f / length

-percentage * Math.log2(percentage)
Expand Down

0 comments on commit 2486d0d

Please sign in to comment.