June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
10
Task/Entropy/Common-Lisp/entropy-1.lisp
Normal file
10
Task/Entropy/Common-Lisp/entropy-1.lisp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(defun entropy (string)
|
||||
(let ((table (make-hash-table :test 'equal))
|
||||
(entropy 0))
|
||||
(mapc (lambda (c) (setf (gethash c table) (+ (gethash c table 0) 1)))
|
||||
(coerce string 'list))
|
||||
(maphash (lambda (k v)
|
||||
(decf entropy (* (/ v (length input-string))
|
||||
(log (/ v (length input-string)) 2))))
|
||||
table)
|
||||
entropy))
|
||||
Loading…
Add table
Add a link
Reference in a new issue