【问题标题】:Testing equivalents to R pchisq in Python在 Python 中测试 R pchisq 的等价物
【发布时间】:2021-11-13 20:26:10
【问题描述】:

Python 中是否有等效的 pchisq R 命令。正如in this question 所说,我使用的是 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

提前谢谢您的帮助。

【问题讨论】:

  • 在您引用的问题中,他们使用的是qchisq,而不是pchisq,peacewang 的回答是正确的。注意你正在测试的 chisq 值,真的很大
  • @StupidWolf 没错。谢谢你指出我

标签: python r chi-squared


【解决方案1】:

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

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

【讨论】:

猜你喜欢
  • 2017-11-27
  • 1970-01-01
  • 1970-01-01
  • 2020-09-14
  • 2018-07-18
  • 2016-06-14
  • 2016-05-23
  • 1970-01-01
  • 2022-10-13
相关资源
最近更新 更多