Home › Statistics & Probability › Confidence Interval Calculator
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.
When to use
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.
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 %).
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
sample_mean | number | yes | Mean of the sample. | |
std_dev | number | yes | Population standard deviation σ if known, otherwise the sample standard deviation s. Range: > 0 | |
sample_size | integer | yes | Number of observations in the sample. Range: ≥ 2 | |
confidence_level_percent | number | % | default 95 | Confidence level in percent (commonly 90, 95 or 99). Determines the critical z value. Range: > 0 |
Outputs
| Output | 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. |
Example
Mean 100, SD 15, n = 36, 95 %: {"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 %: {"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
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/confidence-interval(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/confidence-interval · Markdown: https://tttkmbb.com/statistics/confidence-interval.md · JSON definition: https://tttkmbb.com/statistics/confidence-interval.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="confidence-interval" - OpenAPI operationId:
calculate_confidence_interval - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
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 calculators
- Margin of Error Calculator — Confidence interval for a proportion or survey percentage.
- Sample Size Calculator — How many observations are needed for a target margin of error.
- Descriptive Statistics Calculator — Get the sample mean and standard deviation from raw data.