June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
11
Task/Entropy/Factor/entropy.factor
Normal file
11
Task/Entropy/Factor/entropy.factor
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
USING: assocs kernel math math.functions math.statistics
|
||||
prettyprint sequences ;
|
||||
IN: rosetta-code.entropy
|
||||
|
||||
: shannon-entropy ( str -- entropy )
|
||||
[ length ] [ histogram >alist [ second ] map ] bi
|
||||
[ swap / ] with map
|
||||
[ dup log 2 log / * ] map-sum neg ;
|
||||
|
||||
"1223334444" shannon-entropy .
|
||||
"Factor is my favorite programming language." shannon-entropy .
|
||||
Loading…
Add table
Add a link
Reference in a new issue