The formula for independent samples t test compares two unrelated groups by dividing the difference between their means by the standard error of that difference: t = (x̄1 − x̄2) / SE. With pooled variances, the standard error is sp × √(1/n1 + 1/n2) and the degrees of freedom are n1 + n2 − 2. Welch's version uses √(s1²/n1 + s2²/n2) with a longer degrees of freedom formula, and it is the safer choice when the groups differ in spread or size.
An independent samples t test, also called an unpaired or two-sample t test, asks whether the population means of two separate groups differ. Typical cases are a treatment group against a control group, or two production lines against each other. The t value tells you how many standard errors apart the two sample means are.
This guide gives you both formulas in a form you can copy and defines every symbol. It works one example by hand with groups of 10 and 12, then shows how to read and report the result. It also covers the mistakes that most often break the calculation and how to check your arithmetic in Excel, Python, and PlotStudio AI, which runs the test for you and shows the code behind it.
Why the independent samples t test formula matters
The formula matters because it turns a raw gap between two group averages into one number you can judge against chance. Without it, you would be guessing whether a difference of 6 points is large or trivial.
What the formula tells you
Two samples almost never have identical means, even when both come from the same population. The formula handles this by dividing the observed difference between the means (the signal) by the standard error of that difference (the noise). The result counts how many standard errors separate the two means. A t of 0 means the means are identical, and for groups of around 20 or more, an absolute t above roughly 2 usually crosses the 5% significance line.

