首页 > 解决方案 > 在 Python 中测试 R pchisq 的等价物

问题描述

Python中是否有等效的pchisq R命令。正如在这个问题中所说,我使用的是 scipy 中的 chi2.ppf,但我没有得到与 R 中相同的结果。例如,以下代码:

回复:

pchisq(38972.27814544528, df = 1)
Out: 1

pchisq(40569.99000034796, df = 1)
Out: 1

Python:

chi2.ppf(38972.27814544528, df = 1)
Out: NaN

chi2.ppf(40569.99000034796, df = 1)
Out: NaN

提前谢谢您的帮助。

标签: pythonrchi-squared

解决方案


您可以stats.chi2.cdf在 Python 中使用:

stats.chi2.cdf(38972.27814544528,df=1)
# 1.0

推荐阅读