MECHOWL QUALITY ANALYSIS AI
Two-Proportion z-Test Calculator: Compare Defect Rates from Excel (Fisher's Exact Test, Confidence Interval)
Paste the defectives and the numbers inspected of two machines, two lots or before and after a change to test the difference of the defect rates (two-proportion z-test and Fisher's exact test) with the confidence interval of the difference. One rate can also be tested against a target, and a pass/fail column is counted for you.
Last updated
Your data is not sent. Everything is computed in your browser
Data
Write one group (machine, lot) per row with columns of defectives and numbers inspected (rows of the same group are added up, so a daily record can be pasted as it is). With one record per item and a pass/fail column, choose the pass/fail column and the page counts by group. To compare one defect rate with a target, change "Test".
Read 6 rows and 4 columns.
More settings (Value counted as defective, Chart title, Period, Stratum)
Empty: automatic (defective, NG, fail, reject, × …). Enter it when defectives are written another way (e.g. Grade B).
Empty: "Test of two proportions".
e.g. 1–31 Oct 2026. Written on the chart and the report.
Empty: all rows. A value: only the rows with that value.
Judgement rules
Decide the significance level and the alternative hypothesis before looking at the data. If you change them, write it in the report.
Two-sided (different) is the usual choice. Use one-sided only when the direction was fixed before looking at the data (e.g. did the countermeasure lower the defect rate?).
The default is a common guideline (see —).
Usually 0.05 (5 %). The confidence interval is given at 1 − α (95 % for 0.05). Decide it before looking at the data.
The default is a common guideline (see —).
Result
p-value 0.0355: Significant difference (α = 0.05)
Result of the sample data
Significant difference (α = 0.05)
A difference is called significant when the p-value (two-sided) is at most the significance level 0.05; here p = 0.0355 (two defect rates). A test result does not show the size of the difference or its cause.
- p-value (z-test, two-sided)
- 0.0355
- Difference of the defect rates (Machine 1 − Machine 2)
- −4.06 percentage points
- p-value of Fisher's exact test (two-sided)
- 0.0416
About the data
- Data read as: one row per group (defectives and number inspected).
How to read it
What the chart shows
- At the significance level 0.05, the defect rates of Machine 1 and Machine 2 differ (p = 0.0355).
- The difference of the defect rates is −4.06 percentage points, with a 95 % confidence interval of −7.82 to −0.31 percentage points; Fisher's exact test gives p = 0.0416.
Common misreadings
- A small p-value does not mean a large difference. With much data, even a small difference is significant. Judge the size of the difference by the confidence interval and decide whether it matters in practice.
- The confidence interval of the difference (Wald) and the z-test (pooled rate) use different formulas, so when the p-value is close to the significance level the judgement and "does the interval contain 0" can disagree. Then look at Fisher's exact test too.
- With few defectives (a group with fewer than about 5), the normal approximation of the z-test no longer holds. Look at Fisher's exact test (the exact binomial test for one rate).
- Testing two at a time among three or more groups makes a chance significant result likely somewhere (multiple comparisons). Compare three or more defect rates together with the chi-square test (contingency table).
Next steps
- For the group with the higher defect rate, look into the 4M differences. After a countermeasure, compare the defect rates again with the same number inspected.
Numbers
| p-value (z-test, two-sided) | 0.0355 |
|---|---|
| Difference of the defect rates (Machine 1 − Machine 2) | −4.06 percentage points |
| 95 % confidence interval of the difference | −7.82 to −0.31 percentage points |
| z statistic z | −2.1025 |
| p-value of Fisher's exact test (two-sided) | 0.0416 |
| Defect rate (Machine 1) | 4.00 % (12 / 300) |
| Defect rate (Machine 2) | 8.06 % (25 / 310) |
| Pooled defect rate | 6.07 % |
Calculation steps
- Defect rates
p̂ = defectives ÷ number inspectedMachine 1: 12 ÷ 300 = 0.04000; Machine 2: 25 ÷ 310 = 0.08065 - Pooled defect rate
p̄ = (x₁ + x₂) / (n₁ + n₂)37 ÷ 610 = 0.06066 - z statistic
z = (p̂₁ − p̂₂) / √( p̄(1 − p̄)(1/n₁ + 1/n₂) ) (z² equals the chi-square of the 2 × 2 table without correction)−0.04065 / √(0.06066 × 0.93934 × (1/300 + 1/310)) = −2.1025 - 95 % confidence interval of the difference
(p̂₁ − p̂₂) ± z × √( p̂₁(1 − p̂₁)/n₁ + p̂₂(1 − p̂₂)/n₂ )z = 1.9600 → −7.82 to −0.31 percentage points - Fisher's exact test
the hypergeometric distribution of the 2 × 2 table of defective and good items with the margins fixed (two-sided)p = 0.0416
Values by group
| Group | Defectives | Inspected | Defect rate |
|---|---|---|---|
| Machine 1 | 12 | 300 | 4.00 % |
| Machine 2 | 25 | 310 | 8.06 % |
The results are reference values based on the data you entered and the formulas and criteria shown. They are not a quality guarantee or a pass/fail decision. The final decision rests with you.
References
- NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.4 Does the proportion of defectives meet requirements? · NIST · Open
- NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.4.1 Confidence intervals (for the proportion of defectives) · NIST · Open
- NIST/SEMATECH e-Handbook of Statistical Methods, 7.3.3 How can we determine whether two processes produce the same proportion of defectives? · NIST · Open
- JIS Z 8101-2:2015 Statistics — Vocabulary and symbols — Part 2: Applied statistics (in Japanese) · Japanese Standards Association (JSA)
Standards are shown by number and title only.
Test of two proportions explained
A test of two proportions is a hypothesis test that checks whether the difference between the defect rates (defectives ÷ number inspected) of two groups is larger than chance explains. The two-proportion z-test uses the pooled defect rate of both groups, and Fisher's exact test also works with few defectives. A single defect rate can be compared with a target rate as well (the one-proportion test, with the exact binomial test).
Test of two proportions by hand: the calculation step by step
- Count the defectives x and the number inspected n of each group, and decide the significance level α (usually 0.05).
- Compute each defect rate p̂ = x ÷ n and the pooled rate p̄ = (x₁ + x₂) ÷ (n₁ + n₂).
- Compute z = (p̂₁ − p̂₂) ÷ √( p̄(1 − p̄)(1/n₁ + 1/n₂) ) and get the p-value from the standard normal distribution (doubled for a two-sided test).
- Judge the size of the difference by its confidence interval (p̂₁ − p̂₂) ± z × √( p̂₁(1 − p̂₁)/n₁ + p̂₂(1 − p̂₂)/n₂ ). With few defectives, look at the p-value of Fisher's exact test.
Worked examples
Example 1: Defect rates of two machines (100 parts each)
Machine Defectives Inspected Machine 1 5 100 Machine 2 15 100
Defect rates 0.05 and 0.15, pooled rate 20/200 = 0.1. z = −0.10 / √(0.1 × 0.9 × (1/100 + 1/100)) = −0.10 / 0.042426 = −2.357023. Two-sided p = 2 × Φ(−2.357023) = 0.018422 (significant).
Example 2: One defect rate against a target of 10 % (one-sided)
Process Defectives Inspected New process 26 200
Settings: Test = One defect rate (against a target), Reference defect rate (one rate) = 10, Alternative hypothesis = One-sided (the first is greater)
Defect rate 26/200 = 0.13. z = (0.13 − 0.10) / √(0.10 × 0.90 / 200) = 0.03 / 0.021213 = 1.414214. One-sided p (higher) = Φ(−1.414214) = 0.07865 (not significant). The one-sided 95 % Wilson lower bound is 0.09577 (the same example as NIST e-Handbook 7.2.4 and 7.2.4.1).
Example 3: A defect rate of 0 in one group
Machine Defectives Inspected A 0 50 B 4 50
Pooled rate 4/100 = 0.04. z = −0.08 / √(0.04 × 0.96 × 0.04) = −0.08 / 0.039192 = −2.041241 (p = 0.0412). With so few defectives, Fisher's exact test is the one to look at: p = 0.1175 (not significant).
Example 4: Counted from a pass/fail column (one row per item)
Lot Result A Pass A Fail A Pass A Pass B Fail B Fail B Pass B Fail
A: 1 fail out of 4 → 0.25; B: 3 fails out of 4 → 0.75. Pooled rate 0.5. z = −0.5 / √(0.5 × 0.5 × (1/4 + 1/4)) = −0.5 / 0.353553 = −1.414214.
Example 5: No defectives in either group (not computed)
Machine Defectives Inspected A 0 100 B 0 80
The pooled rate is 0, so the spread (standard error) is 0 and z cannot be computed.
Example 6: More defectives than inspected (input error)
Machine Defectives Inspected A 12 10 B 3 10
A has 12 defectives out of 10 inspected, a defect rate above 1. The page asks to check the counts.
Common mistakes
- Trusting the z-test p-value with few defectives (expected defectives under 5): the normal approximation no longer holds; look at Fisher's exact test.
- Comparing the counts of defectives of groups with different numbers inspected (compare the rates).
- Counting two defects on one part as two defectives (the defect rate is the number of defective parts ÷ the number inspected).
FAQ
- Should I look at the z-test or Fisher's exact test?
- With many defectives the two give almost the same value. When a group has few defectives (fewer than about 5), look at Fisher's exact test, which uses no approximation. This page gives both.
- Can it work from pass/fail records (one row per item)?
- Yes. Choose the pass/fail column and the page counts the defectives and the number inspected of each group. Values such as defective, NG, fail, reject and × are read as defective automatically; for another way of writing it (e.g. Grade B), enter it in "Value counted as defective".
- Is my data sent anywhere?
- No. The calculations and the chart are made in your browser only.
Scope
The difference of two defect rates (z-test, Fisher's exact test and the confidence interval of the difference), and one defect rate against a target (z-test, Wilson confidence interval and exact binomial test).
Not covered by this tool:
- Comparing three or more defect rates (use the chi-square test of a contingency table).
- Paired pass/fail results (the same items before and after).
Excel template: Test of two proportions
A template with the column names and sample values only (no formulas). Enter your values, then copy the range and paste it into the box above.