我有一些数据需要测试以查看它是否来自 Weibull distribution参数未知。在 R我可以使用 https://cran.r-project.org/web/packages/KScorrect/index.html但我在 Python 中找不到任何东西。
使用 scipy.stats 我可以拟合参数:
scipy.stats.weibull_min.fit(values)
然而,为了将其转化为测试,我认为我需要执行一些蒙特卡洛模拟(例如 https://en.m.wikipedia.org/wiki/Lilliefors_test),我不确定具体要做什么。
如何在 Python 中进行这样的测试?
最佳答案
Lilliefors 测试在 OpenTURNS 中实现.为此,您只需使用与您想要适合的分布相对应的工厂。 在下面的脚本中,我模拟了一个大小为 10 的 Weibull 样本,并使用等于 1000 的样本大小执行 Kolmogorov-Smirnov 检验。这意味着 KS 统计量被模拟了 1000 次。
import openturns as ot
sample=ot.WeibullMin().getSample(10)
ot.ResourceMap.SetAsUnsignedInteger("FittingTest-KolmogorovSamplingSize",1000)
distributionFactory = ot.WeibullMinFactory()
dist, result = ot.FittingTest.Kolmogorov(sample, distributionFactory, 0.01)
print('Conclusion=', result.getBinaryQualityMeasure())
print('P-value=', result.getPValue())
可以在以下位置找到更多详细信息:
关于python - python 中 Weibull 分布的拟合优度检验,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57354430/