diff options
Diffstat (limited to 'Entropy.hs')
-rw-r--r-- | Entropy.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Entropy.hs b/Entropy.hs new file mode 100644 index 0000000..2ff28b2 --- /dev/null +++ b/Entropy.hs @@ -0,0 +1,9 @@ +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 |