calculate goodness of fit matlab

2020-04-23 08:28发布

问题:

I have a set of observations obs.

If I plot the histogram of the observation I see that they could come from a gamma distribution

[counts,x] = hist(obs,[1:max(obs)]);

I would like to prove it using chi square goodness of fit.

So I first estimate the gamma parameters

paramEsts = fitdist(obs,'Gamma');  

and the use chi2gof to see if the hypotesis is true (h=0).

[h,p] = chi2gof(obs,'CDF',paramEsts)

My problem is that I get a p = NaN...how is it possible? Where is my mistake? Thanks

to test it please download the obs.mat file https://drive.google.com/file/d/0B3vXKJ_zYaCJbHU2SHhac29MRms/view?usp=sharing