P-value from Chi sq test statistic in Python

后端 未结 7 1746
借酒劲吻你
借酒劲吻你 2020-12-24 01:36

I have computed a test statistic that is distributed as a chi square with 1 degree of freedom, and want to find out what P-value this corresponds to using python.

I

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-24 01:47

    For ultra-high precision, when scipy's chi2.sf() isn't enough, bring out the big guns:

    >>> import numpy as np
    >>> from rpy2.robjects import r
    >>> np.exp(np.longdouble(r.pchisq(19000, 2, lower_tail=False, log_p=True)[0]))
    1.5937563168532229629e-4126
    

提交回复
热议问题