Raw differences mislead because they ignore spread and sample size. A 6-point gap is meaningful when scores vary by about 3 points, and it is easily noise when scores vary by 30. The standard error in the denominator absorbs both the variability inside each group and the number of observations, which is why you cannot judge a difference by looking at the means alone.
The t statistic is the gap between two means measured in standard errors, so a bigger gap or a quieter dataset gives a bigger t.
When to use it and when to pick another test
Use this test when you have two separate groups and one numeric outcome, and you want to compare the group means. Each subject must appear in only one group. If the same people are measured twice, the data are paired, and the independent formula would give the wrong standard error.
| Situation | Test to use |
|---|---|
| Two unrelated groups, numeric outcome | Independent samples t test |
| Same subjects measured twice, or matched pairs | Paired t test: t = d̄ / (sd / √n), df = n − 1 |
| One group compared with a known value | One-sample t test |
| Three or more groups | One-way ANOVA |
| Ordinal outcome, or small and strongly skewed samples | Mann-Whitney U test |
Four assumptions sit behind the formula. Observations must be independent within and between groups, the outcome must be numeric, and it should be roughly normal within each group. Extreme outliers should also be absent. Moderate departures from normality matter little in moderate or large samples. Equal variances are required only for the pooled version, which is the main reason Welch's formula exists.
The two formulas and what every symbol means
Both versions of the independent samples t-test formula share one numerator, the difference between the sample means. They differ only in how they estimate the standard error and the degrees of freedom. Here are both, ready to copy.
Pooled variance formula (Student's t test)
The pooled version assumes both populations have the same variance. It blends the two sample variances into one estimate, weighting each by its degrees of freedom.
t = (x̄1 − x̄2) / ( sp × √(1/n1 + 1/n2) )
sp = √( ((n1 − 1) × s1² + (n2 − 1) × s2²) / (n1 + n2 − 2) )
df = n1 + n2 − 2
Because of the weighting, the larger group has more influence on pooled standard deviation (sp). The degrees of freedom are the total sample size minus 2, one lost for each group mean you estimated. You then compare t to a t distribution with that many degrees of freedom.
Welch's formula for unequal variances
Welch's version skips the pooling. It adds each group's variance of the mean separately, so it makes no claim that the population variances match.
t = (x̄1 − x̄2) / √( s1²/n1 + s2²/n2 )
df = (s1²/n1 + s2²/n2)² / ( (s1²/n1)²/(n1 − 1) + (s2²/n2)²/(n2 − 1) )
The Welch degrees of freedom are rarely a whole number, and that is expected. The value always falls between the smaller group's n − 1 and n1 + n2 − 2. When the two groups have equal sizes, the t statistic is identical to the pooled one, and only the degrees of freedom change.
Symbols and equivalent forms
Every symbol in the two formulas comes from six summary numbers, three per group.
| Symbol | Meaning |
|---|---|
| x̄1, x̄2 | Sample mean of group 1 and group 2 |
| s1², s2² | Sample variance of each group (the SD squared) |
| n1, n2 | Number of observations in each group |
| sp | Pooled standard deviation |
| SE | Standard error of the difference between means |
| df | Degrees of freedom used to find the p-value |
Textbooks print the same pooled formula in several ways, and they all agree. Some replace (n − 1) × s² with the sum of squares, SS = Σ(x − x̄)², which gives sp² = (SS1 + SS2) / (n1 + n2 − 2). Others write the right-hand factor as √((n1 + n2) / (n1 × n2)), which equals √(1/n1 + 1/n2). The algebra differs, but the result does not.
Which version to use
Default to Welch's t test. It performs about as well as the pooled test when variances are equal and much better when they are not, especially with unequal group sizes. Use the pooled formula when you have a sound design-based reason to expect equal variances, or when a protocol, a teaching exercise, or a reviewer asks for Student's version.
When in doubt, report Welch's t test, because it costs almost nothing when variances are equal and protects you when they are not.
Avoid the habit of running a variance test first and choosing the formula from its p-value. A non-significant result does not prove the variances are equal, and the two-step routine adds its own error. Look at the standard deviations and group sizes, then decide.
How to calculate the t statistic step by step
To calculate t, you need the mean, variance, and sample size of each group, then a fixed sequence of arithmetic. The example below keeps the numbers small so that you can follow every step with a calculator.
The example data
A lecturer compares exam scores for students taught with a new method (group 1) and the standard method (group 2). The null hypothesis is that the population means are equal, the test is two-sided, and the significance level is 0.05.

| Group | n | Mean | SD | Variance |
|---|---|---|---|---|
| New method | 10 | 78 | 8 | 64 |
| Standard method | 12 | 72 | 10 | 100 |
The sample SDs differ, but not dramatically, and the group sizes are close. That makes this a case where both versions should land in similar territory. You will see in a moment that they do.
Pooled calculation in six steps
Work through the steps in order and keep at least three decimals until the end.
- Find the difference in means: 78 − 72 = 6.
- Weight each variance: (10 − 1) × 64 = 576 and (12 − 1) × 100 = 1,100. Their sum is 1,676.
- Find the degrees of freedom: 10 + 12 − 2 = 20.
- Find the pooled standard deviation: 1,676 / 20 = 83.8 is the pooled variance, and √83.8 ≈ 9.154.
- Find the standard error: 9.154 × √(1/10 + 1/12) = 9.154 × 0.4282 ≈ 3.920.
- Divide: t = 6 / 3.920 ≈ 1.53.
The group means sit about 1.5 standard errors apart. Whether that is enough to call the difference real is a question for the next section.
Check it against Welch's formula
Welch's route gives a similar answer. The variance of each mean is 64/10 = 6.4 and 100/12 = 8.333, which add to 14.733, so SE = √14.733 ≈ 3.838. The degrees of freedom are 14.733² / (6.4²/9 + 8.333²/11) = 217.07 / 10.864 ≈ 19.98.
| Version | SE | t | df | Two-sided p |
|---|---|---|---|---|
| Pooled (Student) | 3.920 | 1.53 | 20 | about 0.14 |
| Welch | 3.838 | 1.56 | 19.98 | about 0.13 |
If your pooled and Welch results disagree sharply, the variances or group sizes are far apart, and Welch is the one to trust.
How to read and report the t test result
You judge the result by comparing t with a critical value, or by reading its p-value, then you support it with a confidence interval and an effect size. A t value alone says little about whether the difference matters.
Compare t to the critical value
The critical value is the t that cuts off 5% of the distribution, split across both tails for a two-sided test. It shrinks as the degrees of freedom grow.

| df | Critical t (two-sided, α = 0.05) |
|---|---|
| 10 | 2.228 |
| 20 | 2.086 |
| 30 | 2.042 |
| 60 | 2.000 |
| Very large | 1.960 |
In the example, |t| = 1.53 is below 2.086, so you fail to reject the null hypothesis. The two-sided p-value of about 0.14 says the same thing: a gap this large would appear roughly 14% of the time by sampling luck alone if the true means were equal. The sign of t only tells you which group had the higher mean. A one-sided test at df = 20 uses 1.725 instead, but you may choose that only when the direction was set before seeing the data.
Add a confidence interval and effect size
The confidence interval for the difference is (x̄1 − x̄2) ± t* × SE, where t* is the critical value for your df. Here that is 6 ± 2.086 × 3.920, or −2.18 to 14.18. The interval includes zero, which matches the non-significant test. It also shows that the data are compatible with a negative gap and with a gap of 14 points.
Cohen's d expresses the gap in standard deviation units: d = (x̄1 − x̄2) / sp = 6 / 9.154 ≈ 0.66, a medium-sized difference. That combination, a medium effect with a non-significant p, is the classic sign of a study too small to separate a real effect from noise. It does not show that the teaching methods perform the same.
Write it up in APA style
State the test, the means and SDs, t with its degrees of freedom, the p-value, the interval, and the effect size. Here is a fill-in template and the completed example.
An independent samples t test compared [outcome] between [group 1]
(M = [mean], SD = [sd], n = [n]) and [group 2] (M = [mean], SD = [sd],
n = [n]). t([df]) = [t], p = [exact p], 95% CI [[lower], [upper]],
d = [Cohen's d].
An independent samples t test compared exam scores between the new
method group (M = 78.0, SD = 8.0, n = 10) and the standard method group
(M = 72.0, SD = 10.0, n = 12). t(20) = 1.53, p = .14,
95% CI [−2.18, 14.18], d = 0.66.
If you used Welch's test, report its fractional degrees of freedom, for example t(19.98) = 1.56, and say that you used Welch's test.
Common mistakes when applying the formula
Most wrong answers come from a handful of predictable slips, some in the arithmetic and some in the design. Check yourself against both lists before you trust a result.
Arithmetic slips
These are the errors that show up most when people calculate t by hand.
- Plugging in SD where variance belongs. The pooled formula multiplies (n − 1) by the variance, so square the standard deviation first.
- Using n instead of n − 1 in the weights, which understates the pooled variance.
- Using the wrong degrees of freedom. Pooled df is n1 + n2 − 2. It is not n − 1, and it is not the Welch value.
- Forgetting the final square root in the standard error.
- Rounding too early. Keep three or four decimals until the last step, or t can drift in the second decimal.
Design and interpretation errors
The bigger risks sit outside the arithmetic. Paired data treated as independent is the most common, such as before and after measurements on the same people. The independent formula ignores the link between pairs and usually loses power.
Running several t tests across three or more groups is another trap. Three groups mean three pairwise comparisons, and the chance of at least one false positive rises from 5% to about 14%. Use one-way ANOVA with a suitable follow-up instead. Finally, do not read a small p-value as a large effect. With big samples, a trivial gap can be significant, so always report d and the interval.
A t test is only as good as the design behind it, so confirm that your groups are truly independent before you touch the formula.
How to run the formula in software
Software calculates t, df, and p in one step, but you should know which version it runs by default. Reproducing the worked example is a quick way to confirm that your tool does what you expect.
Excel and Python checks
Excel's T.TEST function takes four arguments: two ranges, the number of tails (1 or 2), and the type. Type 2 is the pooled test and type 3 is Welch's. It returns only the p-value, so use the Data Analysis ToolPak (t-Test: Two-Sample Assuming Equal Variances) if you also need the t statistic.
| Tool | Pooled (equal variances) | Welch (unequal variances) |
|---|---|---|
| Excel | =T.TEST(A2:A11, B2:B13, 2, 2) |
=T.TEST(A2:A11, B2:B13, 2, 3) |
| R | t.test(score ~ group, data = d, var.equal = TRUE) |
t.test(score ~ group, data = d) |
| Python (SciPy) | stats.ttest_ind(a, b, equal_var=True) |
stats.ttest_ind(a, b, equal_var=False) |
Note that R defaults to Welch, while SciPy defaults to the pooled test. To reproduce the example from summary statistics, SciPy can work without raw data:
from scipy import stats
# pooled: t about 1.53, p about 0.14
print(stats.ttest_ind_from_stats(78, 8, 10, 72, 10, 12, equal_var=True))
# Welch: t about 1.56, p about 0.13
print(stats.ttest_ind_from_stats(78, 8, 10, 72, 10, 12, equal_var=False))
Running the test in PlotStudio AI
If you would rather not assemble the pieces yourself, PlotStudio AI runs the independent samples t test from a plain-English question. You upload a dataset and ask it to compare an outcome between two groups. Its agents profile the data, choose a method, write and run the Python, and return the t statistic, degrees of freedom, p-value, tables, charts, and an interpretation on a permanent analysis page.
You stay in control of the method. In Verification Mode you review the plan, edit it, and approve the statistical method and assumptions before anything runs, for example by asking for Welch's test or a Mann-Whitney U test. You can inspect the generated code and compare its output with your hand calculation, then export a PDF report or a Jupyter notebook. Analysis runs on your machine, and the free trial includes 30 credits with no credit card. The tool speeds up the work, but checking that the groups are independent and the assumptions are reasonable remains your job.
Treat software output as a second check on your formula work, not a replacement for understanding it.
Turning the formula into a result
The independent samples t test formula is one idea: the gap between two means divided by its standard error. Use the pooled version when you can justify equal variances, and Welch's version otherwise. Then compare t with the critical value for your degrees of freedom.
Your result is not finished at the p-value. Add the confidence interval and Cohen's d, report the means and SDs of both groups, and confirm that the design really has two independent groups. Done in that order, the calculation is short and the conclusion is defensible.
When you want to skip the manual arithmetic and keep the methodology visible, you can try PlotStudio AI free on your own dataset and check its output against the formulas above.
