Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -6,7 +6,7 @@ func entropy s$ .
|
|||
for cnt in d[]
|
||||
if cnt > 0
|
||||
prop = cnt / len s$
|
||||
entr -= (prop * logn prop / logn 2)
|
||||
entr -= (prop * log10 prop / log10 2)
|
||||
.
|
||||
.
|
||||
return entr
|
||||
|
|
|
|||
16
Task/Entropy/SETL/entropy.setl
Normal file
16
Task/Entropy/SETL/entropy.setl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
program shannon_entropy;
|
||||
print(entropy "1223334444");
|
||||
|
||||
op entropy(symbols);
|
||||
hist := {};
|
||||
loop for symbol in symbols do
|
||||
hist(symbol) +:= 1;
|
||||
end loop;
|
||||
h := 0.0;
|
||||
loop for count = hist(symbol) do
|
||||
f := count / #symbols;
|
||||
h -:= f * log f / log 2;
|
||||
end loop;
|
||||
return h;
|
||||
end op;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue