One-Sample t-test
One-Sample t-test
Definition
Core Statement
The One-Sample t-test determines whether the sample mean is statistically different from a known or hypothesized population mean (
Purpose
- Quality Control: Does the average weight of bags produced equal the target (e.g., 500g)?
- Benchmarking: Does our school's average score differ from the national average?
- Difference Scores: Testing if the average difference (Pre - Post) is non-zero (Paired t-test is technically a one-sample test on differences).
When to Use
Use When...
- You have one group of continuous data.
- You want to compare the mean to a specific value (
). - Population Deviation (
) is Unknown (use from sample). (if , t converges to z, but t-test is still safe).
Assumptions
Worked Example: Potato Chips
Problem
Bags of chips claim to hold 200g (
You sample 10 bags: Mean = 195g, StDev = 5g.
- Calculate SE:
. - Calculate t:
- Decision:
- Degrees of freedom =
. - Critical t (
, two-tailed) . . Reject Null.
- Degrees of freedom =
Conclusion: The bags are significantly underfilled.
Python Implementation
import scipy.stats as stats
data = [198, 195, 202, 190, 194, 199, 195, 192, 196, 189]
mu_0 = 200
t_stat, p_val = stats.ttest_1samp(data, popmean=mu_0)
print(f"T-statistic: {t_stat:.3f}")
print(f"P-value: {p_val:.4f}")
if p_val < 0.05:
print("Reject Null: Mean is different from 200.")
Related Concepts
- Student's T-Test - The two-sample version.
- Z-Test - Used if
is known. - Confidence Intervals - The interval version of this test.