Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Entropy/Clojure/entropy-1.clj
Normal file
7
Task/Entropy/Clojure/entropy-1.clj
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(defn entropy [s]
|
||||
(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 +))))
|
||||
2
Task/Entropy/Clojure/entropy-2.clj
Normal file
2
Task/Entropy/Clojure/entropy-2.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(entropy "1223334444")
|
||||
1.8464393446710154
|
||||
Loading…
Add table
Add a link
Reference in a new issue