September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
20
Task/Entropy/Scilab/entropy.scilab
Normal file
20
Task/Entropy/Scilab/entropy.scilab
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
function E = entropy(d)
|
||||
d=strsplit(d);
|
||||
n=unique(string(d));
|
||||
N=size(d,'r');
|
||||
|
||||
count=zeros(n);
|
||||
n_size = size(n,'r');
|
||||
for i = 1:n_size
|
||||
count(i) = sum ( d == n(i) );
|
||||
end
|
||||
|
||||
E=0;
|
||||
for i=1:length(count)
|
||||
E = E - count(i)/N * log(count(i)/N) / log(2);
|
||||
end
|
||||
endfunction
|
||||
|
||||
word ='1223334444';
|
||||
E = entropy(word);
|
||||
disp('The entropy of '+word+' is '+string(E)+'.');
|
||||
Loading…
Add table
Add a link
Reference in a new issue