Skip to content

T-Test Calculator (Student and Welch)

One-sample, two-sample (Welch or pooled) and paired t-tests: t statistic, df, p-value and confidence interval.

Your details

Test
Input
Alternative hypothesis H₁

0.05 means 5 % (95 % confidence).

Results update as you type

t statistic

1.3257

p-value
0.2176
Decision at level α
Do not reject H₀
Degrees of freedom
9
Estimate (mean or difference)
0.75
Standard error
0.565731
Critical value t*
±2.2622
Confidence interval (1 − α): lower limit
-0.529774
Confidence interval (1 − α): upper limit
2.029774
Effect size (Cohen’s d)
0.4192

p = 0.2176 > α = 0.05: the data are compatible with H₀ (this does not prove H₀ is true).

Step-by-step solution
  1. SE = s / √n = 1.789 / √10 = 0.565731 ; df = n − 1 = 9
  2. t = (x̄ − 0) / SE = (0.75 − 0) / 0.565731 = 1.3257
  3. p = 2 × P(T > |t|) = 0.2176
  4. t* = 2.2622 ; x̄ ± t* × SE

The t-test asks whether a difference between means is larger than chance alone would easily produce when the population standard deviation is unknown — the usual situation with real data. William Sealy Gosset published it in 1908 under the pen name "Student", which is why the reference distribution is called Student’s t distribution.

This calculator runs the three common versions:

  • One sample: compare a sample mean with a reference value μ0\mu_0 (a target, a label claim, zero effect).
  • Two independent samples: compare two groups, either with Welch’s test (no assumption of equal variances, the safer default) or the classic pooled Student test.
  • Paired: compare two measurements on the same subjects (before/after, left/right); the test works on the differences.

Enter summary statistics (mean, standard deviation, size) or paste raw data. You get the t statistic, the degrees of freedom (Welch–Satterthwaite for unequal variances), an exact p-value for a two-tailed or one-tailed alternative, the critical value, the confidence interval of the mean or difference, Cohen’s dd and the decision at your significance level.

How to use this calculator

  1. Pick the test: one sample, two samples or paired.
  2. Choose summary statistics or raw data. For a paired test with raw data, enter the two lists in the same subject order.
  3. For two samples, choose Welch (unequal variances) unless you have a good reason to assume equal variances.
  4. Set the hypothesised value: μ0\mu_0 for one sample, the difference Δ0\Delta_0 (usually 0) otherwise.
  5. Choose the alternative hypothesis (≠, < or >) and the significance level α (0.05 by default).
  6. Read t, the p-value and the decision; the steps show the standard error and degrees of freedom.

The formula

One sample (and paired, applied to the differences did_i):

t=xˉ−μ0s/ndf=n−1t = \frac{\bar x - \mu_0}{s / \sqrt n} \qquad df = n - 1

Two samples, Welch:

t=xˉ1−xˉ2−Δ0s12n1+s22n2df=(s12n1+s22n2)2(s12/n1)2n1−1+(s22/n2)2n2−1t = \frac{\bar x_1 - \bar x_2 - \Delta_0}{\sqrt{\dfrac{s_1^2}{n_1} + \dfrac{s_2^2}{n_2}}} \qquad df = \frac{\left(\dfrac{s_1^2}{n_1} + \dfrac{s_2^2}{n_2}\right)^2}{\dfrac{(s_1^2/n_1)^2}{n_1 - 1} + \dfrac{(s_2^2/n_2)^2}{n_2 - 1}}

Two samples, pooled (equal variances):

sp2=(n1−1)s12+(n2−1)s22n1+n2−2t=xˉ1−xˉ2−Δ0sp1/n1+1/n2df=n1+n2−2s_p^2 = \frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2} \qquad t = \frac{\bar x_1 - \bar x_2 - \Delta_0}{s_p\sqrt{1/n_1 + 1/n_2}} \qquad df = n_1 + n_2 - 2

The p-value comes from the Student t distribution, P(T>t)=12Idf/(df+t2)(df/2,1/2)P(T > t) = \tfrac12 I_{df/(df + t^2)}(df/2, 1/2), doubled for a two-tailed test. The confidence interval is $\text{estimate} \pm t^* \times SE$ with $t^*$ the 1−α/21 - \alpha/2 quantile (one-sided bound with 1−α1 - \alpha for a one-tailed test). Cohen’s dd divides the difference by ss (or sps_p).

Worked example

Welch two-sample test (OpenStax Introductory Statistics, Example 10.1). Daily sports time: 9 girls, mean 2 h, s = 0.866; 16 boys, mean 3.2 h, s = 1.

  • SE=0.8662/9+12/16=0.3819SE = \sqrt{0.866^2/9 + 1^2/16} = 0.3819
  • t=(2−3.2)/0.3819=−3.1424t = (2 - 3.2) / 0.3819 = -3.1424, with df≈18.85df \approx 18.85
  • Two-tailed p-value 0.0054 < 0.05: reject H0H_0. The 95 % interval for the difference runs from -2 to -0.4 hours.

Paired test (raw-data default: extra hours of sleep for 10 patients under two drugs). The differences have mean −1.58 and sd=1.23s_d = 1.23, so SE=0.389SE = 0.389 and t=−4.0621t = -4.0621 with 9 df. The two-tailed p-value is 0.0028; with $t^* = 2.2622$ the 95 % interval for the mean difference is -2.46 to -0.7 hours.

Which t-test should I use?

Situation Test Degrees of freedom
One group vs a known value One-sample n−1n - 1
Two unrelated groups Welch two-sample Welch–Satterthwaite (decimal)
Two unrelated groups, variances known to be similar Pooled (Student) n1+n2−2n_1 + n_2 - 2
Same subjects measured twice, or matched pairs Paired pairs − 1

Running an unpaired test on paired data throws away the pairing and usually loses a lot of power — in the sleep example the paired p-value is about 0.003, while a Welch test on the same numbers gives about 0.08. Many statisticians recommend Welch’s version by default, because it performs almost as well as the pooled test when variances are equal and much better when they are not.

Assumptions and interpretation

The t-test assumes independent observations and roughly normal data — or, thanks to the central limit theorem, samples large enough (about 30 per group is a common rule of thumb) for the mean to be close to normal. Strong outliers or heavy skew in small samples call for a transformation or a non-parametric test.

A small p-value says the observed difference would be rare if H0H_0 were true; it does not measure how large or important the difference is. Report the confidence interval and an effect size such as Cohen’s dd (about 0.2 small, 0.5 medium, 0.8 large) alongside it. For tabulated critical values at any α, use the critical value calculator; for the summary statistics themselves, the standard deviation calculator.

Frequently asked questions

What does the t-test tell me?

Whether the difference between a sample mean and a reference value, or between two means, is larger than random sampling variation would typically produce. The p-value measures that.

Should I use Welch’s or Student’s two-sample test?

Welch’s test is the safer default: it does not assume equal variances and loses little when they are equal. Use the pooled test only when equal variances are well justified.

When is a t-test paired?

When each value in one list belongs with one value in the other — the same person before and after, twins, left and right eye. The test then analyses the differences.

One-tailed or two-tailed?

Use two-tailed unless the direction was fixed before seeing the data and a difference in the other direction would be treated like no difference. A one-tailed p-value is half the two-tailed one when t points the expected way.

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

The Welch–Satterthwaite formula approximates the distribution of the statistic with a t distribution whose df can be fractional. The calculator uses the exact fractional value.

Sources

Last updated:

More Statistics calculators

People also use