Error in Poisson's distribution.

1 回表示 (過去 30 日間)
harley
harley 2013 年 9 月 5 日
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));

採用された回答

Roger Stafford
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 件のコメント
harley
harley 2013 年 9 月 5 日
thanks Roger, any suggestions on how i should correctly write it.
Roger Stafford
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!

Translated by