scan-context/src/example/longterm_localization/NCLT/2012-01-15/3_Inference/PRcurve/src/EntropyOfVector.m

17 lines
217 B
Matlab

function H = EntropyOfVector(vec)
len = length(vec);
H = 0;
for ith=1:len
pith = vec(ith);
if(pith == 0)
H = H + 0; % 0log0 = 0
else
H = H + ( -1 * (pith*log2(pith)) );
end
end
end