我有大约 20,000 行这样的数据,
Id | value
1 30
2 3
3 22
..
n 27
我对我的数据进行了统计,平均值33.85,中位数30.99,最小值2.8,最大值206,95%置信区间0.21..所以大多数值在33左右,并且有一些异常值(一点点)..所以看起来像长尾分布。
我对发行版和 python 都很陌生,我尝试过 class fitterhttps://pypi.org/project/fitter/ https://pypi.org/project/fitter/尝试了 Scipy 包中的许多发行版,loglaplace 发行版显示了最低的错误(尽管不太理解它)。
我阅读了该线程中的几乎所有问题,并得出了两种方法(1)拟合分布模型,然后在模拟中绘制随机值(2)计算不同值组的频率,但该解决方案没有值例如超过206。
我的数据是值(数字),在 python 中拟合数据分布的最佳方法是什么,因为在我的模拟中我需要绘制数字。随机数必须与我的数据具有相同的模式。此外,我需要通过绘制数据和模型曲线来验证模型是否可以很好地呈现我的数据。
一种方法是根据贝叶斯信息准则(称为 BIC)选择最佳模型。
OpenTURNS 实现了一种自动选择方法(请参阅此处的文档 http://openturns.github.io/openturns/latest/user_manual/_generated/openturns.FittingTest_BestModelBIC.html).
假设你有一个数组x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
,这里有一个简单的例子:
import openturns as ot
# Define x as a Sample object. It is a sample of size 11 and dimension 1
sample = ot.Sample([[xi] for xi in x])
# define distributions you want to test on the sample
tested_distributions = [ot.WeibullMaxFactory(), ot.NormalFactory(), ot.UniformFactory()]
# find the best distribution according to BIC and print its parameters
best_model, best_bic = ot.FittingTest.BestModelBIC(sample, tested_distributions)
print(best_model)
>>> Uniform(a = -0.769231, b = 10.7692)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)