0

Is there a equivalent of pchisq R command in Python. As was said in this question, I were using chi2.ppf from scipy but I am not getting the same results as in R. For example, the following code:

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

Thaks in advance for the help.

4jano20
  • 25
  • 1
  • 5
  • 1
    in the question you cited, they are using `qchisq`, not `pchisq`, the answer by peacewang is correct. note the chisq value you are testing, is really huge – StupidWolf Sep 20 '21 at 07:05
  • @StupidWolf That's right. Thanks for pointing me out – 4jano20 Sep 20 '21 at 16:01

1 Answers1

2

You can use stats.chi2.cdf in Python:

stats.chi2.cdf(38972.27814544528,df=1)
# 1.0
Peace Wang
  • 2,399
  • 1
  • 8
  • 15