Introduction
The One-Sample T-Test is a parametric statistical procedure used to determine whether the mean of a single sample () is statistically different from a known or hypothesized population mean ().
This test bridges the gap between your specific observations and the "truth" you are comparing them against. Unlike the Z-test, which requires knowing the true population standard deviation (), the T-test is robust because it uses the sample standard deviation () as an estimate. This makes it the standard tool for real-world analysis where population parameters are almost never known.
Real-World Scenarios
- Quality Control: A factory claims its protein bars contain 20g of protein. You collect a random sample of 31 bars. Is the average really 20g, or are they systematically underfilling (or overfilling)?
- Healthcare: A hospital wants to know if the average cholesterol level of a specific patient group differs from the national health goal of 200 mg/dL.
- Environmental Safety: An inspector needs to verify if the lead levels in an apartment building exceed the EPA safety clearance level of 10 micrograms per square foot.
When to Use This Test
You should use a One-Sample T-Test when you meet specific criteria. It is not a catch-all for every mean comparison problem.
You HAVE
- A single continuous variable (e.g., weight, time, height, pH level).
- A known "Test Value" or hypothesized mean () to compare against. This could be a legal standard, an industry benchmark, or a historical average.
You Do NOT Have
- Two separate groups of people (Use Independent Samples T-Test).
- The same people measured twice (Use Paired Samples T-Test).
- More than two groups (Use ANOVA).
- Categorical data (Use Chi-Square).
Crucial Assumptions
For the results of a t-test to be valid, your data must adhere to four key assumptions. Violating these can lead to incorrect conclusions (false positives or false negatives).
1. Independence
The value of one observation does not influence another. For example, measuring the weight of 30 different people is independent. Measuring the weight of the same person 30 times is dependent (not allowed).
2. Continuous Data
The variable must be interval or ratio level (e.g., grams, seconds, height). Categorical variables (e.g., "Yes/No", "High/Low") cannot be used here.
3. Random Sampling
The data should be obtained via a simple random sample from the population to avoid selection bias. If you only pick the heaviest protein bars, your result will be biased high.
4. Normality
The population from which the sample is drawn should be approximately normally distributed.
Note: The t-test is "robust" to violations of normality if the sample size is large () thanks to the Central Limit Theorem. For small samples (), normality is critical.
Setting up Hypotheses
Before calculating anything, you must define your null () and alternative ( or ) hypotheses. This dictates whether you perform a one-tailed or two-tailed test.
| Test Type | Question Asked | Null Hypothesis () | Alternative Hypothesis () |
|---|---|---|---|
| Two-Tailed | Is the mean different from ? | ||
| Right-Tailed | Is the mean greater than ? | ||
| Left-Tailed | Is the mean less than ? |
Example: For the protein bars (Label = 20g), we usually care if it's different in *either* direction, so we use a Two-Tailed test. , .
The T-Statistic Formula
The t-statistic essentially measures "how many standard errors away from the hypothetical mean is our sample mean?".
The Signal (Numerator)
The actual difference between your sample mean and the hypothesized population mean.
The Noise (Denominator)
The Standard Error. This estimates how much sample means fluctuate naturally.
Prerequisite
If the concepts of Standard Error or T-distribution feel unfamiliar, review the Sampling Distributions chapter first. It includes interactive visualizations that build intuition for why we use instead of .
Manual Calculation Example
Let us walk through the calculation manually, step-by-step, using the Protein Bar example.
The Scenario
- Claim (Hypothesis): Protein bars have 20g of protein.
- Sample Data: We collected bars.
- Sample Mean (): Calculated average is 21.40g.
- Sample Std Dev (): Calculated standard deviation is 2.54g.
- Significance Level (): 0.05 (5% risk).
Step 1: Calculate the Difference (Signal)
Step 2: Calculate Standard Error (Noise)
Step 3: Calculate t-Statistic
Our sample mean is 3.07 standard errors away from the hypothesized mean.
Step 4: Determine Critical Value & Decision
Degrees of Freedom (df):
Look up in a t-table (two-tailed). The critical value is approximately 2.042.
Comparison:
vs
Since , our result is in the "rejection region."
Conclusion: Reject . The protein bars likely do NOT contain 20g of protein (they contain significantly more).
Interactive Demo: T-Test Calculator
Adjust the sample statistics and see the t-statistic calculation and decision in real-time. Watch how the t-value changes position on the distribution curve.
Interactive T-Test Calculator
Adjust your sample statistics and see how the t-statistic is calculated and whether you reject the null hypothesis.
Step-by-Step Calculation
Interpreting Results (P-Value)
In modern analysis (using software like JMP, SPSS, or Python), we rely more on the P-Value than manually comparing t-statistics to critical values.
The P-Value Logic
The P-value answers: "If the true mean was actually 20g, what is the probability of randomly picking a sample with a mean of 21.4g (or more extreme)?"
For our energy bar example, software calculates a p-value of 0.0046. This means there is only a 0.46% chance of seeing this data if the labels were correct. That is strong evidence that the labels are wrong.
Checking Normality
Before trusting your t-test, you should visualize your data to check if the normality assumption holds.
1. Histogram
Look for a bell shape. It does not need to be perfect, but it should not be heavily skewed or have massive outliers.
"Is the distribution roughly symmetric and mound-shaped?"
2. Q-Q Plot (Quantile-Quantile)
Points should roughly follow a straight diagonal line. If they curve significantly, the data might not be normal.
"Do the sample quantiles match theoretical normal quantiles?"
What if data is not normal?
If sample size is small () and data is skewed, the t-test is invalid. You should use a Non-Parametric test like the Wilcoxon Signed-Rank Test instead.
Interactive Demo: Normality Diagnostics
Explore how different data distributions appear in histogram and Q-Q plots. Learn to visually diagnose normality violations.
Normality Check: Visual Diagnostics
Select different data distributions to see how histogram and Q-Q plots help diagnose normality violations.
Histogram
Bell-shaped distribution ✓
Q-Q Plot
Points follow diagonal line ✓
Assessment
Data appears approximately normal. T-test is valid.