嗨,有一组观察结果
obs
= https://drive.google.com/file/d/0B3vXKJ_zYaCJVlhqd3FJT0xtWFk/view?usp=sharing
我想证明它们来自 Gamma 分布。
为此,我:
%estimate parameters gamma distribution
paramEsts_gamma = gamfit(obs);
% estimate cdf gamma distribution (objects)
gamma_cdf=makedist('Gamma','a',paramEsts_gamma(1),'b',paramEsts_gamma(2));
% test with kstest if data comes from a gamma distribution
[h_gamma_ks,p_gamma_ks,kstat_gamma_ks,cv_gamma_ks] = kstest(obs,'CDF',gamma_cdf)
% test with chi2gofif data comes from a gamma distribution
pd_gamma = fitdist(obs,'Gamma');
[h_gamma_chi,p_gamma_chi,st_gamma_chi] = chi2gof(obs,'CDF',pd_gamma)
我的问题是我得到了 pvalue 的 NaN p_gamma_chi
.... 我在哪里犯了错误?谢谢
这里有一些代码可以直观地检查分布
%% Plot cdf
% empirical cdf
[f_emp,x_values] = ecdf(obs);
f_gamma = gamcdf(x_values,paramEsts_gamma(1),paramEsts_gamma(2));
figure
hold on;
F = plot(x_values,f_emp);
set(F,'LineWidth',2);
G = plot(x_values,f_gamma,'r-');
set(G,'LineWidth',2);
legend([F G],...
'Empirical CDF','Gamma CDF',...
'Location','SE');