我正在尝试拟合分布。配件已完成,但我需要测量,以选择最佳型号。许多论文都使用 Kolomogorov-Smirnov (KS) 测试。我试图实现这一点,但我得到的 p 值结果非常低。
实施:
#Histigram plot
binwidth = np.arange(0,int(out_threshold1),1)
n1, bins1, patches = plt.hist(h1, bins=binwidth, normed=1, facecolor='#023d6b', alpha=0.5, histtype='bar')
#Fitting
gevfit4 = gev.fit(h1)
pdf_gev4 = gev.pdf(lnspc, *gevfit4)
plt.plot(lnspc, pdf_gev4, label="GEV")
logfit4 = stats.lognorm.fit(h)
pdf_lognorm4 = stats.lognorm.pdf(lnspc, *logfit4)
plt.plot(lnspc, pdf_lognorm4, label="LogNormal")
weibfit4 = stats.weibull_min.fit(h1)
pdf_weib4 = stats.weibull_min.pdf(lnspc, *weibfit4)
plt.plot(lnspc, pdf_weib4, label="Weibull")
burr12fit4 = stats.burr12.fit(h1)
pdf_burr124 = stats.burr12.pdf(lnspc, *burr12fit4)
plt.plot(lnspc, pdf_burr124, label="Burr")
genparetofit4 = stats.genpareto.fit(h1)
pdf_genpareto4 = stats.genpareto.pdf(lnspc, *genparetofit4)
plt.plot(lnspc, pdf_genpareto4, label ="Gen-Pareto")
#KS-Test
print(stats.kstest(h1, lambda k : stats.genpareto.cdf(k, *genparetofit),args=(),N=len(h1),alternative ='two-sided', mode ='approx'))
print(stats.kstest(h1, lambda k : stats.lognorm.cdf(k, *logfit),args=(),N=len(h1),alternative ='two-sided', mode ='approx'))
print(stats.kstest(h1, lambda k : gev.cdf(k, *gevfit),args=(),N=len(h1),alternative ='two-sided', mode ='approx'))
print(stats.kstest(h1, lambda k : stats.weibull_min.cdf(k, *weibfit),args=(),N=len(h1),alternative ='two-sided', mode ='approx'))
print(stats.kstest(h1, lambda k : stats.burr12.cdf(k, *burr12fit),args=(),N=len(h1),alternative ='two-sided', mode ='approx'))
运行后,我得到如下值:
KstestResult(statistic=0.065689774346523788, pvalue=2.3778862070128568e-20)
KstestResult(statistic=0.063434691987405312, pvalue=5.2567851875784095e-19)
KstestResult(statistic=0.065047355887551062, pvalue=5.8076254324909468e-20)
KstestResult(statistic=0.25249534411299968, pvalue=8.3670183092211739e-295)
KstestResult(statistic=0.068528435880779559, pvalue=4.1395594967775799e-22)
这些值是否合理?仍然可以选择最好的模型吗?最佳拟合模型是统计值最小的模型吗?
编辑:
它们看起来非常合身。但我仍然得到那些小的 p 值。