python - python 中 Weibull 分布的拟合优度检验

标签 python scipy statistics weibull openturns

我有一些数据需要测试以查看它是否来自 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/

相关文章:

python - cx_Freeze : "No module named ' codecs'"

python - 在不使用 NumPy 的情况下用 Python 求解线性系统

algorithm - 根据一些外部值生成分布

javascript - 如何在 BigQuery 中运行配对 t 检验。有可用的 UDF 吗?

Python Selenium,单击复选框

python - 在 Pandas 中应用groupby后如何计算列的正数和负数

Python最近邻——坐标

python - 如何为战舰中的舰船生成统计上可能的位置

python - 在 Python 中使用 Gspread 共享给多个用户

python - 使用 scipy、matplotlib 将数据拟合到多峰分布