pythonrstatisticsscipychi-squared

Is there a python equivalent of R's qchisq function?


The R qchisq function converts a p-value and number of degrees of freedom to the corresponding chi-squared value. Is there a Python library that has an equivalent?

I've looked around in SciPy without finding anything.


Solution

  • It's scipy.stats.chi2.ppf - Percent point function (inverse of cdf). E.g., in R:

    > qchisq(0.05,5)
    [1] 1.145476
    

    in Python:

    In [8]: scipy.stats.chi2.ppf(0.05, 5)
    Out[8]: 1.1454762260617695