Error in Poisson's distribution.
3 次查看(过去 30 天)
显示 更早的评论
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));
0 个评论
采纳的回答
Roger Stafford
2013-9-5
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."
2 个评论
Roger Stafford
2013-9-5
I'm not sure what you expect. What is wrong with writing just this:
paramEsts = poissfit(Data);
pdfEst = poisspdf(xgrid,paramEsts);
I see no evidence in your stuff for a second parameter value for 'poisspdf'. In any case, the second argument of 'poisspdf' will either have to be a scalar or else a vector the same size as 'xgrid' to satisfy 'poisspdf' requirements.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!