# Independent t-Test Calculator

> Free independent t-test calculator. Enter the mean, SD and size of two groups and get the Welch or Student t test, the mean difference with 95% CI, Cohen's d and R code.

Canonical: https://biostatkit.com/t-test

The independent t test compares the means of a measured outcome in two separate groups. It divides the difference in means by its standard error: t = (m1 - m2) / SE, then reads a P value from the t distribution. The Welch version does not assume equal SDs and is the usual default.

Enter the mean, standard deviation and size of two independent groups and get the difference in means with its 95% confidence interval, the t statistic, degrees of freedom and P value (Welch or Student), Cohen's d, a sentence for your manuscript and the R code.

## How the independent t test works

### What it is

The independent (two-sample) t test asks whether the means of a measured outcome differ between two separate groups by more than chance would explain. It divides the difference in means by its standard error. The Welch version lets the two groups have different standard deviations; the Student version assumes they are equal.

### How this page computes it

Welch: SE = sqrt(s1²/n1 + s2²/n2), t = (m1 - m2) / SE, with the Welch-Satterthwaite degrees of freedom df = (s1²/n1 + s2²/n2)² / [ (s1²/n1)²/(n1 - 1) + (s2²/n2)²/(n2 - 1) ].

Student: pooled SD sp = sqrt{ [(n1 - 1)s1² + (n2 - 1)s2²] / (n1 + n2 - 2) }, SE = sp sqrt(1/n1 + 1/n2), df = n1 + n2 - 2.

The 95% CI of the difference is (m1 - m2) ± t0.975, df x SE, and the P value is two-sided. Cohen's d is the difference divided by the pooled SD.

### Assumptions

- Two independent groups: different people in each group. For before-and-after values in the same people use a paired t test.
- The outcome is a measurement, and its mean is a fair summary. With small groups the values should be roughly normal; with larger groups (about 30 or more each) the t test is robust to moderate skew.
- For the Student version, similar standard deviations in the two groups.

### Common mistakes

- Entering the standard error of the mean instead of the SD. SE = SD / sqrt(n), so the SD is much larger.
- Using a t test on very skewed data such as length of stay with small groups. Use a rank test or a transformation.
- Testing the equality of variances first and then choosing the test. Using Welch from the start is simpler and safe (Delacre et al, 2017).
- Reporting P alone. Give the difference in means and its 95% CI.

## Worked example

Systolic blood pressure: group 1 mean 132.5 mmHg (SD 15.2, n = 40), group 2 mean 125.1 mmHg (SD 14.8, n = 42).

difference = 132.5 - 125.1 = 7.40 mmHg; Welch SE = sqrt(15.2²/40 + 14.8²/42) = 3.315.

t = 7.40 / 3.315 = 2.23 on 79.5 degrees of freedom, P = .028; 95% CI 7.40 ± 1.990 x 3.315 = 0.80 to 14.00 mmHg. Cohen's d = 7.40 / 15.00 = 0.49.

### How to read the result

Mean blood pressure was 7.4 mmHg higher in group 1. The data are compatible with a true difference anywhere from about 1 to 14 mmHg; the CI excludes 0, matching P = .028.

The Student test gives almost the same result here (t = 2.23, df 80, P = .028) because the two SDs are similar. Whether 7.4 mmHg matters is a clinical question, not a statistical one.

## Methods wording

Means of the two groups were compared with the Welch t test, which does not assume equal variances [2], and the mean difference is reported with its 95% CI (BiostatKit [1]).

Method: Welch and Student two-sample t tests from summary statistics, 95% CI of the mean difference from the t distribution, Cohen's d with the pooled SD.

## Frequently asked questions

### Welch or Student t test?

Welch is the safer default: it gives almost the same answer as Student when the SDs and group sizes are similar, and it stays correct when they are not. Use Student only if you have a reason to assume equal variances, and say which one you used.

### Why are the degrees of freedom not a whole number?

The Welch test estimates its degrees of freedom from the two variances and group sizes (Welch-Satterthwaite), so they are usually a decimal. That is expected.

### Can I enter a standard error or a 95% CI instead of the SD?

Convert first. SD = SE x sqrt(n). From a 95% CI of a mean in a large group, SD = sqrt(n) x (upper - lower) / 3.92.

### What does Cohen's d tell me?

It expresses the difference in means in units of the pooled SD. Cohen suggested 0.2, 0.5 and 0.8 as small, medium and large, but the clinical meaning of the difference in the original unit matters more.

### Is my data stored or sent anywhere?

No. All calculations run in your browser tab. Nothing is uploaded, and the page works offline once loaded.

## Related calculators

- [Sample size: two means or two proportions](https://biostatkit.com/sample-size-two-groups): Participants per group to compare two groups with a chosen power.
- [Chi-square test calculator](https://biostatkit.com/chi-square-test): Pearson and Yates chi-square, Fisher exact P and expected counts for a 2x2 table.
- [Bland-Altman analysis](https://biostatkit.com/bland-altman): Bias and 95% limits of agreement between two measurement methods.
- [All BiostatKit calculators](https://biostatkit.com/)

## References

1. Welch BL. The generalization of 'Student's' problem when several different population variances are involved. Biometrika. 1947;34(1-2):28-35. doi:[10.1093/biomet/34.1-2.28](https://doi.org/10.1093/biomet/34.1-2.28)
2. Student. The probable error of a mean. Biometrika. 1908;6(1):1-25. doi:[10.1093/biomet/6.1.1](https://doi.org/10.1093/biomet/6.1.1)
3. Delacre M, Lakens D, Leys C. Why psychologists should by default use Welch's t-test instead of Student's t-test. Int Rev Soc Psychol. 2017;30(1):92-101. doi:[10.5334/irsp.82](https://doi.org/10.5334/irsp.82)
4. Cohen J. Statistical Power Analysis for the Behavioral Sciences. 2nd ed. Hillsdale, NJ: Lawrence Erlbaum Associates; 1988.
5. Schulz KF, Altman DG, Moher D; CONSORT Group. CONSORT 2010 statement: updated guidelines for reporting parallel group randomised trials. BMJ. 2010;340:c332. doi:[10.1136/bmj.c332](https://doi.org/10.1136/bmj.c332)

Author: TS.BS. Vũ Duy Kiên (https://www.vuduykien.com)
