Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F test with python, finding the critical value

Tags:

python

Using python, Is it possible to calculate the critical value on F distribution with x and y degrees of freedom? In other words, I need to calculate the critical value given a x degrees of freedom and a confidence level 5%, but i do not see the table from statistical books, is it posible to get it with any function from python?

For example, I want to find the critical value for a F distribution with 3 an 39 degrees of freedom for 5% of confidence level. The answer should be: 2.85

like image 329
Marie Avatar asked Oct 02 '16 03:10

Marie


1 Answers

IIUC, you can use scipy.stats.f.ppf, which gives the inverse of the cdf:

>>> import scipy.stats
>>> scipy.stats.f.ppf(q=1-0.05, dfn=3, dfd=39)
2.8450678052793514
>>> crit = _
>>> scipy.stats.f.cdf(crit, dfn=3, dfd=39)
0.95000000000000007
like image 87
DSM Avatar answered Sep 28 '22 09:09

DSM