Study and Productivity

One-Sample t Test, z Test and p-Values in Plain Language

How to test whether a sample differs from a target value with t and z tests, a proportion test and an F test, and how to read p-values and intervals.

Saizul Amin
Saizul Amin30 Oct 2026 · 3 min read
One-Sample t Test, z Test and p-Values in Plain Language

One-Sample t Test, z Test and p-Values in Plain Language

Is the average weight of these cereal boxes really 500 g? Is our defect rate higher than the 5 % in the contract? Did a new procedure change the variability? One-sample tests compare data with a fixed value. This guide explains how they work and how to read their results, and you can run them with the one-sample test calculator.

The logic of a test

  1. State a null hypothesis, for example "the true mean is 500 g".
  2. Choose a significance level α, often 0.05.
  3. Compute a test statistic from the data.
  4. Find the p-value: the probability of getting a result at least this extreme if the null hypothesis were true.
  5. If p < α, reject the null hypothesis.

The one-sample t test

When the population standard deviation is unknown, which is almost always, use:

t = (x̄ − μ₀) / (s / √n),

with n − 1 degrees of freedom. The t distribution has heavier tails than the normal distribution, accounting for the uncertainty in s.

Example: 25 boxes have a mean of 52 g above a reference and an SD of 5; against μ₀ = 50, t = 2.00 with 24 degrees of freedom and a two-sided p of 0.057. At α = 0.05 the difference is not significant.

The z test

If σ is genuinely known from long experience, z = (x̄ − μ₀) / (σ / √n) uses the standard normal distribution. The critical values for a two-sided 5 % test are ±1.96.

One-sided or two-sided?

A two-sided test asks whether the mean differs in either direction. A one-sided test asks about one direction only, and halves the p-value when the effect goes that way. Choose before seeing the data; switching afterwards inflates false positives.

Confidence intervals

The confidence interval x̄ ± t* × s / √n gives the range of plausible true means. In the example the 95 % interval is 49.9 to 54.1. It contains 50, matching the non-significant test. Intervals show both the size and the uncertainty of an effect, so report them alongside p-values.

Testing a proportion

For a proportion, z = (p̂ − p₀) / √(p₀(1 − p₀)/n). With 58 successes in 100 trials against p₀ = 0.5, z = 1.60 and p = 0.11. The approximation works when n p₀ and n(1 − p₀) are at least 10; otherwise use an exact binomial test.

Comparing two variances

The F test divides two sample variances: F = s₁² / s₂². With variances 25 and 10 on 15 and 20 degrees of freedom, F = 2.5 and the two-sided p is about 0.057. The F test is sensitive to non-normal data; Levene's test is more robust.

Common misunderstandings

  • p is not the probability that the null hypothesis is true.
  • A non-significant result does not prove there is no effect; the study may be too small.
  • Statistical significance is not practical importance: with thousands of observations, trivial differences become significant.

Assumptions

  • Random, independent observations.
  • Approximately normal data, or a large enough sample (n above about 30) for the central limit theorem.
  • For the proportion test, enough successes and failures.

Using the calculator

  1. Enter the sample mean, SD and size, and the hypothesised mean.
  2. Enter σ if known.
  3. Choose the alternative and α.
  4. Enter proportion and variance data if needed.
  5. Read the statistics, exact p-values, confidence interval and decision.

Limits

The calculator computes standard tests from summaries. It cannot check your data for outliers or non-normality; look at the data first.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages