Hypothesis Test Calculator (One-Sample t and z Test)
Test whether a sample mean differs from a hypothesised value: one-sample t-test or z-test, two-tailed or one-tailed, with the test statistic and p-value.
Last updated: October 2026
p-value
0.189
Formula below · 1 source (itl.nist.gov) · Updated Oct 2026
Compare with similar
About this calculator
A one-sample test asks whether a sample mean x̄ is far enough from a hypothesised population mean μ₀ that chance is an unlikely explanation.
test statistic = (x̄ − μ₀) ÷ (s ÷ √n)
s ÷ √n is the standard error of the mean.
t or z
Use the t-test when the standard deviation is estimated from the same sample, which is almost always the case. The statistic then follows a t distribution with n − 1 degrees of freedom, whose heavier tails allow for the uncertainty in s. Use the z-test only when the population standard deviation σ is known from outside the sample (for example a long-run process value). For large samples the two give nearly the same answer.
The p-value
The p-value is the probability of a test statistic at least as extreme as yours if μ = μ₀. Two-tailed tests count both directions; a one-tailed test counts only the direction stated in the alternative hypothesis, and should be chosen before seeing the data. If p is below your significance level α (commonly 0.05), you reject H₀. The calculator computes p exactly from the t distribution (regularised incomplete beta function) or the normal distribution.
Assumptions and limits
Observations should be independent and the mean roughly normally distributed: fine for symmetric data or n of about 30 or more, risky for small, skewed samples. A small p-value says the difference is unlikely to be chance, not that it is large or important: report the difference and a confidence interval too.
How to use
Enter the sample mean, the hypothesised mean, the standard deviation and the sample size, then choose the test and the alternative hypothesis. Example 1 (defaults): x̄ = 52.3, μ₀ = 50, s = 8.5, n = 25, two-tailed t-test. Standard error 8.5 ÷ 5 = 1.7; t = 2.3 ÷ 1.7 ≈ 1.353 with 24 degrees of freedom; p ≈ 0.189. Not significant at 0.05. Example 2: bolts with a nominal 10 mm diameter, n = 49, x̄ = 10.3 mm, known σ = 0.7 mm, two-tailed z-test. z = 0.3 ÷ 0.1 = 3.0; p ≈ 0.0027, so the mean differs from 10 mm at the 1% level. Example 3: the default data with a right-tailed t-test (μ > 50): p ≈ 0.094.
Frequently asked questions
What is the difference between a z-test and a t-test in hypothesis testing?
A z-test is used when the population standard deviation is known or the sample size is large (typically n ≥ 30), because the sampling distribution is well approximated by a normal curve. A t-test is used when the population standard deviation is unknown and the sample is small, relying on the t-distribution which has heavier tails to account for extra uncertainty. As sample size grows, the t-distribution converges to the normal distribution, so the two tests produce nearly identical results for large n. In practice, the t-test is safer when in doubt.
How do I interpret the p-value from a hypothesis test?
It is the probability of getting a test statistic at least as extreme as yours if the null hypothesis is true. A p-value of 0.03 means such a result would occur about 3% of the time by chance alone when μ really equals μ₀. It is not the probability that H₀ is true. The 0.05 cut-off is a convention; report the exact p-value.
What does it mean when a hypothesis test result is statistically significant?
Statistical significance means the test statistic exceeds the critical threshold for your chosen significance level, suggesting the observed difference is unlikely due to random sampling variation alone. It does not necessarily mean the difference is practically important or large. A study with a very large sample can detect tiny, trivial differences as statistically significant. Always pair significance with effect size measures (like Cohen's d) and confidence intervals to judge whether a finding has real-world relevance.
Related calculators
Sources & references
Think a result is wrong? Report a problem with this calculator.