How does a two-sample t-test work? Walk through a small example.
It tests whether two group means differ by more than chance would explain. The t statistic is the difference in means divided by its standard error; a large |t| gives a small p-value and evidence against equal means.
Explain it simply
You want to know if students who used a new revision app score higher than those who did not. The groups will differ a bit by luck anyway. The t-test asks: is the gap large compared with the natural noise?
t = (mean1 - mean2) / standard error of the difference
Hypotheses: H0 says the true means are equal, H1 says they are different.
Example
Test scores: app group 72, 75, 78, 80, 82 (mean 77.4); no-app group 68, 70, 72, 74, 71 (mean 71.0).
from scipy import stats
a = [72, 75, 78, 80, 82]
b = [68, 70, 72, 74, 71]
t, p = stats.ttest_ind(a, b)
print(round(t, 2), round(p, 4)) # 3.14 0.0138t = 3.14 with 8 degrees of freedom and p = 0.0138, below 0.05, so we reject H0: the data is unlikely if the two means were really equal.
If the groups may have unequal variances, use Welch's version: ttest_ind(a, b, equal_var=False). It gives the same t here, with p about 0.0189.
What to say in the interview
"A two-sample t-test compares means of two independent groups. I check independence, rough normality or a decent sample size, and use Welch's test if the variances look unequal. I report the effect size and a confidence interval along with the p-value, not only whether it is below 0.05."
Common mistakes
- Using it for the same people measured twice. That needs a paired test.