Error in Poisson's distribution.
조회 수: 7 (최근 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!