function H = entropy2(p)
% ENTROPY2 accepts probability mass function 
% as a row vector, calculate the corresponding 
% entropy in bits.
p=p(find(abs(sort(p)-1)>1e-8)); % Eliminate 1
p=p(find(abs(p)>1e-8)); % Eliminate 0
if length(p)==0
    H = 0;
else
    H = -sum(p.*log(p))/log(2);
end
