Skip to content

Commit

Permalink
Update array.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
cheerfulstoic authored May 9, 2017
1 parent 846448a commit 5be22ab
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 5be22ab

Please sign in to comment.