function out=entropy(pos,neg) % information content / entropy % always does normalization, hence works with integers or reals sum=(pos+neg); p1=pos./(pos+neg); p2=neg./(pos+neg); out=-p1.*log2(p1)-p2.*log2(p2); % do some special processing to take care of 0*log2(0) out=min(out,isfinite(out));