Skip to content
Advertisement

How to perform two-sample one-tailed t-test with numpy/scipy

In R, it is possible to perform two-sample one-tailed t-test simply by using

JavaScript

In Python world, scipy provides similar function ttest_ind, but which can only do two-tailed t-tests. Closest information on the topic I found is this link, but it seems to be rather a discussion of the policy of implementing one-tailed vs two-tailed in scipy.

Therefore, my question is that does anyone know any examples or instructions on how to perform one-tailed version of the test using numpy/scipy?

Advertisement

Answer

From your mailing list link:

because the one-sided tests can be backed out from the two-sided tests. (With symmetric distributions one-sided p-value is just half of the two-sided pvalue)

It goes on to say that scipy always gives the test statistic as signed. This means that given p and t values from a two-tailed test, you would reject the null hypothesis of a greater-than test when p/2 < alpha and t > 0, and of a less-than test when p/2 < alpha and t < 0.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement