Module 09

t-Tests

Comparing means with small samples

Three Types of t-Tests

  • 01

    One-Sample t

    Compare sample mean to known value

  • 02

    Independent t

    Compare means of two groups

  • 03

    Paired t

    Compare means of matched pairs

01

One-Sample t-Test

Interactive t-Test Calculator

t-Test Calculator
Group 1 Mean-
Group 2 Mean-
Difference-
t-statistic-
Degrees of freedom-
p-value-
Enter data and click Calculate

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

Your Sample
x̄ = 105
vs
Known Value
μ₀ = 100
Is x̄ significantly different from μ₀?

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

t = (x̄ - μ₀) / (s / √n)
x̄ - μ₀
Difference from hypothesized mean
s
Sample standard deviation
√n
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

Question: Is average test score different from 75?
Data: n = 25, x̄ = 79, s = 10
H₀: μ = 75 | Hₐ: μ ≠ 75 | α: 0.05
Calculate:
t = (79 - 75) / (10 / √25)
t = 4 / 2 = 2.0
df = 25 - 1 = 24
Result: p = 0.057 > 0.05
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

✓ Required
• Random sample
• Independent observations
• Continuous data
📊 Normality
• n > 30: Not needed (CLT)
• 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.

02

Independent Samples t-Test

Comparing Two Groups

Group A
x̄₁ = 85
vs
Group B
x̄₂ = 78
Different people in each group (between-subjects)

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

t = (x̄₁ - x̄₂) / √(s²pooled/n₁ + s²pooled/n₂)
Where s²pooled combines variance from both groups
Numerator
Difference between group means
Denominator
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

Equal Variances
Use pooled variance (Student's t)
Unequal Variances
Use Welch's t-test

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

d = (x̄₁ - x̄₂) / s_pooled
Difference in terms of standard deviations
|d| = 0.2
Small
|d| = 0.5
Medium
|d| = 0.8
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.

03

Paired Samples t-Test

Matched or Repeated Measures

Time 1
Score: 65
→
Same person
Time 2
Score: 72
Same subjects measured twice (within-subjects)

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

SubjectBeforeAfterDifference
16572+7
27073+3
35867+9
Then: Is mean difference ≠ 0? (One-sample t-test on differences)

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

t = d̄ / (s_d / √n)
d̄
Mean of differences
s_d
SD of differences
n
Number of pairs
df = n - 1 (number of pairs minus 1)

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

Independent t-test
Variability includes:
• Treatment effect
• Person-to-person differences
• Random error
Paired t-test
Variability includes:
• Treatment effect
• Person-to-person differences
• Random error
Each person is their own control → less noise → more power

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.

04

Choosing the Right Test

Which t-Test?

How many groups?
One group
One-Sample t
Compare to known value
Two groups
Same or different people?
Different
Independent t
Same
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

TestQuestionExample
One-SampleIs mean different from X?IQ ≠ 100?
IndependentDo two groups differ?Treatment vs Control
PairedDid 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

✓ All t-Tests Need
• Continuous outcome variable
• Random/representative sample
• Independence of observations
⚠️ Normality
• n < 30: Data should be approximately normal
• 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

01

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
}
Q Should this be analyzed as independent samples or paired? +
A PAIRED—the same patients are measured twice (before and after). Each person serves as their own control, reducing variability from individual differences.
Q Calculate the t-statistic for the paired t-test. +
A t = d̄ / (sd / √n) = -7 / (8 / √30) = -7 / 1.46 = -4.79. This is a large t-value, suggesting a significant drop in blood pressure.
Q With df = 29 and t = -4.79, is this significant at α = 0.05? +
A Yes! Critical t(29) at α = 0.05 (two-tailed) is ±2.045. Since |−4.79| > 2.045, we reject H₀. The medication significantly reduces blood pressure.
Q Calculate Cohen's d for this effect. Is it clinically meaningful? +
A d = mean difference / SD = 7 / 8 = 0.875. This is a large effect (d > 0.8). A 7 mmHg drop is clinically meaningful—it reduces cardiovascular risk.
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
02

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
  }
}
Q Which t-test is appropriate here? +
A Independent samples t-test—different users see different designs. They're not the same people measured twice.
Q The t-test gives p = 0.03. What do you conclude? +
A At α = 0.05, we reject H₀. The new design has a statistically significantly higher conversion rate than the current design.
Q The 0.9% increase (3.2% to 4.1%) seems small. Is it practically significant? +
A It's a 28% relative increase! If your site has 1 million visitors/month, that's 9,000 extra conversions. At $50/conversion, that's $450,000/month. Context matters!
Q What's the risk of running many A/B tests without correction? +
A Multiple testing inflates false positives. Running 20 tests at α = 0.05 expects 1 false positive. Companies should use Bonferroni correction or sequential testing methods.
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
03

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
}
Q What type of t-test is appropriate? +
A One-sample t-test—we're comparing our sample mean to a known population value (μ = 100).
Q Calculate the t-statistic. +
A t = (x̄ - μ₀) / (s / √n) = (104 - 100) / (15 / √50) = 4 / 2.12 = 1.89
Q Should this be one-tailed or two-tailed? +
A One-tailed (right tail)—the school claims 'above average,' predicting a specific direction. H₀: μ ≤ 100, Hₐ: μ > 100.
Q With t(49) = 1.89 and α = 0.05 one-tailed, what's the conclusion? +
A Critical t(49) one-tailed at α = 0.05 is 1.68. Since 1.89 > 1.68, we reject H₀. The school's students have significantly higher IQ than the population average.
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%

