module Entropy where import Data.List entropy :: String -> Double entropy = sum . map lg' . fq' . map (fromIntegral.length) . group . sort where lg' c = (c * ) . logBase 2 $ 1.0 / c fq' c = let sc = sum c in map (/ sc) c