function y = binaryentropy(p)
y = zeros(size(p));
i = find(0<p & p<1);
y(i) = -(p(i).*log2(p(i)) + (1-p(i)).*log2(1-p(i)));