Is there a standard way to do this?
Googling -- \"approximate entropy\" bits -- uncovers multiple academic papers but I\'d like to just find a chunk of pseudocode de
Using Shannon entropy of a word with this formula : http://imgur.com/a/DpcIH
Here's a O(n) algorithm that calculates it :
import math from collections import Counter def entropy(s): l = float(len(s)) return -sum(map(lambda a: (a/l)*math.log2(a/l), Counter(s).values()))