Hypothesis Testing with t-Tests
Master one-sample and two-sample t-tests for comparing means when population variance is unknown
Try these examples:
Hypothesis Testing with -Tests
The -test compares population means when is unknown and must be estimated from the sample. Pick a test type, enter your data, and watch the decision update live.
Test Type
One-Sample -Test
Compares a sample mean to a hypothesized value .
Hypotheses:
-
100
Sample data:
-
105 -
15 -
25
Test Statistic
Statistical Decision
t-Distribution with Test Statistic
Two-sided at
Result
Fail to reject . Insufficient evidence at
Assumptions Check
The one-sample -test requires:
- Random sampling
- Normality (or large via CLT -- drag
25 above 30 for safety) - Independent observations
If normality is suspect with small , consider a nonparametric alternative (e.g., Wilcoxon signed-rank).
Effect Size (Cohen's )
Statistical significance depends on sample size; effect size measures practical importance independently.
Small (). A real but modest difference. Increase
| Benchmark | | |-----------|-------| | Small | 0.2 | | Medium | 0.5 | | Large | 0.8 |
Try it in Code
# One-sample and two-sample t-tests
from scipy import stats
import math
# One-sample t-test
x_bar, s, n, mu0 = 105, 15, 25, 100
se = s / math.sqrt(n)
t_stat = (x_bar - mu0) / se
p_val = 2 * stats.t.sf(abs(t_stat), df=n - 1)
print(f"One-sample t-test:\n t = {t_stat:.4f}, df = {n - 1}, p = {p_val:.4f}")
# Two-sample Welch's t-test
x2, s2, n2 = 98, 12, 30
se_w = math.sqrt(s**2 / n + s2**2 / n2)
t_welch = (x_bar - x2) / se_w
print(f"Welch two-sample t:\n t = {t_welch:.4f}")What to explore next
One-Way ANOVA
Compare means across multiple groups using Analysis of Variance
Understanding Bayes' Theorem
Explore how prior beliefs update with new evidence
Bayesian Inference
Explore how prior beliefs combine with observed data to form posterior distributions using Bayes' theorem
Bootstrap Confidence Intervals
Learn how resampling provides confidence intervals without parametric assumptions
You might also like
Chi-Square Goodness of Fit Test
ExplorationTest whether observed frequencies match expected frequencies using the chi-square goodness of fit test
Hypothesis Testing Explorer
ExplorationVisualize and understand hypothesis testing with the one-sample z-test
Maximum Likelihood Estimation
ExplorationLearn how to find the parameter values that make observed data most probable using the likelihood function
One-Way ANOVA
ExplorationCompare means across multiple groups using Analysis of Variance