code: def entropy_H(self, data):
          
  
          if not data:
              return 0.0
  
          occurences = Counter(bytearray(data))
  
          entropy = 0
          for x in occurences.values():
              p_x = float(x) / len(data)
              entropy -= p_x*math.log(p_x, 2)
  
          return entropy
docs: Calculate the entropy of a chunk of data.