Method: Array#ideal_entropy

Defined in:
lib/core/facets/array/entropy.rb

#ideal_entropyObject

Returns the maximum possible Shannon entropy of the array with given size assuming that it is an “order-0” source (each element is selected independently of the next).

CREDIT: Derek



32
33
34
35
36
# File 'lib/core/facets/array/entropy.rb', line 32

def ideal_entropy
  arr = self
  unitProb = 1.0.to_f / arr.size.to_f
  (-1.to_f * arr.size.to_f * unitProb * Math.log(unitProb)/Math.log(2.to_f))
end