Entropy/Narcissist: Difference between revisions
added Factor
(Added Erlang version) |
(added Factor) |
||
Line 177:
My entropy is 5.00988934931771
</pre>
=={{header|Factor}}==
<lang factor>USING: assocs io io.encodings.utf8 io.files kernel math
math.functions math.statistics prettyprint sequences ;
IN: rosetta-code.entropy-narcissist
: entropy ( seq -- entropy )
[ length ] [ histogram >alist [ second ] map ] bi
[ swap / ] with map
[ dup log 2 log / * ] map-sum neg ;
"entropy-narcissist.factor" utf8 [
contents entropy .
] with-file-reader</lang>
{{out}}
<pre>
4.591946214804276
</pre>
=={{header|FreeBASIC}}==
<lang FreeBASIC>' version 01-06-2016
|