How to interpret results of two-sample, one-tailed t-test in Scipy

I want to perform a two-sample, one-tailed t-test to compare two means. For the specific problem I am looking, I want the comparison to only be in one direction. I would like the null hypothesis to be that mu_2 > mu_1 and the alternative hypothesis to be mu_1 <= mu_2. Or should the null hypothesis still be that mu_1 - mu_2 = 0, even for the one-tailed case?

I am working with a large dataset, but if I were to extract and round the parameters, for data_1 it is mu_1 = 4.3, s_1 = 4.8, and n_1 = 40000 and data_2 it is mu_2 = 4.9, s_2 = 4.4, n_2 = 30000. I am using scipy to perform a two-sample t-test:

stats.ttest_ind(data1,
data2,
equal_var = False)


Given that scipy only takes into account a two-tail test, I am not sure how to interpret the values. Ttest_indResult(statistic=-19.51646312898464, pvalue=1.3452106729078845e-84). The alpha value is 0.05, and the p-value is much much smaller than that which would mean the null hypothesis is rejected. However, my intuition tells me that the null hypothesis should not be rejected, because mu_2 is clearly larger than mu_1 (at the very minimum I would expect the p-value to be larger). Therefore, I feel like I'm either interpreting the results incorrectly or need to additional calculations to get the correct answer.

I would appreciate any additional help and guidance. Thanks!

python scipy statistics inference t-test

• I think you’ve made a typo in your post. You’re observing a lower sample mean in group 1 than in group 2. That shouldn’t be evidence that the population mean of group 1 is greater than the population mean of group 2.
– Dave
Apr 23, 2020 at 5:55
• I agree with your statement mu_1 is less than mu_2 (on the flip side, I made the null hypothesis mu_2 > mu_1), and that shouldn't yield that the the population mean of group 1 is greater than the population mean of group 2. But not sure about the typo you're referring to? I don't understand why do I obtain a p-value that supports the alternate hypothesis. Since t's one-sided do I have do another step on top (such as 1 -p-value or something)? Apr 23, 2020 at 6:14
• You can have a directional null, but it should include equality. If you want to include equality in your alternative it hints that you should be looking at something else instead (such as a noninferiority test perhaps, though there are other possibilities) Apr 23, 2020 at 6:27
• You obtain a p-value that supports the alternative hypothesis because your results are very unlikely if the null hypothesis is true.
– Dave
Apr 23, 2020 at 14:05

If, however, you want to test a one-sided hypothesis, but what you observe is in the opposite direction (e.g. testing $$H_a: \mu_1>\mu_2$$ but observing $$\bar{x}_1<\bar{x}_2$$), your p-value is going to exceed $$0.50$$. Running the hypothesis test in that case is unnecessary; you know you won’t be able to reject.