# Two-Proportion Z-Test Calculator

> Tests whether two independent proportions differ using the pooled two-proportion z-test and reports the z statistic, two- and one-sided p-values and a Wald confidence interval for the difference.

- Calculator id: `proportion-z-test` · Category: Statistics & Probability (`statistics`) · Tool name: `calculate_two_proportion_z_test`
- Canonical page: https://tttkmbb.com/statistics/proportion-z-test · This document: https://tttkmbb.com/statistics/proportion-z-test.md · JSON definition: https://tttkmbb.com/statistics/proportion-z-test.json

## Purpose

Tests whether two independent proportions differ using the pooled two-proportion z-test and reports the z statistic, two- and one-sided p-values and a Wald confidence interval for the difference.

**Use when:** You have successes and trials for two independent groups (conversion rates, response rates, defect rates) and want to know whether the rates differ significantly.

**Do not use when:** Counts are very small (n·p or n·(1 − p) below 5 in a group: use Fisher's exact test), the groups are paired (McNemar's test), or there are more than two groups or categories (use chi-square-test).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `successes_a` | integer |  | required | Number of successes (events) in group A. (min 0) |
| `trials_a` | integer |  | required | Number of observations in group A. (min 1) |
| `successes_b` | integer |  | required | Number of successes in group B. (min 0) |
| `trials_b` | integer |  | required | Number of observations in group B. (min 1) |
| `alpha` | number |  | optional, default 0.05 | Significance level as a probability (0.05 = 5 %), not a percentage. Confidence intervals and critical values use level 1 − alpha. (> 0) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `proportion_a` | number |  | successes_a / trials_a. |
| `proportion_b` | number |  | successes_b / trials_b. |
| `difference` | number |  | proportion_a − proportion_b. |
| `pooled_proportion` | number |  | (successes_a + successes_b) / (trials_a + trials_b), used for the test's standard error. |
| `standard_error` | number |  | √(p̂ (1 − p̂) (1/n_a + 1/n_b)). |
| `z_statistic` | number |  | difference / standard_error. |
| `p_value_two_sided` | number |  | 2 × (1 − Φ(\|z\|)). |
| `p_value_one_sided` | number |  | 1 − Φ(\|z\|): for the alternative in the observed direction. |
| `ci_lower` | number |  | Lower limit of the 100·(1 − alpha) % Wald interval for the difference (unpooled standard error). |
| `ci_upper` | number |  | Upper limit of the same interval. |
| `significant` | boolean |  | true when p_value_two_sided < alpha. |
| `decision` | string |  | Plain-language conclusion of the two-sided test. |

## Formula

`p_a = x_a/n_a, p_b = x_b/n_b, p̂ = (x_a + x_b)/(n_a + n_b); z = (p_a − p_b) / √(p̂(1 − p̂)(1/n_a + 1/n_b)); p = 2(1 − Φ(|z|)); CI = (p_a − p_b) ± z(1 − alpha/2) × √(p_a(1 − p_a)/n_a + p_b(1 − p_b)/n_b)`

Normal approximation to the binomial without continuity correction (equivalent to the 2×2 chi-square test without Yates' correction: χ² = z²). The confidence interval uses the unpooled standard error, as is standard.

## Data Sources

- Wikipedia – Z-test — https://en.wikipedia.org/wiki/Z-test (reference, retrieved 2026-09-24)
- NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.4.1 Confidence intervals for a proportion — https://www.itl.nist.gov/div898/handbook/prc/section2/prc241.htm (government, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/proportion-z-test?successes_a=…&trials_a=…&successes_b=…&trials_b=…`
- `POST https://tttkmbb.com/api/v1/calculate/proportion-z-test` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/proportion-z-test · OpenAPI operationId `calculate_two_proportion_z_test` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "proportion-z-test", "inputs": {…}}`

## Example

- 60/200 (30 %) vs 40/200 (20 %): inputs `{"successes_a":60,"trials_a":200,"successes_b":40,"trials_b":200}` → `{"proportion_a":0.3,"proportion_b":0.2,"difference":0.1,"pooled_proportion":0.25,"standard_error":0.0433,"z_statistic":2.3094,"p_value_two_sided":0.020921,"p_value_one_sided":0.010461,"ci_lower":0.0157,"ci_upper":0.1843,"significant":true}`
- 20/100 vs 15/100: inputs `{"successes_a":20,"trials_a":100,"successes_b":15,"trials_b":100}` → `{"difference":0.05,"pooled_proportion":0.175,"z_statistic":0.9305,"p_value_two_sided":0.35212,"ci_lower":-0.0551,"ci_upper":0.1551,"significant":false}`

```
GET https://tttkmbb.com/api/v1/calculate/proportion-z-test?successes_a=60&trials_a=200&successes_b=40&trials_b=200
```

## Limitations

Counts are very small (n·p or n·(1 − p) below 5 in a group: use Fisher's exact test), the groups are paired (McNemar's test), or there are more than two groups or categories (use chi-square-test). Normal approximation to the binomial without continuity correction (equivalent to the 2×2 chi-square test without Yates' correction: χ² = z²). The confidence interval uses the unpooled standard error, as is standard. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why does the test use a pooled proportion but the interval does not?**

Under H0 both groups share one proportion, so the test pools them for the best estimate of the null standard error; the interval describes the actual difference and therefore uses each group's own variance.

**Is this the same as an A/B test significance calculator?**

Yes for a two-sided test of conversion rates; z² equals the chi-square statistic of the corresponding 2×2 table without continuity correction.

## Related

- [Chi-Square Test Calculator](https://tttkmbb.com/statistics/chi-square-test.md) — Same comparison as a 2×2 table, or more than two groups.
- [Margin of Error Calculator](https://tttkmbb.com/statistics/margin-of-error.md) — Confidence interval for a single proportion.
- [Sample Size Calculator](https://tttkmbb.com/statistics/sample-size.md) — Sample size needed for a target margin of error.
