One-Sample t-Test
Interactive t-Test Calculator
Enter your own data for two groups and calculate a t-test! Type comma-separated values for each group, select your alpha level, and click Calculate. The calculator computes the t-statistic, degrees of freedom, and p-value, then tells you whether to reject or fail to reject the null hypothesis.
Testing Against a Known Value
Use one-sample t-test when comparing your sample mean to a known/hypothesized population value. Example: Is the average IQ in my sample different from the population mean of 100?
The t-Statistic
Difference from hypothesized mean
Sample standard deviation
Square root of sample size
The t-statistic measures how many standard errors the sample mean is from the hypothesized value. Larger |t| = more evidence against H₀. df = n - 1.
Worked Example
H₀: μ = 75 | Hₐ: μ ≠ 75 | α: 0.05
t = (79 - 75) / (10 / √25)
t = 4 / 2 = 2.0
df = 25 - 1 = 24
Fail to reject H₀. Not significant at α = 0.05
With t = 2.0 and df = 24, the p-value is 0.057. Since p > 0.05, we fail to reject H₀. There's insufficient evidence that the mean differs from 75 (though it's close!).
When It's Valid
• Independent observations
• Continuous data
• n < 30: Data should be roughly normal
• Check with histogram
Key assumptions: random sample, independence, continuous data. Normality matters less with large samples (n > 30) thanks to the Central Limit Theorem. For small n, check for approximate normality.
Independent Samples t-Test
Comparing Two Groups
Use independent t-test when comparing means of two SEPARATE groups with different participants. Example: Treatment vs. Control, Men vs. Women, Before-group vs. After-group.
The t-Statistic
Difference between group means
Standard error of the difference
The formula looks complex but is conceptually simple: difference in means divided by variability of that difference. Pooled variance combines both groups' variances for a better estimate.
Equal vs. Unequal Variances
Classic t-test assumes equal variances in both groups. If variances differ, use Welch's t-test (doesn't pool variances). Most software defaults to Welch's—it's safer and nearly as powerful.
Cohen's d
Small
Medium
Large
Cohen's d tells you HOW DIFFERENT the groups are in standard deviation units. Unlike p-values, d doesn't depend on sample size. A statistically significant result can have a tiny effect size.
Paired Samples t-Test
Matched or Repeated Measures
Use paired t-test when the SAME subjects are measured twice (before/after), or when subjects are matched in pairs. Each person serves as their own control, reducing variability.
Converting to One-Sample
| Subject | Before | After | Difference |
|---|---|---|---|
| 1 | 65 | 72 | +7 |
| 2 | 70 | 73 | +3 |
| 3 | 58 | 67 | +9 |
The paired t-test is actually a one-sample t-test on the DIFFERENCES. Calculate (After - Before) for each subject, then test if mean difference ≠ 0. This is why it's more powerful—individual differences cancel out.
The t-Statistic
Mean of differences
SD of differences
Number of pairs
Calculate the difference for each pair, then apply one-sample t-test to these differences. We're testing whether the mean difference is significantly different from zero.
Why Paired Tests Are Powerful
• Treatment effect
• Person-to-person differences
• Random error
• Treatment effect
•
• Random error
Paired designs are more powerful because individual differences are removed. If people vary widely in ability, paired tests see only the change within each person, not differences between people.
Choosing the Right Test
Which t-Test?
Compare to known value
Independent t
Paired t
One group → One-sample t. Two different groups → Independent t. Same people twice → Paired t. For 3+ groups, use ANOVA instead of multiple t-tests.
At a Glance
| Test | Question | Example |
|---|---|---|
| One-Sample | Is mean different from X? | IQ ≠ 100? |
| Independent | Do two groups differ? | Treatment vs Control |
| Paired | Did scores change? | Before vs After |
Each t-test answers a specific question about means. Choosing the wrong test gives wrong results. The most common mistake is using independent t when paired is appropriate.
Shared Assumptions
• Random/representative sample
• Independence of observations
• n ≥ 30: CLT makes t-tests robust
• Severely skewed: Consider non-parametric alternative
All t-tests assume continuous data, random sampling, and independence. Normality is important for small samples but t-tests are robust with n > 30. For extreme violations, use Mann-Whitney or Wilcoxon tests.
Real-World Examples
Apply your knowledge to practical scenarios
Blood Pressure Medication Trial
A clinical trial tests whether a new medication lowers blood pressure. 30 patients are measured before and after 8 weeks of treatment. Before: mean = 145 mmHg, SD = 12. After: mean = 138 mmHg, SD = 10. Mean difference: -7 mmHg, SD of differences: 8.
Sample Data
{
"n": 30,
"before_mean": 145,
"after_mean": 138,
"mean_diff": -7,
"sd_diff": 8
}
Key Insights
- Paired designs are powerful because they eliminate between-subject variability
- Always report both statistical significance AND effect size
- Clinical/practical significance may differ from statistical significance
A/B Testing for Website Conversion
An e-commerce company tests two landing page designs. Group A (current design): n = 500, conversion rate = 3.2%, SD = 0.18. Group B (new design): n = 500, conversion rate = 4.1%, SD = 0.20. Is the new design significantly better?
Sample Data
{
"groupA": {
"n": 500,
"mean": 0.032,
"sd": 0.18
},
"groupB": {
"n": 500,
"mean": 0.041,
"sd": 0.2
}
}
Key Insights
- Independent t-test for different groups of people
- Practical significance depends on business context
- Multiple A/B tests require correction for family-wise error rate
Is This School Above Average?
A school district claims their students have above-average IQ. They test n = 50 students, finding x̄ = 104, s = 15. Population mean IQ is known to be μ = 100. Is the school's claim supported?
Sample Data
{
"n": 50,
"sample_mean": 104,
"sample_sd": 15,
"population_mean": 100
}
Key Insights
- One-sample t-test compares a sample to a known value
- Use one-tailed test when direction is predicted in advance
- Statistical significance with n = 50 and 4-point difference is marginal—larger effect would be more convincing
t-Tests Quiz
Test your understanding • Passing score: 70%