[ACCEPTED]-Finding Two-Tailed P Value from t-distribution and Degrees of Freedom in Python-p-value

Accepted answer
Score: 14

Yes, n-1 is the degrees of freedom in that 11 example.

Given a t-value and a degrees of 10 freedom, you can use the "survival 9 function" sf of scipy.stats.t (aka the complementary 8 CDF) to compute the one-sided p-value. The 7 first argument is the T value, and the second 6 is the degrees of freedom.

For example, the 5 first entry of the table on this page says that for 1 degree of 4 freedom, the critical T value for p=0.1 3 is 3.078. Here's how you can verify that 2 with t.sf:

In [7]: from scipy.stats import t

In [8]: t.sf(3.078, 1)
Out[8]: 0.09999038172554342   # Approximately 0.1, as expected.

For the two-sided p-value, just double 1 the one-sided p-value.

More Related questions