ElEve...

parent 8baf4227
...@@ -174,7 +174,10 @@ entropyTrie :: Entropy e => (k -> Bool) -> Trie k () -> Trie k e ...@@ -174,7 +174,10 @@ entropyTrie :: Entropy e => (k -> Bool) -> Trie k () -> Trie k e
entropyTrie _ (Leaf c) = Leaf c entropyTrie _ (Leaf c) = Leaf c
entropyTrie pred (Node c () children) = Node c e (map (entropyTrie pred) children) entropyTrie pred (Node c () children) = Node c e (map (entropyTrie pred) children)
where where
e = sum $ map f $ Map.toList children children' = Map.toList children
sum_count = sum $ _node_count . snd <$> children'
e | sum_count == 0 = nan
| otherwise = sum $ f <$> children'
f (k, child) = if pred k then chc * P.logBase 2 (fromIntegral c) f (k, child) = if pred k then chc * P.logBase 2 (fromIntegral c)
else - chc * P.logBase 2 chc else - chc * P.logBase 2 chc
where where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment