t test vs z test

T test vs Z test: How to Choose the Right One

Key Takeaways

  • Use a t-test for a mean when the population standard deviation is unknown.
  • Use a z-test for a mean when the population standard deviation is known. For proportions, the test is usually a z-test when the normal conditions are met.
  • The t-distribution has heavier tails than the normal distribution, especially for small samples, and it gets closer to normal as sample size grows.

t test vs z test can feel confusing because both tests compare a sample to a claim. The hard part is knowing which one fits your data.

This guide gives you a simple rule, clear steps, and worked examples. You are not behind. You just need a clear method.

Quick answer

A t-test and a z-test are both hypothesis tests (methods used to check whether sample data support a claim). The main difference is this: for means, use a z-test when the population standard deviation σ is known, and use a t-test when σ is unknown and you use the sample standard deviation s instead. For proportions, you usually use a z-test if the sample is large enough for the normal approximation.

Mini-rule:

  1. Check what you are testing: mean or proportion.
  2. If it is a mean, ask whether σ is known.
  3. If σ is known, use z. If σ is unknown, use t.

For one-sample means, the formulas are:z=xˉμ0σ/nz=\frac{\bar{x}-\mu_0}{\sigma/\sqrt{n}}t=xˉμ0s/nt=\frac{\bar{x}-\mu_0}{s/\sqrt{n}}

Where:

  • xˉ\bar{x} = sample mean (average from your sample)
  • μ0\mu_0​ = claimed population mean
  • σ\sigma = population standard deviation
  • ss = sample standard deviation
  • nn = sample size

What is the difference between a t-test and a z-test?

A test statistic is a number that shows how far your sample result is from the claim in the null hypothesis. Both tests measure distance in standard error units, but they use different distributions.

Main difference

Featuret-testz-test
Usually used forMeansMeans or proportions
Standard deviation usedSample standard deviation sssPopulation standard deviation σ\sigmaσ
Distribution usedt-distributionStandard normal distribution
Best known classroom ruleUse when σ\sigmaσ is unknownUse when σ\sigmaσ is known
Small sample behaviorSafer because t has heavier tailsLess common for means in real life

This rule is the safest beginner rule for means:

  • Unknown σt-test
  • Known σz-test

Why the t-distribution is different

The t-distribution is a curve like the normal curve, but with heavier tails (more area in the ends). That extra spread accounts for the fact that you are estimating the population standard deviation with sample data. As the sample size gets bigger, the t-distribution becomes closer to the normal distribution.

Key terms you need to know

  • Mean (average value).
  • Population (the whole group you want to study).
  • Sample (the smaller group you actually measure).
  • Standard deviation (how spread out the data are).
  • Population standard deviation σ (true spread in the full population).
  • Sample standard deviation sss (spread measured from your sample).
  • Hypothesis test (a method for checking a claim using sample data).
  • Null hypothesis H0H_0 (the claim you test first, often “no difference” or “equals”).
  • Alternative hypothesis HaH_a (the competing claim).
  • p-value (how surprising your sample result would be if the null hypothesis were true).
  • Degrees of freedom, df (how many values can vary freely after a rule is used). For a one-sample t-test, df=n1df=n-1.

Why does t use n−1?

When you compute the sample standard deviation, you first use the sample mean. After that, only n−1 deviations can vary freely because the deviations must add up to zero. That is why the degrees of freedom for the one-sample t-distribution are n1n-1.

When to use t-test vs z-test

Use a t-test when:

  • You are testing a mean.
  • The population standard deviation is unknown.
  • The population is roughly normal, or the sample is large enough for the method to work well.

Use a z-test when:

  • You are testing a mean and the population standard deviation is known.
  • You are testing a proportion and the normal conditions are met.

Important note about “sample size 30”

Many students learn this shortcut:

  • “If n30n \ge 30, use z.”

That shortcut is too simple by itself. For means, the better classroom rule is still about whether σ is known. In real problems, σ\sigma is often unknown, so the t-test is often the better choice for means, even with larger samples.

t-test vs z-test decision table

QuestionUse this
Testing one mean, σ\sigma knownz-test
Testing one mean, σ\sigma unknownt-test
Testing one proportion, conditions metz-test
Comparing means with unknown population standard deviationsusually a t-based method

Step-by-step method

Use this process when your teacher asks you to choose the test and solve.

Step 1: Identify the variable

Ask: are you testing a mean or a proportion?

  • Mean examples: average height, average score, average wait time
  • Proportion examples: percent who passed, fraction who prefer tea, share of defective items

Step 2: Write the hypotheses

Example:

  • H0:μ=50H_0:\mu=50
  • Ha:μ50H_a:\mu\neq50

Or for a proportion:

  • H0:p=0.40H_0:p=0.40
  • Ha:p>0.40H_a:p>0.40

