BiostatKit / Tests & intervals / Independent t-test
Independent t-Test Calculator
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.
Your data never leaves your browser. No sign-up, no ads.Result
Difference in means, group 1 minus group 2.
Sentence for your manuscript
Written in AMA style from your numbers. Check it against your own study design before you submit.
Reporting checklist
- CONSORT 2010 (trials): for each outcome give the result in each group and the estimated effect size with its precision, such as a 95% CI (item 17a).
- STROBE 2007 (observational studies): describe all statistical methods (item 12) and give unadjusted estimates with their precision (item 16a).
- Give the mean and SD of each group, the difference in means with its 95% CI, and say whether you used the Welch or the Student t test.
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]).
[1] BiostatKit. Independent t-test calculator. Accessed [date]. [URL]
[2] Welch BL. The generalization of 'Student's' problem when several different population variances are involved. Biometrika. 1947;34(1-2):28-35.
Reproduce it in R
The script is filled in with your numbers. Paste it into R or RStudio and compare.
This calculator was checked against Python (SciPy ttest_ind_from_stats, and ttest_ind with its confidence interval on rebuilt samples) on 3 reference cases and matched to 4 significant digits. See the verification log.
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
Step by step
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.
Press Load example above to see these numbers in the calculator.
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.
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: Participants per group to compare two groups with a chosen power.
- Chi-square test calculator: Pearson and Yates chi-square, Fisher exact P and expected counts for a 2x2 table.
- Bland-Altman analysis: Bias and 95% limits of agreement between two measurement methods.
- All BiostatKit calculators