01 / 21
?

Comparing Groups
via Simulation

Learn to use randomization and simulated distributions to determine whether a difference between two groups is statistically meaningful.

Math 3

What Does It Mean to Compare Groups?

In statistics, we often collect data from two groups and want to know: is there a real difference between them, or could the difference we see be explained by random chance alone?

Group A
Treatment group: receives new study method
Group B
Control group: uses the traditional method

Key Terms You Need to Know

Statistic
A numerical summary from sample data, such as \(\bar{x}_A - \bar{x}_B\).
Null Hypothesis
The assumption that there is no real difference between groups: \(H_0\).
Simulation
Randomly reshuffling data many times to build a distribution of differences under \(H_0\).

Why Use Simulation?

Traditional formulas (like the two-sample \(t\)-test) require assumptions about normality and equal variances. Simulation-based inference works even when those assumptions are shaky.

Formula-Based
Requires large samples, normality, and known distributions
Simulation-Based
Works for any sample size and any shape of data: just reshuffle and count

The Core Idea: Randomization Test

Under the null hypothesis \(H_0\): the group labels don't matter. If that's true, we can randomly reassign labels and recalculate the difference. Repeat this many times to build a null distribution.

Simulated Difference in Means -6 -3 0 3 6 Observed: 4.8 Null Distribution (1000 simulated reshufflings)

Understanding the \(p\)-value

The \(p\)-value is the proportion of simulated differences that are at least as extreme as the observed difference. It answers: "How surprising is my result if there's truly no difference?"

Small \(p\)-value
\(p < 0.05\): the observed difference is unlikely due to chance. Evidence of a real effect.
Large \(p\)-value
\(p \ge 0.05\): the observed difference could easily happen by chance. Not enough evidence.

Statistical vs. Practical Significance

Statistical Significance Practical Significance
Question Is the difference real (not just chance)? Is the difference large enough to matter?
Measured by \(p\)-value Effect size, context
Example \(p = 0.02\): unlikely due to chance Difference of 0.3 points on a 100-point test
Verdict Statistically significant Practically meaningless

Step-by-Step: Randomization Test

1
State hypotheses. \(H_0\): no difference between groups. \(H_a\): there is a difference.
2
Calculate observed statistic. Find \(\bar{x}_A - \bar{x}_B\) from your actual data.
3
Simulate under \(H_0\). Pool all data, randomly assign to two groups, compute the difference. Repeat 1000+ times.
4
Find the \(p\)-value. Count how many simulated differences are as extreme as (or more extreme than) the observed.
5
Make a decision. If \(p < 0.05\), reject \(H_0\): the difference is statistically significant.

Example 1: Sleep Study

A researcher splits 20 students into two groups. Group A sleeps 8 hours; Group B sleeps 6 hours. Test scores are recorded. The observed difference in means is \(\bar{x}_A - \bar{x}_B = 5.2\) points.

Group A (8 hrs) n = 10 \(\bar{x} = 82.1\) Group B (6 hrs) n = 10 \(\bar{x} = 76.9\)

Example 1: Running the Simulation

We pool all 20 scores, randomly split them into two groups of 10, and compute the difference. After 1000 reshufflings, we get a null distribution.

Simulated Difference -8 -6 -4 -2 0 2 4 6 8 Observed: 5.2 p = 0.018

Example 2: Fertilizer Experiment

A farmer tests two fertilizers on 30 identical plots (15 per fertilizer). He measures crop yield in kg. The observed difference in mean yield is \(\bar{x}_A - \bar{x}_B = 1.4\) kg.

Fertilizer A n = 15 \(\bar{x} = 24.7 \text{ kg}\) Fertilizer B n = 15 \(\bar{x} = 23.3 \text{ kg}\)

Example 2: Simulation Result

Simulated Difference (kg) -4 -2 0 2 4 Observed: 1.4 p = 0.21

Example 3: Two-Sided Test

A teacher compares two class sections' quiz scores. Observed difference: \(\bar{x}_1 - \bar{x}_2 = -3.6\). In a two-sided test, we check both tails: differences \(\le -3.6\) or \(\ge 3.6\).

Simulated Difference -6 -3 0 3 6 -3.6 +3.6 Two-sided p = 0.034

One-Sided vs. Two-Sided Tests

One-Sided Two-Sided
\(H_a\) \(\bar{x}_A > \bar{x}_B\) or \(\bar{x}_A < \bar{x}_B\) \(\bar{x}_A \neq \bar{x}_B\)
Counts One tail only Both tails combined
Easier to reject? Yes: smaller \(p\) No: \(p\) is roughly doubled
When to use You have a directional prediction before seeing data You just want to know if groups differ

Common Mistakes to Avoid

✕ Confusing \(p\)-value meaning
The \(p\)-value is not the probability that \(H_0\) is true. It's the probability of seeing data this extreme if \(H_0\) were true.
✕ Too few simulations
Using only 50 or 100 reshufflings gives an unstable \(p\)-value. Use at least 1000 simulations for reliable results.
✕ Ignoring practical significance
A tiny difference can be statistically significant with large samples. Always ask: does this difference matter in context?

Summary: Decision Framework

Scenario \(p\)-value Conclusion
Sleep study \(0.018\) Reject \(H_0\): meaningful
Fertilizer test \(0.21\) Fail to reject \(H_0\): no evidence
Quiz sections (two-sided) \(0.034\) Reject \(H_0\): meaningful

Question 1 of 5

In a randomization test, what does the null hypothesis \(H_0\) assume?

Question 2 of 5

A simulation produces 1000 reshuffled differences. Of these, 42 are at least as extreme as the observed difference. What is the \(p\)-value?

Question 3 of 5

A researcher finds \(p = 0.12\). Using a significance level of \(\alpha = 0.05\), what should they conclude?

Question 4 of 5

Why is it important to use at least 1000 simulations rather than just 50?

Question 5 of 5

A study with 10,000 participants finds a difference of 0.2 points on a 100-point scale, with \(p = 0.001\). What is the best interpretation?