MATLAB: Error in Poisson’s distribution.

pdfpoissons

have some example data, trying to use poisson's PDF, (this is a small part of the overall code) but keep getting a error of. Any ideas where i've gone wrong. I can get Weibull pdf & Gamma pdf to work using the same process.
??? Attempted to access paramEsts(2); index out of bounds because numel(paramEsts)=1.
Error in => fix at 4
pdfEst = poisspdf(xgrid,paramEsts(1),paramEsts(2));
Data = [15 6 7 3 4 9 6 1 1 2 3 4 5 9 7 7 7 5 1 1];
xgrid = linspace(0,20);
paramEsts = poissfit(Data);
pdfEst = poisspdf(xgrid,paramEsts(1),paramEsts(2));

Best Answer

  • As you have written it, 'paramEsts' will be a single scalar consisting of the maximum likelihood estimate of the Poisson parameter. That is the reason paramEsts(2) does not make sense. Here is a quote from the poissfit documentation: "lambdahat = poissfit(data) returns the maximum likelihood estimate (MLE) of the parameter of the Poisson distribution, λ, given the data data."