如何找到数据列表的最佳拟合分布函数?
我知道 Python 内置了许多概率函数,带有 random 模块。
我想知道,给定一个浮点数列表,是否有可能找到最适合该列表的分布方程?
我不知道 numpy 是否这样做,但这个函数可以与 Excel 的“趋势”函数进行比较(不相等,但相似)。
我该怎么做呢?
I am aware of many probabilistic functions builted-in Python, with the random
module.
I'd like to know if, given a list of floats, it would be possible to find the distribution equation that best fits the list?
I don't know if numpy does it, but this function could be compared (not equal, but similar) with the Excel's "Trend" function.
How would I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看看 numpy.polyfit
Look at numpy.polyfit
还有 curve_fit
there's also curve_fit
您可能想尝试 statsmodels.tsa 中的时间序列分析。查看下面的代码:
一个警告。我发现季节性部分不能很好地处理异质性——当你的周期函数振幅随时间增长时。它保持周期性幅度恒定(这是季节性的一部分),然后您的残差将显示周期性效应。
You may want to try the time series analysis in statsmodels.tsa. Check out the code below:
One caveat. I found the seasonal part not to handle heterostascedy well -- this si when your periodic function amplitude grows with time. It keeps the periodic amplitude constant (that is part of seasonal) and then your residual will show a periodic effect.
看看 https:/ 的文档/erdogant.github.io/distfit/pages/html/Plots.html#plot-all-fitted-distributions
通过测试多个分布函数并对最佳模型进行排名,它们正是您所需要的
Take a look at the documentation of https://erdogant.github.io/distfit/pages/html/Plots.html#plot-all-fitted-distributions
They have exactly what you need by testing multiple distribution functions and ranking the best models