Install free

Guides

Two-sample z-test in Google Sheets

The two-sample z-test compares two means when you know each population's variance in advance, for example from years of quality-control records. If you only have the sample variances, use a t-test instead. Example: breaking strength (kg) of cable from two suppliers. Long-run records put Supplier A's variance at 4 and Supplier B's at 4.5.

AB
1Supplier ASupplier B
241.237.5
338.539
44435.2
540.141.4
637.836.8
742.638.1
839.934.9
943.140.2
1040.737.7
1138.236.3
1241.939.6
1342.335.8

Run the z-test

  1. Open Extensions, StatPak, Data Analysis and choose z-Test: Two Sample for Means.
  2. Variable 1 range: A1:A13. Variable 2 range: B1:B13.
  3. Hypothesized mean difference: 0.
  4. Variable 1 variance (known): 4. Variable 2 variance (known): 4.5. Enter variances: if you know a standard deviation of 2, enter 4.
  5. Tick Labels in first row and click Run.
z-Test: Two Sample for Means
Supplier ASupplier B
Mean40.8583337.70833
Known Variance44.5
Observations1212
Hypothesized Mean Difference0
z3.742758
P(Z<=z) one-tail9.1006E-5
z Critical one-tail1.644854
P(Z<=z) two-tail0.0001820117
z Critical two-tail1.959964

How to read the output

With formulas

Sheets' Z.TEST function is a one-sample test, so it does not cover this case. Build it directly:

z-test or t-test?

Known population variances are rare outside quality control and textbook exercises. When the variances are estimated from the same data, the t-test accounts for that extra uncertainty. With large samples (a few hundred per group) the two give almost the same answer.

Related guides