Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 974
jveldridge Avatar asked Aug 06 '13 01:08

jveldridge


1 Answers

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
like image 149
Vadim Khotilovich Avatar answered Sep 22 '22 01:09

Vadim Khotilovich