
function [H] = binary_entropy(prob)

H = zeros(size(prob));
ind = find(prob>0 & prob<1); 
if (length(ind)>0),
  H(ind) = -prob(ind).*log(prob(ind))-(1-prob(ind)).*log(1-prob(ind));
end;
