Calculator
Enter your data to get the test statistic (z or t), p-value and test decision.
Explanation
This test is used when you want to check whether the population mean equals a reference value \(\mu_0\). It is one of the most widely used procedures in process control, biomedical research, education and business analytics, because it lets you test a specific claim against quantitative evidence.
In practice there are two scenarios: if you know the population standard deviation \(\sigma\), you use a z-test; if \(\sigma\) is unknown and is estimated with the sample standard deviation \(s\), you use a Student's t-test. This distinction matters because it reflects the extra uncertainty introduced when estimating variability from the sample itself.
Hypotheses and test statistic
\(H_0: \mu = \mu_0\)
\(H_1: \mu \neq \mu_0\), \(\mu > \mu_0\) or \(\mu < \mu_0\)
If \(\sigma\) is known: \( z = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}} \)
If \(\sigma\) is unknown: \( t = \frac{\bar{x} - \mu_0}{s / \sqrt{n}} \), with \(df=n-1\)
- \(\bar{x}\): sample mean.
- \(\mu_0\): mean stated in the null hypothesis.
- \(\sigma\): population standard deviation (if known).
- \(s\): sample standard deviation (if \(\sigma\) is unknown).
- \(n\): sample size.
Quick check
- If the p-value is less than \(\alpha\), \(H_0\) is rejected.
- If the p-value is greater than or equal to \(\alpha\), there isn't enough evidence to reject \(H_0\).
- A non-significant result does not prove that \(H_0\) is true.
Why are there two formulas for this test?
z-test: used when the population \(\sigma\) is known. The statistic follows a standard normal distribution under \(H_0\).
t-test: used when \(\sigma\) is unknown and is replaced by \(s\). That extra uncertainty is modeled with Student's t distribution with \(n-1\) degrees of freedom.
As \(n\) grows, the t distribution gets very close to the normal, which is why both methods converge for large samples.
Worked example
A factory claims that its machine produces parts with an average weight of \(\mu_0 = 500\) g. To verify this, an inspector takes a sample of \(n = 25\) parts and obtains \(\bar{x} = 497\) g and sample standard deviation \(s = 8\) g. The goal is to test whether the mean weight differs significantly from 500 g with \(\alpha = 0.05\) (two-tailed).
The hypotheses are \(H_0\colon \mu = 500\) versus \(H_1\colon \mu \neq 500\). Since \(\sigma\) is unknown, the Student's t statistic is used with \(df = n - 1 = 24\) degrees of freedom:
\( t = \dfrac{\bar{x} - \mu_0}{s/\sqrt{n}} = \dfrac{497 - 500}{8/\sqrt{25}} = \dfrac{-3}{1.6} = -1.875 \)
For a two-tailed test with \(\alpha = 0.05\) and 24 degrees of freedom, the critical value is \(t_{0.025,\,24} \approx 2.064\). Since \(|t| = 1.875 < 2.064\), the statistic does not fall in the rejection region.
The p-value associated with the two-tailed test is \(p \approx 0.073\). Since \(p = 0.073 > \alpha = 0.05\), \(H_0\) is not rejected.
Conclusion: with the available data there is not enough evidence to claim that the mean weight departs from 500 g at the 5% significance level. The machine may be correctly calibrated.
How to interpret the result
Rejecting \(H_0\) (p-value < α) means that, if the population mean were really \(\mu_0\), it would be very unlikely to have observed a sample value as far off as the one obtained. It is concluded that there is statistical evidence that \(\mu \neq \mu_0\) (or > / <, depending on the chosen alternative). However, rejecting \(H_0\) does not mean the difference is large or important: with very large samples even a difference of a few tenths can turn out to be significant.
Failing to reject \(H_0\) (p-value ≥ α) does not prove that the mean equals \(\mu_0\); it only indicates that the data are compatible with that value at the chosen significance level. Low power — due to a small sample or high variance — can prevent detecting real differences. Before concluding "there is no effect," check the power of the test and the confidence interval.
Regarding the z or t statistic shown by the tool: its magnitude indicates how many standard errors \(\bar{x}\) is away from \(\mu_0\). In the chart, the green zone is the non-rejection region, the red zones are the critical regions and the amber line marks the observed statistic. If the amber line falls in red, p-value < α. To assess practical relevance, always complement the result with the confidence interval for \(\mu\) and the effect size (Cohen's d = \((\bar{x}-\mu_0)/s\)).
Frequently asked questions
- When should I use z and when t? Use z if you know the population \(\sigma\); use t if \(\sigma\) is unknown and you estimate it from the sample.
- What does the p-value represent in this mean test? The probability, under \(H_0\), of observing a result as extreme as the one obtained.
- What is a typical α? Many analyses use 0.05, although 0.01 may be preferred in critical contexts.
- Should I report anything else? Yes: add a confidence interval and an effect size to interpret the practical relevance.
- What is the minimum detectable effect (MDE)? It is the smallest difference from \(\mu_0\) that your study is designed to detect with a given power (for example, 80%) and a fixed significance level \(\alpha\). If the true effect is smaller than the MDE, the test may fail to detect it due to lack of power.
Reference: Student's t-test — Wikipedia