Error in Poisson's distribution.
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Roger Stafford
am 5 Sep. 2013
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 Kommentare
Roger Stafford
am 5 Sep. 2013
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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!