What Is the One‑Sample t‑Test?
The one‑sample t‑test (also known as the Student's t‑test) is a statistical procedure used to determine whether the mean of a single population differs from a known or hypothesized value (μ₀). It is one of the most fundamental and widely used hypothesis tests in statistics, applicable in fields ranging from psychology and medicine to engineering and economics.
The test statistic is given by:
t = (x̄ − μ₀) / (s / √n)
where x̄ is the sample mean, s is the sample standard deviation, and n is the sample size.
The t‑statistic follows a Student's t‑distribution with df = n − 1 degrees of freedom under the null hypothesis. The p‑value is derived from this distribution and indicates the probability of observing a t‑statistic as extreme as the one computed, assuming the null hypothesis is true.
Why Use This Interactive t‑Test Calculator?
-
Educational Clarity: Visualize the t‑distribution, see how the test statistic relates to critical regions, and understand the impact of sample size and variability.
-
Research Ready: Obtain p‑values, confidence intervals, and effect sizes (Cohen's d) for publication‑ready reporting.
-
Flexible Input: Enter raw data directly or use summary statistics — perfect for quick checks or when raw data are unavailable.
-
Interactive Graph: The t‑distribution curve updates in real time, showing your t‑statistic, critical regions, and confidence interval bounds. Hover over the curve to read exact coordinates.
Mathematical Derivation
The one‑sample t‑test is derived from the sampling distribution of the sample mean. When the population standard deviation is unknown (which is almost always the case), we estimate it using the sample standard deviation s. The standardized statistic follows a t‑distribution with n − 1 degrees of freedom.
The null hypothesis (H₀) is that the population mean μ equals the hypothesized value μ₀. The alternative hypothesis (H₁) can be two‑tailed (μ ≠ μ₀), left‑tailed (μ < μ₀), or right‑tailed (μ > μ₀).
The confidence interval for the population mean is given by:
x̄ ± tα/2, df · (s / √n)
where tα/2, df is the critical value from the t‑distribution with df degrees of freedom.
Cohen's d effect size is computed as:
d = (x̄ − μ₀) / s
This provides a standardized measure of the magnitude of the difference, independent of sample size.
Step‑by‑Step Workflow
-
Choose between Raw Data (enter your observations) or Summary Statistics (enter mean, SD, and n).
-
Specify the hypothesized population mean (μ₀) you want to test against.
-
Select your significance level (α) — common choices are 0.05, 0.01, and 0.10.
-
Choose the alternative hypothesis direction: two‑tailed, left‑tailed, or right‑tailed.
-
Click Run t‑Test to compute all statistics and generate the interactive graph.
-
Interpret the results: examine the p‑value, confidence interval, and effect size to draw conclusions.
Example Datasets & Interpretation
Each example below is pre‑loaded and ready to run. Click any preset to populate the fields and instantly see the analysis.
|
Example
|
Context
|
Hypothesized Mean (μ₀)
|
t‑Statistic
|
p‑Value (two‑tailed)
|
Interpretation
|
|
Exam Scores
|
Student test scores: [78, 82, 79, 85, 81, 83, 77, 80, 84, 82]
|
80
|
0.95
|
0.37
|
No significant difference from μ₀ = 80
|
|
Product Weights
|
Package weights (g): [102, 98, 101, 99, 103, 100, 97, 102, 99, 101]
|
100
|
1.20
|
0.26
|
No significant difference from μ₀ = 100g
|
|
Reaction Times
|
Reaction times (ms): [210, 215, 208, 220, 205, 212, 218, 207, 213, 209]
|
200
|
5.80
|
< 0.001
|
Significant difference — mean reaction time is higher than 200 ms
|
|
Lab Measurements
|
pH readings: [7.02, 7.05, 6.98, 7.00, 7.03, 6.97, 7.01, 7.04, 6.99, 7.02]
|
7.00
|
1.85
|
0.097
|
Marginally significant at α=0.10, not at α=0.05
|
Case Study: Clinical Trial on Blood Pressure
A pharmaceutical company conducts a clinical trial to test whether a new drug reduces systolic blood pressure. The known population mean for untreated patients is 140 mmHg. A sample of 25 patients treated with the drug shows a mean of 132 mmHg with a standard deviation of 15 mmHg.
Using a one‑sample t‑test with μ₀ = 140, we obtain t = (132 − 140) / (15/√25) = −8 / 3 = −2.667. With df = 24, the two‑tailed p‑value is approximately 0.013. At α = 0.05, we reject H₀ and conclude that the drug significantly reduces blood pressure. The effect size (Cohen's d) is −0.533, indicating a moderate to large effect. The 95% confidence interval for the mean is [125.8, 138.2], which does not contain 140.
This example illustrates how the t‑test can provide evidence for treatment efficacy, guiding regulatory decisions and clinical practice.
Common Misconceptions & Clarifications
-
The t‑test assumes normality: The test is robust to moderate departures from normality, especially with larger sample sizes (n ≥ 30). For small samples, consider using a non‑parametric alternative like the Wilcoxon signed‑rank test if normality is severely violated.
-
p‑value is not the probability that H₀ is true: The p‑value is the probability of observing data as extreme as yours, assuming H₀ is true. It does not directly tell you the probability that H₀ is correct.
-
Significance does not imply practical importance: A statistically significant result may have a small effect size (e.g., d = 0.1) that is not practically meaningful. Always interpret effect sizes alongside p‑values.
-
Confidence intervals are more informative than p‑values: A confidence interval provides a range of plausible values for the population mean, giving a better sense of precision and practical significance.
Applications Across Disciplines
-
Medicine & Public Health: Compare patient outcomes against established benchmarks (e.g., blood pressure, cholesterol levels).
-
Education: Evaluate whether student test scores differ from a district‑wide average.
-
Manufacturing: Test whether product dimensions meet specifications (e.g., diameter, weight, thickness).
-
Psychology: Assess whether reaction times or survey scores deviate from population norms.
-
Environmental Science: Determine if pollutant concentrations exceed regulatory thresholds.
-
Finance: Test whether average portfolio returns differ from a benchmark index.
Rooted in statistical theory – This tool is built on the foundational work of William Sealy Gosset ("Student"), who developed the t‑test in 1908 while working at the Guinness Brewery. The implementation follows standard statistical methods documented in authoritative texts such as Statistical Inference by Casella & Berger, Introduction to the Practice of Statistics by Moore, McCabe, & Craig, and the NIST/SEMATECH e‑Handbook of Statistical Methods. The interactive visualization uses Canvas rendering for real‑time feedback. Reviewed by the GetZenQuery statistics team, last updated June 2026.
Frequently Asked Questions
The z‑test is used when the population standard deviation is known, while the t‑test is used when it is estimated from the sample. The t‑test is more conservative (wider confidence intervals) and is the appropriate choice in most real‑world applications where the population SD is unknown.
Use a two‑tailed test when you are interested in deviations in either direction (μ ≠ μ₀). Use a one‑tailed test when you have a directional hypothesis (μ > μ₀ or μ < μ₀). The choice should be made before collecting data, based on the research question.
While there is no universal minimum, a sample size of at least 20–30 is generally recommended for the t‑test to be robust to non‑normality. For very small samples (n < 10), the normality assumption becomes more critical, and you may want to consider non‑parametric alternatives.
Cohen's d is a standardized effect size. Conventional thresholds are: d = 0.2 (small effect), d = 0.5 (medium effect), and d = 0.8 (large effect). However, these are guidelines — the practical significance depends on the specific context and domain.
The t‑test is reasonably robust to violations of normality, especially for larger sample sizes. If you have serious concerns about normality, consider using a non‑parametric test like the Wilcoxon signed‑rank test, which does not assume a normal distribution.