Find a course

Module 3: Estimation and Hypothesis TestingLesson 7 of 1115 min

Comparing Two Groups

Compare means with a two-sample t-test and rates with a two-proportion z-test, choose paired or independent designs, and pick the right test for your data.

Step 1 of 12Learn

Did the new email raise order values?

A marketing team sends two versions of a promotional email to two random groups of 2,000 customers. Customers who received version A spent an average of $52.10 per order; those who received version B spent $54.00. The team wants to roll out B to the full list of 400,000 customers.

The difference of $1.90 looks meaningful, but order values vary a lot. In both groups the standard deviation is around $30 to $32. With that much noise, could two random groups receiving the same email easily differ by $1.90?

Comparing two groups is the most common inferential task in business analytics: two versions of a page, two regions, two time periods, customers with and without a feature. The logic is always the same:

  1. Compute the difference between the groups.
  2. Compute the standard error of that difference, which combines the noise in both groups.
  3. Divide to get a test statistic and a p-value, and build a confidence interval for the difference.

What changes is the formula for the standard error, which depends on whether you compare means or proportions and whether the groups are independent or paired. This lesson walks through the main cases with real numbers, so you can check the output of any tool and know which test to ask for.

Step 2 of 12Learn

Two-sample t-test for means

For two independent groups, the standard error of the difference in means is

SE = √( s₁²/n₁ + s₂²/n₂ )

and the test statistic is t = (x̄₂ − x̄₁) / SE. This version, which doesn't assume equal variances in the two groups, is called Welch's t-test and is a sensible default.

For the email test: s₁ = $30, s₂ = $32, n = 2,000 in each group.

SE = √(900/2,000 + 1,024/2,000) = √(0.45 + 0.512) = √0.962 ≈ $0.98

t = 1.90 / 0.98 ≈ 1.94

With thousands of observations, t behaves like z, and t = 1.94 gives a two-sided p-value of about 0.053. The 95% confidence interval for the difference is 1.90 ± 1.96 × 0.98, roughly −$0.02 to +$3.82.

So the honest conclusion is: version B may raise order values by up to about $3.80, but the data is also consistent with no effect at all. With α = 0.05 the result is just short of significance. Rather than declaring victory or failure, the team could run the test longer or on more customers, which would shrink the SE. Notice how much more the interval says than "p = 0.053" alone.

Step 3 of 12Try the calculator

Two-sample comparison of means (Welch)

Enter the mean, standard deviation and size of each group. The interval uses 1.96, which is accurate for large samples.

Difference (B − A)
1.9
Standard error of the difference
0.981
t statistic
1.94
95% CI lower
-0.02
95% CI upper
3.82

Step 4 of 12Practice · Work it out

Group A (n = 400) has a mean session time of 20 minutes, group B (n = 400) has 22 minutes, and both have an SD of 10 minutes. What is the t statistic for the difference? Round to two decimal places.

Step 5 of 12Chart

A real difference in means, huge overlap in people

Group means of 20 and 22 minutes, both with SD 10. The averages differ clearly with 400 users per group, yet individual users overlap almost entirely.

A real difference in means, huge overlap in peopleLine chart with 9 categories: 0: Group A (mean 20) 0.54, Group B (mean 22) 0.35; 5: Group A (mean 20) 1.3, Group B (mean 22) 0.94; 10: Group A (mean 20) 2.42, Group B (mean 22) 1.94; 15: Group A (mean 20) 3.52, Group B (mean 22) 3.12; 20: Group A (mean 20) 3.99, Group B (mean 22) 3.91; 25: Group A (mean 20) 3.52, Group B (mean 22) 3.81; 30: Group A (mean 20) 2.42, Group B (mean 22) 2.9; 35: Group A (mean 20) 1.3, Group B (mean 22) 1.71; 40: Group A (mean 20) 0.54, Group B (mean 22) 0.79.01234Density (%)0510152025303540Session time (minutes)
Normal curves. A significant difference in means does not mean most B users beat most A users.
A real difference in means, huge overlap in people
Session time (minutes)Group A (mean 20)Group B (mean 22)
00.540.35
51.30.94
102.421.94
153.523.12
203.993.91
253.523.81
302.422.9
351.31.71
400.540.79

Step 6 of 12Learn

Comparing two proportions

For conversion rates and other proportions, the standard two-proportion z-test first pools both groups to estimate a common rate under the null hypothesis of no difference:

p̂ = (x₁ + x₂) / (n₁ + n₂)

SE = √( p̂(1 − p̂)(1/n₁ + 1/n₂) )

z = (p₂ − p₁) / SE

Example: version A converts 500 of 10,000 visitors (5.0%), version B converts 580 of 10,000 (5.8%). Pooled p̂ = 1,080 / 20,000 = 0.054.

SE = √(0.054 × 0.946 × 0.0002) ≈ 0.0032

z = 0.008 / 0.0032 ≈ 2.50, giving a two-sided p-value of about 0.012.

For the confidence interval of the difference, analysts use the unpooled SE, √(p₁(1 − p₁)/n₁ + p₂(1 − p₂)/n₂), which here is also about 0.0032. The 95% interval is 0.8 ± 0.63 points, or about +0.17 to +1.43 percentage points.

Report the result both ways. In absolute terms, B raised conversion by 0.8 points. In relative terms, that is a lift of 0.8 / 5.0 = 16%. Relative lifts sound more impressive, so always say which one you mean; "conversion up 16%" and "conversion up 0.8 points" describe the same result.

Step 7 of 12Practice · Work it out

Version A converts 200 of 4,000 visitors and version B converts 260 of 4,000. Using the pooled two-proportion z-test, what is the z statistic? Round to two decimal places.

Step 8 of 12Learn

Paired designs and choosing the right test

Independent or paired? Groups are independent when different units are in each group, such as different customers seeing versions A and B. Data is paired when the same units are measured twice or matched one to one: the same stores before and after a remodel, the same users rating two designs, twins in a study. For paired data, compute the difference within each pair and analyze those differences with a paired t-test. Pairing removes the variation between units, which often makes the test far more powerful. Treating paired data as independent wastes that advantage and can hide real effects.

Choosing a test mostly comes down to the type of outcome and the design:

  • Numeric outcome, two independent groups: Welch's two-sample t-test.
  • Numeric outcome, paired: paired t-test on the differences.
  • Yes/no outcome, two groups: two-proportion z-test (or a chi-square test, which is equivalent for a 2×2 table).
  • Categorical outcome with several categories, or several groups: chi-square test of independence.
  • Small samples with heavily skewed data: a rank-based test such as Mann-Whitney, or bootstrap intervals.
  • More than two group means: analysis of variance (ANOVA), followed by planned comparisons.

The test matters less than the design. Randomization, adequate sample size and one pre-chosen primary metric do more for the trustworthiness of a result than any choice among formulas.

Step 9 of 12Practice · Sort into groups

Sort each comparison into the design it uses.

Tap an item, then tap its group (or drag it there).

Step 10 of 12Diagram

Choosing a two-group test

Two questions pick the test: what kind of outcome, and are the groups independent?

Choosing a two-group testHierarchy diagram: Compare two groups, Numeric outcome (means), Yes/no outcome (proportions), Independent: Welch t-test, Paired: paired t-test, Two-proportion z-test.Compare two groupsNumeric outcome(means)Yes/no outcome(proportions)Independent: Welcht-testPaired: pairedt-testTwo-proportionz-test

Tap a shape with to see more.

Compare two groups
Numeric outcome (means)
Yes/no outcome (proportions)
Independent: Welch t-test

Different users in each group.

Paired: paired t-test

Same units measured twice: test the differences.

Two-proportion z-test

Conversion rates of two independent groups.

Step 11 of 12Note

Step 12 of 12Practice · Choose one

A company wants to know whether the mix of plan types (Basic, Plus, Pro) differs between customers in Europe and customers in Asia. Which test fits best?