Step by step

How to calculate a t-test by hand

Work through each t-test with a pencil, a calculator and a t table. Every number below was computed by the same engine as the calculators, so you can check your own working line by line.

Sources checked on November 21, 2026. Results computed by the site's engine and tested against R and SciPy.

The common recipe

Every t-test has the same shape: an estimate, minus the value the null hypothesis expects, divided by the estimate's standard error. What changes between the tests is the estimate and how its standard error is found.

t = (estimate − hypothesized value) / standard error

Then you need the degrees of freedom, which set the shape of the t distribution, and either a critical value from a t table or an exact p-value from software or the p-value from t calculator.

Paired test, worked

Use Student's sleep data: two drugs given to the same 10 patients. Step 1 is to subtract within each pair. The differences, drug 1 minus drug 2, are: −1.2, −2.4, −1.3, −1.3, 0, −1, −1.8, −0.8, −4.6, −1.4.

  1. Mean of the differences: d̄ = −1.58.
  2. Standard deviation of the differences: sd = 1.2300 (divide the sum of squared deviations by n − 1 = 9).
  3. Standard error: sd / √n = 1.2300 / √10 = 0.3890.
  4. t = −1.58 / 0.3890 = −4.0621, with df = 9.
  5. The two-tailed 5% critical value for 9 df is 2.262. Since |t| = 4.06 is larger, the difference is significant at the 5% level. The exact two-sided p is 0.0028.

One-sample test, worked

The one-sample test is the paired test without the subtraction step. To test whether the sleep differences above have a mean of zero you would get exactly the same t; that is why software runs a paired test as a one-sample test on the differences. For a fresh example, take NIST's ZARR13 summary: mean 9.26146, SD 0.022789, n = 195, tested against 5. The standard error is 0.022789 / √195 = 0.001632, and t = (9.26146 − 5) / 0.001632 = 2611.26 on 194 df.

Student's independent test, worked

Now treat the two sleep columns as if they came from different patients. Group means are 0.75 and 2.33, SDs 1.7890 and 2.0022, with 10 in each.

  1. Pooled variance: sp² = [(9)(1.7890)² + (9)(2.0022)²] / 18 = 3.6048, so sp = 1.8986.
  2. Standard error: sp√(1/10 + 1/10) = 0.8491.
  3. t = (0.75 − 2.33) / 0.8491 = −1.8608, with df = 10 + 10 − 2 = 18.
  4. Two-tailed 5% critical value for 18 df: 2.101. |t| is smaller, so this is not significant at the 5% level (exact p = 0.0792).

Welch's test and its degrees of freedom

Welch's test uses the same difference but a standard error that does not pool: √(s1²/n1 + s2²/n2). With equal group sizes, as here, it equals Student's standard error, so t is the same: −1.8608. The degrees of freedom differ. Write v1 = s1²/n1 = 0.3201 and v2 = s2²/n2 = 0.4009. Then

df = (v1 + v2)² / (v1²/(n1−1) + v2²/(n2−1)) = 17.78

Keep the decimals. With df = 17.78 the exact two-sided p is 0.0794, matching R's printed df of 17.776. If you must use a printed table, round the df down to 17, which gives a slightly larger critical value of 2.110.

Textbook check: OpenStax Example 10.1

OpenStax Introductory Statistics works a Welch test from summary statistics: means 2 and 3.2, SDs 0.866 and 1, samples of 9 and 16. Our engine gives t = −3.14 and df = 18.8466, against the book's df of about 18.8462. The book reports p = 0.0054; that is the two-sided p (the one-sided value is 0.0027).

If your answer differs from software

  • Check that you used n − 1, not n, in the SD.
  • Do not round intermediate values; carry at least five significant figures until the end.
  • Check which test the software ran. Excel, SPSS and R each have their own defaults; see t-tests in R, Python, Excel and SPSS.
  • Check the direction: t changes sign if you swap the groups, but |t| and the two-sided p do not.
  • Some school syllabuses use their own version of the formula. If yours does, follow your course's formula sheet for exams and expect small differences from the results here.

Sources