# Confidence Interval Calculator

> Computes a confidence interval for a population mean from the sample mean, standard deviation and sample size using the normal (z) critical value: mean ± z · s / √n.

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

## Purpose

Computes a confidence interval for a population mean from the sample mean, standard deviation and sample size using the normal (z) critical value: mean ± z · s / √n.

**Use when:** You have a sample mean, its standard deviation and the sample size and want the interval that likely contains the population mean at a given confidence level.

**Do not use when:** The statistic is a proportion or survey percentage (use margin-of-error), or the sample is small (n < 30) with an unknown population SD, where a t-based interval is the correct choice and this z interval is slightly too narrow.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `sample_mean` | number |  | required | Mean of the sample. |
| `std_dev` | number |  | required | Population standard deviation σ if known, otherwise the sample standard deviation s. (> 0) |
| `sample_size` | integer |  | required | Number of observations in the sample. (min 2) |
| `confidence_level_percent` | number | % | optional, default 95 | Confidence level in percent (commonly 90, 95 or 99). Determines the critical z value. (> 0) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `z_value` | number |  | Two-sided standard normal critical value for the confidence level (1.6449 for 90 %, 1.96 for 95 %, 2.5758 for 99 %). |
| `standard_error` | number |  | std_dev / √sample_size. |
| `margin_of_error` | number |  | z_value × standard_error (half-width of the interval). |
| `lower_bound` | number |  | sample_mean − margin_of_error. |
| `upper_bound` | number |  | sample_mean + margin_of_error. |

## Formula

`z = Φ⁻¹(1 − (1 − confidence_level_percent/100) / 2); standard_error = std_dev / √sample_size; margin_of_error = z × standard_error; interval = sample_mean ± margin_of_error`

Uses the normal critical value, which is exact when the population σ is known and a good approximation when s is estimated from n ≥ 30 observations. For smaller samples with an estimated s, the Student t critical value with n − 1 degrees of freedom should replace z (e.g. 2.045 instead of 1.96 for n = 30 at 95 %).

## Data Sources

- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5.2 Confidence Limits for the Mean — https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm (government, retrieved 2026-09-23)
- Wikipedia – Confidence interval — https://en.wikipedia.org/wiki/Confidence_interval (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/confidence-interval?sample_mean=…&std_dev=…&sample_size=…`
- `POST https://tttkmbb.com/api/v1/calculate/confidence-interval` 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/confidence-interval · OpenAPI operationId `calculate_confidence_interval` 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": "confidence-interval", "inputs": {…}}`

## Example

- Mean 100, SD 15, n = 36, 95 %: inputs `{"sample_mean":100,"std_dev":15,"sample_size":36,"confidence_level_percent":95}` → `{"z_value":1.96,"standard_error":2.5,"margin_of_error":4.9,"lower_bound":95.1,"upper_bound":104.9}`
- Mean 50, SD 8, n = 100, 99 %: inputs `{"sample_mean":50,"std_dev":8,"sample_size":100,"confidence_level_percent":99}` → `{"z_value":2.5758,"standard_error":0.8,"margin_of_error":2.0607,"lower_bound":47.9393,"upper_bound":52.0607}`

```
GET https://tttkmbb.com/api/v1/calculate/confidence-interval?sample_mean=100&std_dev=15&sample_size=36&confidence_level_percent=95
```

## Limitations

The statistic is a proportion or survey percentage (use margin-of-error), or the sample is small (n < 30) with an unknown population SD, where a t-based interval is the correct choice and this z interval is slightly too narrow. Uses the normal critical value, which is exact when the population σ is known and a good approximation when s is estimated from n ≥ 30 observations. For smaller samples with an estimated s, the Student t critical value with n − 1 degrees of freedom should replace z (e.g. 2.045 instead of 1.96 for n = 30 at 95 %). All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**What does a 95 % confidence interval mean?**

If the sampling were repeated many times and an interval computed each time, about 95 % of those intervals would contain the true population mean. It does not mean there is a 95 % probability that this particular interval contains it.

**When should I use t instead of z?**

When the population standard deviation is unknown and estimated from the sample, the t distribution with n − 1 degrees of freedom is the exact choice; for n ≥ 30 the difference from z is small (about 4 % wider at n = 30, under 1 % at n = 200).

## Related

- [Margin of Error Calculator](https://tttkmbb.com/statistics/margin-of-error.md) — Confidence interval for a proportion or survey percentage.
- [Sample Size Calculator](https://tttkmbb.com/statistics/sample-size.md) — How many observations are needed for a target margin of error.
- [Descriptive Statistics Calculator](https://tttkmbb.com/statistics/descriptive-statistics.md) — Get the sample mean and standard deviation from raw data.
