Uni-Sine
MathematicsStatistics

T test calculator with the p-value shaded

A t test checks whether a mean, or the difference between two means, is far enough from what you expected to be more than chance. It turns the difference into a t statistic, for one sample t = (x̄ − μ₀) ÷ (s ÷ √n), and compares it with a t distribution to get a p-value. If p is below your significance level, usually 0.05, you reject the null hypothesis. This t test calculator is part of our Hypothesis Test Calculator: it runs one-sample, two-sample and paired t tests and ends with a conclusion in words.

Try it

Hypothesis Test Calculator

Run z, t and chi-squared tests and read off the p-value

Go to its page

How to run a t test in the calculator

  1. Open the Hypothesis Test Calculator. It opens on a z test, so under Which test choose One-sample t test, Two-sample t test or Paired t test.
  2. Choose the tail (Two-tailed, Lower tail or Upper tail) and the significance level (10%, 5%, 1% or 0.1%).
  3. Under Values, enter Summary values (means, standard deviations and sizes) or switch to Raw data and type or paste your data. For a one-sample test, also give the Mean to test μ₀.
  4. For a two-sample test, turn on Assume equal variances (pooled) only if you have reason to. Otherwise it runs Welch's test.
  5. Read the hypotheses, the test statistic, the p-value, the critical values, the degrees of freedom and the conclusion. The distribution shades the p-value and the critical region.

Which t test?

TestUse it whent statisticDegrees of freedom
One-sampleComparing one mean with a known value(x̄ − μ₀) ÷ (s ÷ √n)n − 1
Two-sample (Welch)Comparing two independent groups(x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂)Welch's formula
PairedTwo measurements on the same subjectsd̄ ÷ (s_d ÷ √n), on the differencesn − 1

Use a t test, not a z test, when the population standard deviation is unknown and you estimate it from the sample. t tests assume the data, or the differences, come from a roughly normal population, which matters most for small samples.

Worked examples you can check in the calculator

Example 1: one-sample t test

A maker claims its batteries last 10 hours. A sample of 16 lasts a mean of 9.6 hours with s = 1.2. Is that evidence the claim is wrong, at the 5% level, two-tailed? H₀: μ = 10 and H₁: μ ≠ 10.

t = \frac{9.6 - 10}{1.2 \div \sqrt{16}} = \frac{-0.4}{0.3} = -1.333

With 15 degrees of freedom the p-value is 0.202, and the critical values are ±2.131. Since p > 0.05, do not reject H₀: the sample doesn't give enough evidence against the 10-hour claim.

Example 2: two-sample t test

Group A (n = 20) scores a mean of 72 with s = 8, and group B (n = 22) a mean of 66 with s = 10. Is there a difference, at 5%, two-tailed?

t = \frac{72 - 66}{\sqrt{\frac{8^2}{20} + \frac{10^2}{22}}} = \frac{6}{2.783} = 2.156

Welch's formula gives about 39.4 degrees of freedom, and the p-value is 0.037. Since p < 0.05, reject H₀: there is evidence the group means differ.

Example 3: paired t test

Five students take a test before and after a revision session. Their improvements are 2, 4, 1, 3 and 5 marks. Work on the differences: d̄ = 3 and s_d = 1.581, so:

t = \frac{3}{1.581 \div \sqrt{5}} = 4.243

With 4 degrees of freedom, p = 0.013 two-tailed, below 0.05, so there is evidence the session changed the scores. Choose Paired t test, Raw data, and type the differences. A paired test is right here because the same students were measured twice.

Try one

practice
Pick an answer, then check it.
A t test gives p = 0.08. At the 5% significance level, what do you conclude?

One-tailed or two-tailed?

Choose before you look at the data. A two-tailed test asks whether the mean is different in either direction. A one-tailed test asks about one direction only, such as whether batteries last less than claimed. For the same t, the one-tailed p-value is half the two-tailed one: in example 1 it would be 0.101, still not significant.

Common mistakes

  • Using a two-sample test on paired data. If the same subjects are measured twice, use the paired test.
  • Dividing by s instead of s ÷ √n. The t statistic uses the standard error of the mean.
  • Saying H₀ is proven true. A large p-value only means not enough evidence against it.
  • Choosing the tail after seeing the data. Decide the direction first.
  • Pooling variances by habit. Welch's test is safer unless the variances are known to be equal.

Common questions

What does a t test tell you?
Whether a difference in means is larger than you'd expect from chance, given the spread and size of the samples. The p-value says how surprising the result would be if the null hypothesis were true.
What is the formula for a one-sample t test?
t = (x̄ − μ₀) ÷ (s ÷ √n), with n − 1 degrees of freedom.
When should I use a paired t test?
When each value in one sample matches one in the other, such as before and after measurements on the same people. Test the differences.
What is the difference between a t test and a z test?
A z test needs the population standard deviation. A t test estimates it from the sample, so it uses the t distribution, which has wider tails for small samples.
Can I paste raw data?
Yes. Switch Values to Raw data and paste a column or two from a spreadsheet.

Revision cards

Read the front, say your answer, then flip to check.

Where to go next

  • Solve it

    Hypothesis Test Calculator

    Run z, t and chi-squared tests and read off the p-value

    Open the tool
  • Test it

    AP Statistics

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Maths · StatisticsP-value calculator: z, t and chi-square testsFree p-value calculator: run a z, t, chi-square or F test from your data or summary values and get the p-value, the critical value and a plain conclusion.