function [out]=hb(p)

if p == 0
    out = 0;
else
    out = - p.*log2(p) - (1-p).*log2(1-p);
end