% get_ntrpy - calculate entropy from prob dist
% [adapted from % Andrea Trevino - 4/23/15]

function hnow=get_ntrpy(loglikeli) 
xlikeli=exp(loglikeli); % posterior likelihoods
% posterior probability
nce=size(loglikeli,1);
sumxlikeli=repmat(sum(xlikeli),nce,1);
postprob=xlikeli./sumxlikeli; % the posterior for each theta_i
% current entropy H_now
log2post=(loglikeli-log(sumxlikeli))/log(2);
hnow=-sum(postprob.*log2post);
return
end

