(self, data)
return entropy
Calculate entropy for provided data
Calculate entropy for provided data
Calculate entropy for provided data
def H(self, data):
        """
        Calculate entropy for provided data
        """
        if not data:
            return 0
        entropy = 0
        for x in range(256):
            p_x = float(data.count(chr(x)))/len(data)
            if p_x > 0:
                entropy += - p_x*math.log(p_x, 2)
        return entropy
def H ( self , data ) : if not data : return 0 entropy = 0 for x in range ( 256 ) : p_x = float ( data . count ( chr ( x ) ) ) / len ( data ) if p_x > 0 : entropy += - p_x * math . log ( p_x , 2 ) return entropy