0 of 10 answered
Q1 multiple-choice

When should you use a paired t-test instead of an independent t-test?

Explanation: Paired t-test is used when the same subjects are measured twice (before/after, pre/post) or when subjects are matched in pairs. Each subject serves as their own control.
Q2 calculation

Sample: n = 36, x̄ = 52, s = 12. Testing against μ₀ = 48. What is the t-statistic?

Explanation: t = (x̄ - μ₀) / (s / √n) = (52 - 48) / (12 / √36) = 4 / (12/6) = 4 / 2 = 2.0
Q3 multiple-choice

What is the degrees of freedom for a one-sample t-test with n = 25?

Explanation: For a one-sample t-test, df = n - 1 = 25 - 1 = 24. We lose one degree of freedom because we estimate the mean from the sample.
Q4 multiple-choice

What does Welch's t-test do differently from Student's t-test?

Explanation: Welch's t-test doesn't pool variances and doesn't assume equal variances. It's safer and nearly as powerful as Student's t when variances are unequal.
Q5 multiple-choice

Cohen's d = 0.3 for a two-group comparison. This is considered:

Explanation: Cohen's benchmarks: d = 0.2 (small), d = 0.5 (medium), d = 0.8 (large). So d = 0.3 is between small and medium, typically classified as small.
Q6 multiple-choice

A paired t-test is essentially a one-sample t-test on:

Explanation: The paired t-test calculates the difference for each pair, then tests whether the mean difference is significantly different from zero—making it a one-sample t-test on the differences.
Q7 multiple-choice

Why are paired designs more powerful than independent designs?

Explanation: In paired designs, each subject is their own control. Individual differences cancel out, leaving only the effect of the treatment. This reduces noise and increases power to detect effects.
Q8 multiple-choice

For an independent t-test with n₁ = 15 and n₂ = 17, what is df (assuming equal variances)?

Explanation: For independent t-test with equal variances, df = n₁ + n₂ - 2 = 15 + 17 - 2 = 30. We lose one df for each group's mean estimate.
Q9 multiple-choice

What is the main assumption the Central Limit Theorem helps with in t-tests?

Explanation: CLT states that sample means are approximately normal for large n, regardless of population distribution. This means t-tests are robust to non-normality when n > 30.
Q10 multiple-choice

You have 3 groups to compare. What should you NOT do?

Explanation: Running multiple t-tests without correction inflates Type I error rate. With 3 groups, you'd do 3 comparisons, raising family-wise error to ~14%. Use ANOVA instead.

Quiz Results

0 %

← Effect Sizes & Power Next: ANOVA →