Confidence Interval Calculator
Give the sample mean, spread and size, or successes and trials, and get the interval with its margin of error.
https://flxcode.com/confidence-interval-calculator/
If this box has numbers, the mean, s and n are taken from them and the three fields above are not used.
Example Confidence interval
95% confidence interval for the mean
| Sample mean (x̄) | 52.4 |
|---|---|
| Critical value (t*) | 2.0639 |
| Standard error | 1.62 |
| Margin of error | 3.34352 |
| Lower limit | 49.0565 |
| Upper limit | 55.7435 |
The steps, with your numbers
Degrees of freedom: n − 1 = 25 − 1 = 24
Critical value: t* for 95% with 24 df = 2.0639
Standard error: SE = s / √n = 8.1 / √25 = 1.62
Margin of error: t* × SE = 2.0639 × 1.62 = 3.34352
Interval: x̄ ± margin = 52.4 ± 3.34352 = (49.0565, 55.7435)
No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it.
Problem or idea? Email us
Quick start
- Pick the type: mean with known σ (z), mean with unknown σ (t), or a proportion.
- Choose 90, 95 or 99%, or type any level such as 97.5.
- Type the numbers. For the t interval you can paste the raw data instead.
- Read the interval, the margin of error and the steps below it.
Formulas
| Type | Interval | Critical value |
|---|---|---|
| Mean, σ known | x̄ ± z* × σ / √n | z* from the normal curve |
| Mean, σ unknown | x̄ ± t* × s / √n | t* with n − 1 degrees of freedom |
| Proportion | p̂ ± z* × √(p̂(1 − p̂) / n) | z* from the normal curve |
Critical values
These come from the same inverse functions the tool calls.
| Level | z* | t*, df = 9 | t*, df = 24 | t*, df = 99 |
|---|---|---|---|---|
| 90% | 1.6449 | 1.8331 | 1.7109 | 1.6604 |
| 95% | 1.96 | 2.2622 | 2.0639 | 1.9842 |
| 99% | 2.5758 | 3.2498 | 2.7969 | 2.6264 |
Worked examples
| Case | Inputs | Margin | 95% interval |
|---|---|---|---|
| Mean, σ known | x̄ = 100, σ = 15, n = 36 | 4.89991 | 95.1001 to 104.9 |
| Mean, σ unknown | x̄ = 52.4, s = 8.1, n = 25 | 3.34352 | 49.0565 to 55.7435 |
| Poll proportion | 560 of 1,000 | 0.03077 | 0.5292 to 0.5908 |
| Small proportion | 4 of 20 | 0.1753 | 0.0247 to 0.3753 (Wilson 0.08066 to 0.416) |
How the width changes
The margin of error depends on three things: the confidence level, the spread of the data and the sample size. To halve the margin, you need four times the sample. That is why polls of 1,000 people give about ±3 points and going to 4,000 only gets you to about ±1.5. To check a claim against a number, find the p-value for it. To get the spread from your list first, use the standard deviation calculator.
Numbers this uses
Every constant the tool uses is listed here with its source. Where a number varies, you can edit it in the tool.
- Critical values is computed, not looked up. z* from Acklam's inverse normal with a refinement step, t* by bisection on the exact t distribution.
- Levels is any level above 0 and below 100. The three chips are 90, 95 and 99.
- Proportion is Wald interval, with the Wilson interval beside it. Wald is cut at 0 and 1 and flagged when there are fewer than 10 successes or failures.
Common mistakes
- Using z with the sample standard deviation on a small sample. Use t.
- Reading the interval as covering 95% of the data. It is about the mean, not about individual values.
- Entering the percentage of successes instead of the count. Type 560, not 56.
Nothing you type or paste is uploaded. We count events without cookies (details).
FAQ
What does a 95% confidence interval mean?
If you repeated the study many times and built an interval each time, about 95% of those intervals would contain the true value. It does not mean there is a 95% chance this one interval holds it. For a mean of 52.4, s = 8.1 and n = 25 the interval is 49.0565 to 55.7435.
Should I use z or t?
Use z when the population standard deviation σ is known, which is rare. Use t when you only have the sample standard deviation s, which is the usual case. t gives a wider interval for small samples: with n = 25 the critical value is 2.0639 instead of 1.95996.
How do I get a confidence interval for a proportion?
Pick Proportion and type the successes and the sample size. A poll with 560 yes answers out of 1,000 gives 56% with a margin of error of 3.08 points, so 52.9234% to 59.0766%.
What is the margin of error?
It is the part you add and subtract: the critical value times the standard error. In the z example with σ = 15 and n = 36 it is 4.89991, so the mean of 100 becomes 95.1001 to 104.9.
What happens when I raise the confidence level?
The interval gets wider. For the same data, 99% gives 47.869 to 56.931 instead of 49.0565 to 55.7435. More confidence costs precision. A bigger sample narrows it: the margin shrinks with the square root of n.
Which interval for a proportion should I trust?
The simple one (Wald) is the textbook formula and is fine for large samples. With few successes or failures it can be too narrow or leave [0, 1]. For 4 out of 20 it gives 0.0246955 to 0.375305, while the Wilson interval, also shown, gives 0.0806577 to 0.416017.
Can I paste my data instead of typing the mean and s?
Yes, for the mean with unknown σ. Paste the numbers in the data box and the tool uses their mean, sample standard deviation and count. The fields above are then ignored, and it says so.
Is my data uploaded?
No. The numbers stay in your browser and are not stored or sent. We only count which type of interval you used and which level.
More from FLXCode
P-Value CalculatorNew
p-value from a z, t, chi-square or F statistic, one or two tailed, with the tails shown.
Z-Score CalculatorNew
z-score from a value, mean and standard deviation, or from data, with percentile and p-values.
Standard Deviation CalculatorNew
Paste your numbers and get the sample and population standard deviation, with the steps shown.
Average CalculatorNew
Average (mean) of pasted numbers, or a weighted average for grades and prices, with the steps.