Independent samples t-test
An independent samples t-test asks one question: are the average scores of two separate groups further apart than chance alone would usually produce? It’s one of the most common tests in coursework and dissertations, and it’s easy to run in any software. It’s also easy to run on the wrong design, or to over-read the result. This lesson covers when the test fits, what to check first, and how to read and report it, using a real dataset you can reproduce.
What the test compares
You have two groups made up of different people (or animals, or schools), and one continuous outcome measured once per person. The test compares the two group means and sets them against how much the scores vary within each group.
- Null hypothesis (H₀): the two population means are equal (μ₁ = μ₂).
- Alternative hypothesis (H₁): the two population means differ (μ₁ ≠ μ₂). This is the usual two-tailed version.
Some examples: exam scores for students taught online vs in person, blood pressure for a treatment group vs a control group, or job satisfaction for full-time vs part-time staff.
Is it the right test for your design?
Most mistakes with this test come from using it on a design it doesn’t fit. Check which situation you’re in:
| Your situation | Use |
|---|---|
| Two different groups, continuous outcome | Independent samples t-test |
| The same people measured twice (before/after, two conditions) | Paired samples t-test |
| One group compared with a fixed value (e.g. a population norm) | One-sample t-test |
| Three or more groups | One-way ANOVA |
| Two groups, but the outcome is clearly non-normal or ordinal | Mann-Whitney U test |
| Two groups, categorical outcome (yes/no, pass/fail) | Chi-square or Fisher’s exact test |
Assumptions to check first
Check these before you settle on the test, not after. If one fails, you switch to a different test, so finding out afterwards means you may have already reported the wrong one.
- Independence. Each observation belongs to exactly one group, and one person’s score doesn’t influence another’s. This comes from your design, and no test can check it for you. Repeated measurements of the same person break it.
- A continuous outcome. Scores, times, amounts. A single Likert item is ordinal; treating it as continuous is a choice you need to justify.
- Approximately normal residuals. The scores within each group should be roughly bell-shaped around their group mean. This matters less as groups get larger, because the t-test is fairly robust to mild non-normality. Strong skew, especially in small groups, is the real problem.
- Similar variances (homogeneity of variance). The spread of scores should be similar in both groups. Levene’s test, or its more robust median-centred version (Brown-Forsythe), checks this. If the variances differ, use Welch’s t-test.
Student’s vs Welch’s t-test
The classic (Student’s) t-test pools the two groups’ variances into one estimate, which is only valid if they really are similar. Welch’s t-test estimates each group’s variance separately and adjusts the degrees of freedom. When variances are equal it loses almost nothing; when they aren’t, it keeps the false-positive rate where it should be. That is why many methodologists now recommend Welch’s as the default (Delacre, Lakens & Leys, 2017), and why R’s t.test() runs Welch’s unless you ask otherwise. SPSS prints both rows in one table (“equal variances assumed” and “not assumed”) next to Levene’s test, so you need to choose the row yourself.
How the t statistic is calculated
The t statistic is the difference between the means divided by its standard error, which is the amount you’d expect that difference to vary by chance:
t = (x̄₁ − x̄₂) / (sp × √(1/n₁ + 1/n₂))
where sp is the pooled standard deviation, sp² = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] / (n₁ + n₂ − 2), and the degrees of freedom are n₁ + n₂ − 2. A larger |t| means the means are further apart relative to the noise. The p-value is the probability of a |t| at least that large if the null hypothesis were true.
Cohen’s d puts the same difference in standard-deviation units: d = (x̄₁ − x̄₂) / sp. Roughly, 0.2 is conventionally called small, 0.5 medium and 0.8 large (Cohen, 1988), but what counts as meaningful depends on your field.
Worked example: vitamin C and tooth growth
We’ll use ToothGrowth, a public dataset from a 1940s nutrition experiment (Crampton, 1947) that ships with R. Sixty guinea pigs received vitamin C either as orange juice (OJ) or as plain ascorbic acid (VC), 30 animals each. The outcome, len, is the length of the cells responsible for tooth growth. The question: does mean tooth growth differ between the two supplements?
Step 1: describe the groups
| Supplement | n | Mean | SD |
|---|---|---|---|
| Ascorbic acid (VC) | 30 | 16.96 | 8.27 |
| Orange juice (OJ) | 30 | 20.66 | 6.61 |
The OJ group’s mean is 3.70 higher. The question is whether a gap that size stands out against spreads of 6.6 to 8.3 within each group.
Step 2: check the assumptions
- Independence: each animal was in one group only, so this holds by design.
- Normality: the residuals (each score minus its group mean, divided by the group SD) show no clear departure from normality: D’Agostino-Pearson test, p = .162 (Shapiro-Wilk, p = .224). With 30 per group the test is robust to mild departures anyway.
- Equal variances: Brown-Forsythe test, p = .275. The SDs differ a little (8.27 vs 6.61), but not enough to suggest unequal population variances.
- Sample size: 30 per group. Analytika requires at least 20 per group before it uses a t-test; below that it switches to the Mann-Whitney U test.
All checks pass, so Student’s independent samples t-test is appropriate. This is the order Analytika enforces: it runs the checks on your data first, and the results decide which test is used.
Step 3: run the test
This is the raw output from Analytika’s t-test template on this dataset:
Group 1 (VC): mean=16.9633, n=30, sd=8.2660 Group 2 (OJ): mean=20.6633, n=30, sd=6.6056 T-statistic: -1.9153 P-value: 0.06039 Cohen's d: -0.4945 df: 58 95% CI: [-1.0064, 0.0215] Mean difference: -3.7000 Difference CI (95%): [-7.5670, 0.1670] Rows excluded for missing values: 0 of 60
Group 1 is VC, so the difference is VC − OJ, which is why t, d and the mean difference are negative. As a check, here is R on the same data:
> t.test(len ~ supp, data = ToothGrowth, var.equal = TRUE)
Two Sample t-test
data: len by supp
t = 1.9153, df = 58, p-value = 0.06039
alternative hypothesis: true difference in means between group OJ and group VC is not equal to 0
95 percent confidence interval:
-0.1670064 7.5670064
sample estimates:
mean in group OJ mean in group VC
20.66333 16.96333Same t, degrees of freedom and p-value. The signs are flipped only because R puts OJ first (alphabetical order). Analytika’s test suite checks this case, and the Welch version, against R to four decimal places on every change.
You can also check the arithmetic by hand. The pooled SD is √[(8.266² + 6.606²) / 2] ≈ 7.48, so the standard error is 7.48 × √(2/30) ≈ 1.93, giving t = −3.70 / 1.93 ≈ −1.92 and d = −3.70 / 7.48 ≈ −0.49.
Step 4: interpret it
- p = .060 is above the conventional .05 threshold, so this test finds no evidence of a difference in mean tooth growth between the two supplements.
- That is not the same as showing there’s no difference. The 95% confidence interval for the difference runs from −7.57 to 0.17: the data fit anything from a large OJ advantage to essentially none.
- The effect size, d = −0.49 (95% CI −1.01 to 0.02), is close to what is conventionally called medium. With 30 per group, a study planned to detect d = 0.5 would have only about a 48% chance of reaching significance. About 64 per group would be needed for 80% power. A non-significant result from a study this size is weak evidence either way.
Step 5: report it in APA style
An independent samples t-test found no evidence of a difference in tooth growth between guinea pigs given ascorbic acid (M = 16.96, SD = 8.27) and those given orange juice (M = 20.66, SD = 6.61), t(58) = −1.92, p = .060, d = −0.49, 95% CI [−1.01, 0.02]. The mean difference was −3.70, 95% CI [−7.57, 0.17].
Italicise the statistical symbols, drop the leading zero for p (it can’t exceed 1), and give exact p-values rather than “p > .05”. See our APA reporting guide for other tests.
What about Welch’s version?
On the same data, Welch’s t-test gives t(55.31) = −1.92, p = .061. With equal group sizes the two versions produce the same t; only the degrees of freedom, and so the p-value, shift slightly. When group sizes and variances both differ, the two versions can disagree much more, and Welch’s is the one to trust.
A lesson about design
ToothGrowth also gave each supplement at three doses, and dose has a large effect on tooth growth. The t-test ignores dose, so all of that variation ends up in the within-group spread and hides the supplement difference. A two-way ANOVA that includes dose finds a clear supplement effect, F(1, 54) = 15.57, p < .001, and an interaction showing that the size of the OJ advantage depends on dose, F(2, 54) = 4.11, p = .022. The t-test above wasn’t miscalculated. It just answered a cruder question than the design allowed. If your study has another factor that affects the outcome, include it in the model.
Common mistakes
- Using it on paired data. Before/after scores from the same people need a paired t-test. Treating them as independent usually throws away power.
- Running several t-tests instead of one ANOVA. Three groups means three pairwise t-tests and an inflated false-positive rate. Use ANOVA with post-hoc tests.
- Writing “no difference” for p > .05. Write “no evidence of a difference” and report the confidence interval.
- Reporting only the p-value. Most rubrics and journals now expect an effect size and a confidence interval as well.
- Checking assumptions after choosing the test. If the checks would have changed the test, the analysis has to be redone.
- Claiming cause and effect from observational groups. A difference between, say, smokers and non-smokers is an association. Only random assignment to groups supports causal language.
How to run it
- SPSS: Analyze → Compare Means → Independent-Samples T Test. Put the outcome under Test Variable and the group under Grouping Variable, then define the two group codes.
- R:
t.test(outcome ~ group, data = df, var.equal = TRUE)for Student’s, or leave outvar.equalfor Welch’s. - Python:
scipy.stats.ttest_ind(a, b)for Student’s, or addequal_var=Falsefor Welch’s. - Analytika: upload your file and ask, for example, “Does tooth length differ by supplement?” It runs the assumption checks, picks Student’s, Welch’s or Mann-Whitney based on them, and drafts the APA write-up.
- Summary numbers only? Our free t-test calculator works from means, SDs and group sizes.
Frequently asked questions
Can the two groups be different sizes?
Yes. Unequal group sizes are fine, but they make the test more sensitive to unequal variances. That’s exactly the situation where Welch’s t-test matters most.
What if my data aren’t normal?
With mild non-normality and reasonably sized groups, the t-test usually holds up. With strong skew, small groups, or an ordinal outcome, use the Mann-Whitney U test, which compares ranks rather than means.
Is it the same as a two-sample t-test?
Yes. “Independent samples”, “two-sample” and “between-subjects” t-test all refer to the same test.
One-tailed or two-tailed?
Two-tailed unless you stated a directional prediction before seeing the data and a difference in the other direction would truly mean nothing to you. Switching to one-tailed after the fact to get p under .05 is a well-known red flag for reviewers.
References
- Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum.
- Crampton, E. W. (1947). The growth of the odontoblasts of the incisor tooth as a criterion of the vitamin C intake of the guinea pig. The Journal of Nutrition, 33(5), 491–504.
- Delacre, M., Lakens, D., & Leys, C. (2017). Why psychologists should by default use Welch’s t-test instead of Student’s t-test. International Review of Social Psychology, 30(1), 92–101.
- Student. (1908). The probable error of a mean. Biometrika, 6(1), 1–25.
- Welch, B. L. (1947). The generalization of “Student’s” problem when several different population variances are involved. Biometrika, 34(1–2), 28–35.
More in Comparing groups
Try it with the free tools
T-Test Calculator
Independent, paired, and one-sample t-tests with exact p-values, confidence intervals, effect size, and APA output.
Effect Size Calculator
Cohen's d, Hedges' g, eta squared, and conversions between effect size metrics — with the interpretation benchmarks.
Sample Size Calculator
How many participants do you actually need? Four calculators covering surveys, group comparisons, proportions, and correlations.
Run this on your own data
Upload a dataset and ask your question in plain English. Analytika checks the assumptions, picks the test, runs it, and writes the results up in APA format.