You ask a number of questions. Here are two answers. You ask how to compute the negative log likelihood. If you have the Statistics Toolbox and you are fitting a probability distribution, here's how to compute the negative log likelihood for the Poisson distribution. Note that it is smaller (likelihood is larger) at the mle than at a different value.
>> x = poissrnd(3,1000,1);
>> m = poissfit(x)
m =
2.9660
>> negloglik = -sum(log(poisspdf(x,m)))
negloglik =
1.9322e+03
>> negloglik = -sum(log(poisspdf(x,m+.1)))
negloglik =
1.9338e+03
You ask about a zero truncated distribution. Here I define a Poisson distribution truncated to exclude the zero value. Then I use the mle function to fit this to the same sample as above but with zero excluded.
>> ztpdf = @(x,m) (x>0).*poisspdf(x,m)./(1-poisspdf(0,m));
>> mle(x(x>0),'pdf',ztpdf,'start',1)
ans =
2.9678
Best Answer