Python 中带有 mu 和 alpha 的负二项式的 CDF

问题描述 投票:0回答:1

我有一些计数数据有点类似于泊松分布,但过于分散。我使用 statsmodels 在 python 中安装了一个负二项式 glm 模型,并选择了 alpha 值(即色散参数)。然后我将该模型应用于测试集以做出一些预测。我现在想要计算累积分布函数,以便我可以计算随机变量 X<=9 given my outputted prediction mu (i.e.7.8) and pre-determined value for alpha (i.e. 0.2).

scipy文档(https://docs.scipy.org/doc/scipy/reference/ generated/scipy.stats.nbinom.html)建议我可以用nbinom.cdf(k, n, p) 但是当我只有 mu 和 alpha 时,我如何获得 n 和 p 的值?

python scipy statsmodels glm binomial-cdf
1个回答
1
投票

p 和 n 与 alpha 和 mu 相关,您提供的文档中给出了关系:

sigma_squared = mu + alpha * mu**2
p = mu / sigma_squared
n = mu**2 / (sigma_squared - mu)
© www.soinside.com 2019 - 2024. All rights reserved.