chi2inv in Python

Viewed 6895

What is the corresponding function for calculating the inverse chi squared distribution in python? In MATLAB, for example, a 95% confidence interval with n degrees of freedom is given by

chi2inv(0.95, n)
2 Answers
from scipy.stats.distributions import chi2
chi2.ppf(0.975, df=2)

7.377758908227871

octave:4> chi2inv(0.975,2)
ans =  7.3778

Additional information to the current answer:

chi2.ppf and chi2.cdf are inverse of each-other:

from scipy.stats.distributions import chi2
chi2.ppf(0.95, df=5)     # 11.07
chi2.cdf(11.07, df=5)    # 0.95
Related