Entropy: Difference between revisions
Content added Content deleted
(Rewrote it in a more functional style.) |
|||
Line 1,962: | Line 1,962: | ||
(setq LN2 0.693147180559945309417) |
(setq LN2 0.693147180559945309417) |
||
(de |
(de tabulate-chars (Str) |
||
(let Map NIL |
(let Map NIL |
||
(for Ch (chop Str) |
(for Ch (chop Str) |
||
Line 1,972: | Line 1,972: | ||
(de entropy (Str) |
(de entropy (Str) |
||
(let ( |
(let ( |
||
Sz (length Str) |
Sz (length Str) |
||
Hist (tabulate-chars Str) |
|||
) |
) |
||
(*/ |
|||
(for Counts (freq-table Str) |
|||
(sum |
|||
⚫ | |||
( |
'((Pair) |
||
(*/ |
(let R (*/ (cdr Pair) 1. Sz) |
||
⚫ | |||
Hist) |
|||
1. LN2))) |
|||
</lang> |
</lang> |
||
{{Out}} |
{{Out}} |
||
Line 1,985: | Line 1,989: | ||
-> "1.84643934" |
-> "1.84643934" |
||
</pre> |
</pre> |
||
=={{header|PL/I}}== |
=={{header|PL/I}}== |
||
<lang pli>*process source xref attributes or(!); |
<lang pli>*process source xref attributes or(!); |