问题描述
我正在尝试将负二项分布拟合到只有一个字段且该字段是句子中的单词数的数据集。如何使用 statsmodels.discrete.discrete_mode 拟合分布
解决方法
我认为 statsmodels 类只是作为回归模型的后端资产,而不是用于拟合分布。请参阅此处的参考:Regression with Discrete Dependent Variable
但是在 other question here 的答案中,有一个链接,其中包含一个可能的解决方法来利用 statsmodels 回归模型来拟合您的分布:Newbie question about discrete distributions and MLE
我也为您查看了 scipy.stats.nbinom,因为 scipy 具有适用于各种分布的 MLE 拟合方法。但是离散分布没有拟合方法。 这里有很多答案解释了其中的困难,以及一些替代方法:
- In scipy.stats rv_continuous has a fit method to find MLEs,but rv_discrete does not. Why?
- Fitting negative binomial in python
- Fitting For Discrete Data: Negative Binomial,Poisson,Geometric Distribution
作为除上述答案中提到的方法之外的另一种可能性,我建议您使用 PyMC3 package 查看贝叶斯数值方法,因为它也包括 Negative Binomial 分布。