Step 3: Check what standard deviation you have

  • If the problem gives population standard deviation σ for a mean, use z.
  • If it only gives sample data and you must compute s, use t.

Step 4: Choose the formula

For one mean:z=xˉμ0σ/nt=xˉμ0s/nz=\frac{\bar{x}-\mu_0}{\sigma/\sqrt{n}} \qquad t=\frac{\bar{x}-\mu_0}{s/\sqrt{n}}

Step 5: Compute the test statistic

Plug in the numbers carefully.

Step 6: Find the p-value or compare with a critical value

Use your calculator, table, or software.

Step 7: Make the decision

  • If pαp \le \alpha, reject H0H_0.
  • If p>αp > \alpha, fail to reject H0H_0​.

Step 8: Write the conclusion in words

Answer the question in context.

What to write on your paper

Use this mini-checklist:

  1. Parameter: mean or proportion
  2. H0H_0 and HaH_a
  3. Test used: t-test or z-test
  4. Given values: nn, xˉ\bar{x}, μ0\mu_0​, and σ\sigma or ss
  5. Test statistic
  6. p-value or critical value
  7. Decision
  8. Final sentence in context

Quick self-check

Ask yourself:

  • Did I test a mean or a proportion?
  • Did I use σ or s correctly?
  • Does my conclusion match the direction of HaH_a?
  • Did I write the conclusion in words, not just symbols?

Worked examples

Example 1

A juice factory says its bottles have an average fill of 500 mL. The population standard deviation is known: σ=12\sigma=12 mL. A sample of n=36n=36bottles has mean xˉ=496\bar{x}=496 mL. At α=0.05\alpha=0.05, test whether the true mean differs from 500 mL.

Step 1: Hypotheses

H0:μ=500H_0:\mu=500Ha:μ500H_a:\mu\neq500

Step 2: Choose the test

This is a test about a mean, and σ\sigmaσ is known. Use a z-test.

Step 3: Compute the test statistic

z=xˉμ0σ/n=49650012/36=412/6=42=2z=\frac{\bar{x}-\mu_0}{\sigma/\sqrt{n}} =\frac{496-500}{12/\sqrt{36}} =\frac{-4}{12/6} =\frac{-4}{2} =-2

Why this step happens: the formula measures how far the sample mean is from the claim in standard error units.

Step 4: Decision

For a two-tailed test at α=0.05\alpha=0.05, z=2|z|=2 gives a p-value a little below 0.05, so reject H0H_0​.

Final answer

There is enough evidence at the 5% level to say the mean fill is different from 500 mL.


Example 2: Typical homework one-sample t-test

A teacher says the average study time before a quiz is 4 hours. A sample of 16 students has:

  • xˉ=5\bar{x}=5 hours
  • s=2s=2 hours

Test at α=0.05\alpha=0.05 whether the average study time is greater than 4 hours.

Step 1: Hypotheses

H0:μ=4H_0:\mu=4Ha:μ>4H_a:\mu>4

Step 2: Choose the test

This is a test about a mean, but the population standard deviation is unknown. Use a t-test.

Step 3: Compute the test statistic

t=xˉμ0s/n=542/16=12/4=10.5=2t=\frac{\bar{x}-\mu_0}{s/\sqrt{n}} =\frac{5-4}{2/\sqrt{16}} =\frac{1}{2/4} =\frac{1}{0.5} =2

Step 4: Degrees of freedom

df=n1=161=15df=n-1=16-1=15

Step 5: Decision

For a right-tailed test with df=15df=15, t=2t=2 gives a p-value below 0.05, so reject H0H_0​.

Final answer

There is enough evidence to say the average study time is greater than 4 hours.


Example 3: Mean or proportion?

A school says 60% of students bring lunch from home. You sample 100 students and find 68 bring lunch.

Step 1: Identify the parameter

This is a proportion, not a mean.

Step 2: Choose the test

For one population proportion, the usual classroom method is a z-test when the conditions for the normal approximation are met.

Why this matters

Some students see a sample size of 100 and think “t-test because sample data.” That is wrong here because the variable is a proportion, not a mean.


Example 4: Exam-style trick question

A problem says:

“A sample of 40 light bulbs has mean life 810 hours. The company claims the mean is 800 hours. The sample standard deviation is 50 hours.”

Which test?

Correct choice

Use a t-test.

Why

You are testing a mean, and the problem gives sample standard deviation s, not population standard deviation σ\sigmaσ. Even though n=40n=40, the safer rule for means is still based on whether σ\sigma is known.

Practice set

