Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Entropy/Emacs-Lisp/entropy-1.l
Normal file
15
Task/Entropy/Emacs-Lisp/entropy-1.l
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(defun shannon-entropy (input)
|
||||
(let ((freq-table (make-hash-table))
|
||||
(entropy 0)
|
||||
(length (+ (length input) 0.0)))
|
||||
(mapcar (lambda (x)
|
||||
(puthash x
|
||||
(+ 1 (gethash x freq-table 0))
|
||||
freq-table))
|
||||
input)
|
||||
(maphash (lambda (k v)
|
||||
(set 'entropy (+ entropy
|
||||
(* (/ v length)
|
||||
(log (/ v length) 2)))))
|
||||
freq-table)
|
||||
(- entropy)))
|
||||
2
Task/Entropy/Emacs-Lisp/entropy-2.l
Normal file
2
Task/Entropy/Emacs-Lisp/entropy-2.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(shannon-entropy "1223334444")
|
||||
1.8464393446710154
|
||||
Loading…
Add table
Add a link
Reference in a new issue