Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,9 +1,7 @@
|
|||
(defn entropy [s]
|
||||
(let [len (count s)
|
||||
freqs (frequencies s)
|
||||
log-of-2 (Math/log 2)]
|
||||
(->> (keys freqs)
|
||||
(map (fn [c]
|
||||
(let [rf (/ (get freqs c) len)]
|
||||
(* -1 rf (/ (Math/log rf) log-of-2)))))
|
||||
(let [len (count s), log-2 (Math/log 2)]
|
||||
(->> (frequencies s)
|
||||
(map (fn [[_ v]]
|
||||
(let [rf (/ v len)]
|
||||
(-> (Math/log rf) (/ log-2) (* rf) Math/abs))))
|
||||
(reduce +))))
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(H "1223334444")
|
||||
(entropy "1223334444")
|
||||
1.8464393446710154
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue