Free statistics calculators, every step shown

T Test vs Z Test

Enter a mean, SD and sample size to run a t test and a z test side by side and see which one applies to your data.

The T test vs Z test calculator runs a one-sample t test and a z test on the same numbers, then tells you which one to report. You enter the sample mean, the hypothesized mean, the standard deviation, the sample size, the tail and α. Both tests use one shared test statistic, so the difference comes from the distribution it is compared against: a t distribution with n − 1 degrees of freedom for the t test, and the standard normal for the z test. The z test is recommended only when the population standard deviation σ is known. Otherwise the t test is recommended, because a sample standard deviation is only an estimate. The tool runs in your browser, is free, and needs no sign-up.
T test vs z test example

How to use the T test vs Z test calculator

  1. Type the sample mean x̄ and the hypothesized mean μ₀.
  2. Type the standard deviation. Leave the checkbox unticked if this is a sample SD. Tick it only if the value is the known population SD σ.
  3. Type the sample size n. It must be a whole number of at least 2.
  4. Choose the tail: two-tailed, right-tailed or left-tailed.
  5. Set α. It defaults to 0.05, and you can also type 5 %.
  6. Read the two large results: the recommended test’s name and its p-value.
  7. Check the verdict at α for that test, then compare the two tests in the side-by-side table.
  8. Open “How it was calculated” under the result to see the formula, the values substituted and the answer.

The result updates as you type. The preset buttons above the form load typical cases, such as a case where the two tests disagree. Reset restores the starting example. Printing, copying and sharing are covered below.

Example: x̄ = 104.5, μ₀ = 100, SD = 7 and n = 10 (the starting values) give the same statistic, 2.0329, for both tests, but the t test does not reject at α = 0.05 (p = 0.072594) while the z test does (p = 0.042063). Tick the σ box only if 7 is a known population value, not one measured from these ten observations.

T test vs z test: what is the difference?

The two tests share one statistic: t = (x̄ − μ₀)/(SD/√n). The t test compares it with a t distribution that has n − 1 degrees of freedom. The z test compares the same number with the standard normal, which is equivalent to treating the degrees of freedom as infinite. The t distribution has heavier tails, so its p-value is never smaller than the z p-value for the same statistic. Using z with a sample SD therefore makes a result look more significant than it is.

When to use a t test vs a z test

Use the z test when the population standard deviation σ is known from outside the sample — for example from a long-running process or a published norm — and for large-sample tests of proportions. Use the t test whenever the standard deviation comes from the same sample, which is nearly always the case in practice. The gap is largest for small samples. With the starting example (x̄ = 104.5, μ₀ = 100, SD = 7, n = 10, two-tailed), the statistic is 2.0329. The t test gives p = 0.072594 and fails to reject at α = 0.05, because the critical value is 2.2622. The z test gives p = 0.042063 and rejects, because its critical value is 1.96. As n grows, the t critical value falls toward 1.96, and the two tests agree.

Does sample size change the answer?

Yes, through the degrees of freedom. The table under the result shows the two-tailed 5 % critical values for t at n = 5, 10, 30, 100 and 1000 next to z = 1.96: the difference is large at n = 5 and almost gone at n = 1000. That is why older textbooks said a z test is fine above n = 30; with software there is no reason not to use the t test whenever σ is estimated from the sample.

Worked examples

InputResult
x̄ = 104.5, μ₀ = 100, SD = 7, n = 10, Two-tailedstatistic = 2.033, t test p = 0.072594, z test p = 0.042063, use the t test
x̄ = 52.3, μ₀ = 50, SD = 6.2, n = 25, Two-tailedstatistic = 1.855, t test p = 0.075946, z test p = 0.063619, use the t test
x̄ = 100.8, μ₀ = 100, SD = 4, n = 400, Two-tailedstatistic = 4, t test p = 7.5493 × 10⁻⁵, z test p = 6.3342 × 10⁻⁵, use the t test
x̄ = 98.4, μ₀ = 100, SD = 5, n = 30, Left-tailedstatistic = -1.753, t test p = 0.04511, z test p = 0.039826, use the z test

Calculated by the tool above with these values.

Frequently asked questions

Is the calculator free, and is anything I type uploaded?

Yes, the calculator is free. Everything is calculated in your browser, so nothing you type is uploaded, and there is no account or sign-up. Results may be used in any work, including commercial reports, theses and client projects, without attribution. The page reminds you to check that the method’s assumptions fit your data before you report a result.

Can I print or share a calculation?

Yes. “Print / save as PDF” produces a one-page record with your inputs, the results, the calculation steps and the date. “Copy result” copies the result lines together with a link. “Copy link” copies the page address, which stores every input in the ?s= part of the URL, so the same calculation reopens later or can be sent to a colleague.

Why is the t p-value always larger than the z p-value for the same numbers?

The t distribution has heavier tails than the standard normal, so a given test statistic leaves more probability beyond it. The t p-value is therefore never smaller than the z p-value for the same statistic.

When should I use the z test instead of the t test?

Use the z test only when the population standard deviation σ is known. If you only have a sample standard deviation, use the t test, because the sample SD is an estimate and the t test allows for that uncertainty.

Why do the t and z critical values get closer as the sample size grows?

The t distribution’s degrees of freedom are n − 1, so as n increases the t distribution approaches the standard normal. In the calculator’s table, the gap t − z shrinks at n = 5, 10, 30, 100 and 1000.

What does the warning about the p-value being within 2 % of α mean?

It means the decision is close. A small change in the data or in α could change the verdict, so report the p-value along with the decision rather than the decision alone.

What does the warning about the sample mean pointing the wrong way mean?

For a one-sided alternative, the warning appears when x̄ lies on the opposite side of μ₀ from the direction you chose. In that case the p-value for that tail is large, and you should check that you picked the right tail.