Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Entropy/Raku/entropy-1.raku
Normal file
5
Task/Entropy/Raku/entropy-1.raku
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
sub entropy(@a) {
|
||||
[+] map -> \p { p * -log p }, bag(@a).values »/» +@a;
|
||||
}
|
||||
|
||||
say log(2) R/ entropy '1223334444'.comb;
|
||||
9
Task/Entropy/Raku/entropy-2.raku
Normal file
9
Task/Entropy/Raku/entropy-2.raku
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
use MONKEY-TYPING;
|
||||
augment class Bag {
|
||||
method entropy {
|
||||
[+] map -> \p { - p * log p },
|
||||
self.values »/» +self;
|
||||
}
|
||||
}
|
||||
|
||||
say '1223334444'.comb.Bag.entropy / log 2;
|
||||
Loading…
Add table
Add a link
Reference in a new issue