M=[0.25,0.20,0.15,0.12,0.10,0.08,0.05,0.05];
a=0;
for j=1:8
    a=a - M(j)* log2( M(j) );
end

