在 Python 中测试 R pchisq 的等价物
Testing equivalents to R pchisq in Python
Python 中是否有与 pchisq R 命令等效的命令?正如中所说
问题 ,我使用的是 scipy 中的 chi2.ppf,但我没有得到与 R 中相同的结果。例如,以下代码:
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
谢谢大家的帮助。
您可以在 Python 中使用 stats.chi2.cdf
:
stats.chi2.cdf(38972.27814544528,df=1)
# 1.0
Python 中是否有与 pchisq R 命令等效的命令?正如中所说 问题 ,我使用的是 scipy 中的 chi2.ppf,但我没有得到与 R 中相同的结果。例如,以下代码:
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
谢谢大家的帮助。
您可以在 Python 中使用 stats.chi2.cdf
:
stats.chi2.cdf(38972.27814544528,df=1)
# 1.0