from edumath.statistics import difference_standard_error
difference_standard_error(10, 25, 12, 36)2.8284271247461903
Many statistical questions compare groups: treatment versus control, before versus after, city A versus city B, or two manufacturing processes. The key is to compare the groups in a way that respects the study design.
After this lesson you should be able to:
A group comparison usually has:
Examples:
| Question | Response | Groups |
|---|---|---|
| Do two study methods lead to different exam scores? | exam score | method A, method B |
| Did blood pressure change after treatment? | blood pressure | before, after |
| Are support rates different in two cities? | yes/no support | city 1, city 2 |
Samples are paired when observations are naturally linked.
Examples:
For paired data, analyze the within-pair differences.
Samples are independent when observations in one group are not matched to specific observations in the other group.
Examples:
When comparing two means, the estimate is often:
sample mean 1 - sample mean 2
When comparing two proportions, the estimate is:
sample proportion 1 - sample proportion 2
The sign matters. A positive difference means group 1 is larger using that order.
For independent means, a common standard error form is:
SE difference = sqrt(s1^2/n1 + s2^2/n2)
The idea is that uncertainty from both groups contributes to the uncertainty of the difference.
A difference can be statistically significant but practically small. Always ask:
Group A has mean 82, standard deviation 10, and sample size 25. Group B has mean 76, standard deviation 12, and sample size 36.
Step 1: Compute the difference.
difference = 82 - 76 = 6
Group A’s mean is 6 points higher.
Step 2: Compute standard error.
SE = sqrt(10^2/25 + 12^2/36)
SE = sqrt(100/25 + 144/36)
SE = sqrt(4 + 4)
SE = sqrt(8), about 2.83
Step 3: Interpret.
The observed difference is about 6/2.83 = 2.12 standard errors from zero. That may be evidence of a real difference, but a full test also requires conditions and a p-value or interval.
Five students take a pre-test and post-test. Their improvements are:
3, 5, -1, 4, 2
Step 1: Analyze differences, not two unrelated groups.
The data are paired because each student has both measurements.
Step 2: Compute the mean improvement.
mean improvement = (3 + 5 - 1 + 4 + 2) / 5 = 13/5 = 2.6
Interpretation: The average improvement in this sample is 2.6 points.
In City A, 120 of 200 sampled residents support a policy. In City B, 90 of 180 sampled residents support it.
Step 1: Compute sample proportions.
p-hat A = 120/200 = 0.60
p-hat B = 90/180 = 0.50
Step 2: Compute the difference.
0.60 - 0.50 = 0.10
Interpretation: City A’s sample support is 10 percentage points higher. That difference is an estimate; uncertainty must be considered before making a strong conclusion.
30 and group B mean is 24, compute A - B.0.1 points with p-value 0.001, what question should you ask about practical importance?30 - 24 = 6.0.1 points is large enough to matter in the real context.Guess first. A person rates pain before and after taking a medicine. Paired or independent?
Guided exercise.
Paired, because the two measurements belong to the same person.
Checkpoint. Two different classrooms use two different textbooks. Paired or independent?
Guess first. If order is treatment minus control, what does a positive value mean?
Guided exercise.
A positive value means the treatment group has a larger average or proportion than the control group.
Checkpoint. Compute treatment minus control for means 15 and 18.
Guess first. Is a difference of 0.07 equal to 7 percentage points?
Guided exercise.
Yes. Proportions are decimals; multiply by 100 to express percentage points.
Checkpoint. Convert a difference of 0.125 to percentage points.
Guess first. What two ideas should accompany a group difference?
Guided exercise.
Use uncertainty and practical context. Ask whether the difference is statistically clear and whether it matters.
Checkpoint. Name one design feature that strengthens causal claims.
15 - 18 = -3; treatment is lower by 3 units.12.5 percentage points.Use edumath to compute a standard error for a difference of independent means.
2.8284271247461903
Use SymPy to simplify the same calculation symbolically.