A two-point difference can be a big deal or ordinary sampling noise. The t statistic compares that difference with the estimated uncertainty in the sample mean.
Start with a runnable example
from math import sqrt
mean, null_mean, sample_sd, n = 52, 50, 4, 16
standard_error = sample_sd / sqrt(n)
t = (mean - null_mean) / standard_error
print(standard_error, t, n - 1) # 1.0 2.0 15
The code computes a statistic, not a p-value. Here t = 2 with 15 degrees of freedom gives a two-sided p-value of about 0.064. An exact one-sample t test assumes independent normal observations; approximate use needs care with small samples, skew and outliers. The estimated standard deviation must be positive. A threshold decision also says nothing by itself about practical importance.
Fictional student scene: In a bustling campus cafe, Sam triumphantly declares that his newly modified electric kettle saves precious study time because one cup boiled an observable fraction of a second faster. When his lab partner, Maya, calmly asks to see more measurements and checks for ambient water temperature variations, Sam crosses his arms and calls her skepticism an attack on innovation. Maya sighs, knowing that a single observation cannot establish the claimed improvement.
The core idea: Signal versus noise
A one-sample t-test is designed precisely to resolve disputes like Sam's. It compares a population mean, denoted by the Greek letter μ, with a specified hypothesized value (represented as μ₀) when the population standard deviation (σ) is completely unknown. Instead of relying on a single trial, we gather a sample of observations to calculate an observed mean difference (sample mean minus hypothesized mean) and scale it against our estimated uncertainty—known as the estimated standard error.
In notation, the test statistic is calculated as t = (x̄ - μ₀) / (s / sqrt(n)), where x̄ is the sample mean, s is the sample standard deviation, and n is the sample size. The same difference gives stronger evidence when the estimated sampling uncertainty is smaller. Note that this is one specific flavor of hypothesis testing; paired designs and independent-group designs require entirely different experimental layouts and formulas.
Follow the numbers
Let us examine Sam's boiling time experiment after Maya convinced him to collect a proper dataset. Suppose Sam records 25 independent observations, so n = 25. He finds a sample mean boiling time of x̄ = 52 seconds, with a sample standard deviation of s = 10 seconds. He wants to test the null hypothesis H₀: μ = 50 against the two-sided alternative hypothesis H₁: μ not equal to 50 at a prechosen significance level of α = 0.05.
First, we compute the estimated standard error, which measures how much sample means are expected to fluctuate purely by chance. The formula is s / sqrt(n). Plugging in our numbers gives 10 / sqrt(25) = 10 / 5 = 2. Next, we calculate the t-statistic: t = (52 - 50) / 2 = 2 / 2 = 1. This tells us that Sam's observed sample mean is exactly 1 estimated standard error above the hypothesized population mean of 50.
With n = 25, our degrees of freedom are df = n - 1 = 25 - 1 = 24. A two-sided p-value uses both tails of a Student's t-distribution with 24 degrees of freedom. For t = 1, the resulting two-sided p-value is approximately 0.327. Because 0.327 is substantially larger than our significance threshold of 0.05, we fail to reject the null hypothesis. There is insufficient statistical evidence to claim the true mean boiling time differs from 50 seconds.
Assumptions come before the p-value
For the exact one-sample t reference distribution, assume an independent random sample from a normal population with finite, positive variance. The numerical examples use this teaching model. Larger samples can support approximations, but dependence, severe outliers, selection bias and strongly skewed small samples require care. Repeated tests of the same network or kettle may be dependent; collecting more rows is not the same as collecting independent information.
Try another example
Consider a second scenario involving a different batch of measurements. Suppose a researcher studies campus internet download speeds. A historical baseline states the average speed is μ₀ = 100 megabits per second. The researcher collects a sample of n = 16 connection tests, yielding a sample mean of x̄ = 94 megabits per second and a sample standard deviation of s = 12 megabits per second. We wish to test H₀: μ = 100 versus H₁: μ not equal to 100 at a 0.05 significance level.
We calculate the estimated standard error: s / sqrt(n) = 12 / sqrt(16) = 12 / 4 = 3. Then, we compute the t-statistic: t = (x̄ - μ₀) / SE = (94 - 100) / 3 = -6 / 3 = -2. The degrees of freedom are df = 16 - 1 = 15. Looking up a t-distribution with 15 degrees of freedom, the two-sided p-value for a magnitude of 2 or more extreme is approximately 0.064. Since 0.064 is greater than 0.05, we again fail to reject the null hypothesis at the 5 percent level, though the evidence is closer to conventional thresholds.
Three common mistakes to avoid
Interpreting hypothesis tests requires discipline. Avoid these frequent pitfalls:
- Equating failing to reject with proving the null: Failing to reject H₀ never proves that μ equals the hypothesized value. It simply means our data lack the statistical power or clarity to rule it out. Absence of evidence is not evidence of absence.
- Reusing old reference distributions: Changing your sample size alters your degrees of freedom (df = n - 1), which alters the shape of the t-distribution. If n changes from 25 to 100, you cannot reuse critical values or p-value calculations from the old distribution.
- Confusing statistical significance with practical importance: A tiny deviation can yield a massive t-statistic and a tiny p-value if your sample size is gigantic, even if the real-world difference is trivial. Conversely, a large, important difference might fail to reach significance in a tiny sample.
Try it yourself, then check
Test your understanding with these practice problems:
- Exercise 1: Keep the sample mean at x̄ = 52 and sample standard deviation at s = 10, but increase the sample size from n = 25 to n = 100. What happens to the t-statistic and degrees of freedom? Answer: The standard error falls from 10 / sqrt(25) = 2 down to 10 / sqrt(100) = 1. Consequently, the t-statistic doubles from (52 - 50) / 2 = 1 to (52 - 50) / 1 = 2. The degrees of freedom increase from 24 to 99.
- Exercise 2: Suppose n = 9, x̄ = 48, s = 6, and we test H₀: μ = 50. Compute the t-statistic and degrees of freedom. Answer: The standard error is 6 / sqrt(9) = 6 / 3 = 2. The t-statistic is (48 - 50) / 2 = -2 / 2 = -1. The degrees of freedom are 9 - 1 = 8.
- Exercise 3: If a one-sample t-test yields a p-value of 0.012 at a prechosen significance level of α = 0.05, what is the correct statistical decision? Answer: Since the p-value (0.012) is less than the significance level (0.05), we reject the null hypothesis in favor of the alternative hypothesis.
Sources and further reading
For additional foundational reading and worked problems, consult the linked open learning reference. The worked examples presented throughout this guide are original teaching examples designed to illustrate core principles without relying on empirical human measurements.
We are building Matheria for calculation, organized study, and learning resources. Explore Matheria. Which step of the standard error calculation should we break down further in a follow-up? Leave a specific question.
Editorial note: Prepared with AI assistance and discussed with Gemini before publication. Student scenes and datasets are fictional unless stated otherwise. The cover is AI-generated conceptual artwork, not experimental evidence.
References for implementation: https://docs.python.org/3/library/statistics.html and https://numpy.org/doc/stable/reference/generated/numpy.linalg.cond.html
Top comments (0)