# Margin of Error Calculator

> Computes the margin of error (half-width of the confidence interval) of a sample proportion from the sample size, confidence level and observed percentage, with an optional finite population correction.

- Calculator id: `margin-of-error` · Category: Statistics & Probability (`statistics`) · Tool name: `calculate_margin_of_error`
- Canonical page: https://tttkmbb.com/statistics/margin-of-error · This document: https://tttkmbb.com/statistics/margin-of-error.md · JSON definition: https://tttkmbb.com/statistics/margin-of-error.json

## Purpose

Computes the margin of error (half-width of the confidence interval) of a sample proportion from the sample size, confidence level and observed percentage, with an optional finite population correction.

**Use when:** You have poll or survey results (n respondents, x % answering a certain way) and need the ± margin at a confidence level.

**Do not use when:** You are still planning the survey and need the required sample size (use sample-size), or the statistic is a mean rather than a percentage (use confidence-interval).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `sample_size` | integer |  | required | Number of respondents or observations. (min 1) |
| `confidence_level_percent` | number | % | optional, default 95 | Confidence level in percent (commonly 90, 95 or 99). Determines the critical z value. (> 0) |
| `proportion_percent` | number | % | optional, default 50 | Percentage of the sample with the attribute. 50 % gives the largest (most conservative) margin. (min 0, max 100) |
| `population_size` | integer |  | optional | Optional total population size N. When given, the finite population correction is applied; omit for large or unknown populations. (min 2) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `z_value` | number |  | Two-sided normal critical value for the confidence level. |
| `standard_error_percent` | number | % | 100 × √(p (1 − p) / n), after the finite population correction if applied. |
| `margin_of_error_percent` | number | % | z_value × standard error, in percentage points. |
| `lower_bound_percent` | number | % | proportion − margin (not truncated at 0). |
| `upper_bound_percent` | number | % | proportion + margin (not truncated at 100). |

## Formula

`margin = z · √(p (1 − p) / sample_size) × 100, with p = proportion_percent/100; with population_size N the margin is multiplied by √((N − sample_size) / (N − 1))`

Normal (Wald) approximation to the binomial, standard in survey reporting; it is inaccurate when n·p or n·(1 − p) is below about 10 (very small samples or extreme percentages), where a Wilson interval should be used.

## Data Sources

- 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-23)
- Wikipedia – Margin of error — https://en.wikipedia.org/wiki/Margin_of_error (reference, retrieved 2026-09-23)

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/margin-of-error?sample_size=…`
- `POST https://tttkmbb.com/api/v1/calculate/margin-of-error` 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/margin-of-error · OpenAPI operationId `calculate_margin_of_error` 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": "margin-of-error", "inputs": {…}}`

## Example

- n = 1,000, 95 %, 50 %: inputs `{"sample_size":1000,"confidence_level_percent":95,"proportion_percent":50}` → `{"z_value":1.96,"standard_error_percent":1.5811,"margin_of_error_percent":3.1,"lower_bound_percent":46.9,"upper_bound_percent":53.1}`
- n = 400, 99 %, 30 %: inputs `{"sample_size":400,"confidence_level_percent":99,"proportion_percent":30}` → `{"z_value":2.5758,"standard_error_percent":2.2913,"margin_of_error_percent":5.9,"lower_bound_percent":24.1,"upper_bound_percent":35.9}`

```
GET https://tttkmbb.com/api/v1/calculate/margin-of-error?sample_size=1000&confidence_level_percent=95&proportion_percent=50
```

## Limitations

You are still planning the survey and need the required sample size (use sample-size), or the statistic is a mean rather than a percentage (use confidence-interval). Normal (Wald) approximation to the binomial, standard in survey reporting; it is inaccurate when n·p or n·(1 − p) is below about 10 (very small samples or extreme percentages), where a Wilson interval should be used. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why do polls report ±3 %?**

A sample of about 1,000 at 95 % confidence and p = 50 % gives 1.96 × √(0.25 / 1000) = 3.1 percentage points; the same sample gives a smaller margin for percentages far from 50 %.

**Is the margin in percent or percentage points?**

Percentage points: a result of 40 % with a ±3 % margin means 37 % to 43 %.

## Related

- [Sample Size Calculator](https://tttkmbb.com/statistics/sample-size.md) — Plan the sample size for a target margin.
- [Confidence Interval Calculator](https://tttkmbb.com/statistics/confidence-interval.md) — Interval for a sample mean instead of a proportion.