Try these before checking the answers.

  1. A company claims the average battery life is 20 hours. You know σ=3\sigma=3 hours. A sample of 25 batteries has xˉ=18.8\bar{x}=18.8. Which test?
  2. A class average is claimed to be 75. A sample of 10 students has xˉ=72\bar{x}=72 and s=6s=6. Which test?
  3. A survey checks whether more than 45% of students prefer online notes. Out of 200 students, 110 say yes. Which test?
  4. A sample of 36 plants has xˉ=14\bar{x}=14 cm and s=2s=2 cm. The claim is μ=13.5\mu=13.5 cm. Which test?
  5. A hospital says the average waiting time is 30 minutes. You know the population standard deviation is 8 minutes. A sample of 49 patients has mean 28 minutes. Which test?
  6. A school says 70% of students pass a screening test. In a sample of 120 students, 78 pass. Which test?
  7. A sample of 12 quiz scores has mean 81 and sample standard deviation 5. The claim is 80. Which test?
  8. Common trap: A sample of 100 people is used to test whether the average height differs from 170 cm. The problem gives s=9s=9 cm, not σ\sigma. Which test?

Answer key

  1. z-test
  2. t-test
  3. z-test for one proportion
  4. t-test
  5. z-test
  6. z-test for one proportion
  7. t-test
  8. t-test

Short solutions for 2 items

Item 1:
Testing a mean with known σ, so use z-test.

Item 8:
Large sample, but still a mean with unknown population standard deviation. Since only ss is given, use t-test.

mistakes

Common mistakes: t test vs z test

MistakeWhy it happensDo this instead
Using z-test just because n30n \ge 30Students memorize a shortcut and stop thereFor means, first ask whether σ\sigmaσ is known
Using t-test for proportions“Test” sounds the same, so students mix variable typesCheck the parameter first: mean or proportion
Mixing up ss and σ\sigmaBoth are standard deviationssss is from the sample, σ\sigmaσ is the population value
Forgetting degrees of freedom in t-testStudents rush to computeFor one-sample t, use df=n1df=n-1
Writing a math-only conclusionStudents stop after the p-valueAlways write one sentence in context
Choosing the wrong tailStudents do not read the claim carefullyMatch the sign in HaH_aHa​: <<, >>, or \neq

If you get stuck…

“I don’t know what formula to use.”
Start by asking: am I testing a mean or a proportion? Then ask whether σ is known.

“I keep mixing up t and z.”
Use this memory line:

  • t → mean with unknown population standard deviation
  • z → mean with known population standard deviation, or many proportion tests

“My calculator gives a different value.”
Check:

  • Did you enter σ\sigma or sss correctly?
  • Did you choose one-tailed or two-tailed correctly?
  • Did you use the right degrees of freedom for t?

“I do not know whether the answer should be negative.”
The test statistic can be negative. That usually just means the sample mean is below the claimed mean.

“I do not know the prerequisite ideas.”
Review hypothesis testing basics and test selection first:

“I still do not get why this is t and not z.”
That is normal. Ask your teacher or tutor to show one problem where σ\sigmaσ is known and one where it is unknown. Seeing both side by side usually helps.

Next steps

  • How to Choose the Right Statistical Test — Start here if you want a bigger map of when to use each test.
  • Statistical Test Selector — Use this tool when you are unsure which test fits your homework or project.
  • t-Distribution Calculator — Helpful when your problem uses a t-test and you need tail areas or critical values.
  • Confidence Interval Calculator — Good next step because confidence intervals and hypothesis tests are closely connected.
  • parametric vs nonparametric tests — Read this next if your class is moving beyond basic test choice and into assumption checks.
  • one tailed vs two tailed test — Read this next if you keep getting confused about the direction of the alternative hypothesis.

How we know

  • This guide follows standard classroom rules for choosing between one-sample mean z-tests and t-tests.
  • The explanation of the t-distribution and its heavier tails matches standard introductory statistics texts.
  • The explanation of degrees of freedom n−1 follows standard textbook treatment of the sample standard deviation and Student’s t-distribution.
  • The point that one-sample proportion tests commonly use a z-test comes from standard intro statistics materials.
  • Worked steps were checked against standard hypothesis-testing structure used in university statistics instruction.

Use this the right way

Use this guide to learn the method, not to skip the learning. Write your own steps in your own words when you do homework or research. If you use outside sources in a report or paper, cite them properly and avoid plagiarism.

Reference

Pennsylvania State University. (n.d.). 8.2.3 Hypothesis testing. STAT 200. https://online.stat.psu.edu/stat200/lesson/8/8.2/8.2.3

OpenStax. (2023). 8.2 A single population mean using the Student t distribution. In Introductory Statistics 2e. https://openstax.org/books/introductory-statistics-2e/pages/8-2-a-single-population-mean-using-the-student-t-distribution

OpenStax. (2023). 9.5 Additional information and full hypothesis test examples. In Introductory Statistics 2e. https://openstax.org/books/introductory-statistics-2e/pages/9-5-additional-information-and-full-hypothesis-test-examples

Scroll to Top