Confidence Interval Calculator
Calculate a confidence interval for a mean, from summary statistics or raw data and with a t or z critical value, or for a proportion with the Wilson and Wald methods. Each result comes with its margin of error, the calculation steps and a number-line picture.
Confidence level (used by both calculators below)
Confidence interval for a mean
Calculation steps
The steps show rounded values; the tool calculates with full precision and rounds only at the end.
Confidence interval for a proportion
Calculations run in your browser. Nothing you enter is sent anywhere; your inputs are remembered only on this device.
How to use the confidence interval calculator
- Pick the confidence level at the top; 95 % is the usual choice. Both calculators use it.
- For a mean, enter the sample size, the sample mean and the standard deviation, then say whether it is the sample value s (t interval) or a known population value σ (z interval).
- If you have the measurements themselves, switch to Raw data and paste them; the tool works out n, the mean and s.
- For a proportion, enter the number of successes and the sample size, or a percentage and the sample size.
- Read the interval, margin of error, standard error and critical value. Copy result copies a one-line summary.
How it works
Most confidence intervals have the form estimate ± critical value × standard error. For a mean:
x̄ ± t* × s ÷ √n
Here x̄ is the sample mean, s the sample standard deviation (calculated with n − 1 in the denominator), n the sample size and t* the critical value of Student's t distribution with n − 1 degrees of freedom. The term s ÷ √n is the standard error, and t* times the standard error is the margin of error. If the population standard deviation σ is known, σ replaces s and the normal critical value z* replaces t*.
For a proportion with x successes in n trials, the sample proportion is p̂ = x ÷ n. The Wald interval is:
p̂ ± z* × √(p̂(1 − p̂) ÷ n)
The Wilson score interval is:
(p̂ + z*² ÷ (2n) ± z* × √(p̂(1 − p̂) ÷ n + z*² ÷ (4n²))) ÷ (1 + z*² ÷ n)
Critical values are computed in your browser, not read from a table: z* from an inverse normal function, t* by solving the cumulative t distribution (through the regularized incomplete beta function). The tool keeps full precision and rounds only the display: results for a mean to 3 decimal places unless you choose otherwise, percentages to 2, proportions and critical values to 4.
Examples
Example 1: t interval. n = 25, x̄ = 50, s = 10, 95 % confidence. The standard error is 10 ÷ √25 = 2 and t* (24 degrees of freedom) is 2.0639, so the margin of error is 2.0639 × 2 = 4.128 and the interval is 45.872 to 54.128.
Example 2: z interval with a known σ. n = 100, x̄ = 50, σ = 10, 95 % confidence. The standard error is 1 and z* = 1.9600, so the margin of error is 1.960 and the interval is 48.040 to 51.960.
Example 3: raw data. The values 4, 8, 15, 16, 23, 42 give n = 6, x̄ = 18 and s = 13.491. With t* = 2.5706 (5 degrees of freedom) the standard error is 5.508 and the margin of error 14.158, so the 95 % interval is 3.842 to 32.158.
Example 4: a poll. 520 of 1,000 respondents say yes, 95 % confidence. The sample proportion is 52 %, and the Wald margin of error is 1.96 × √(0.52 × 0.48 ÷ 1000) = 3.10 %, giving 48.90 % to 55.10 %. The Wilson interval is 48.90 % to 55.08 %, almost the same. With 3 successes in 10 trials they differ a lot: Wald gives 1.60 % to 58.40 %, Wilson 10.78 % to 60.32 %.
What a confidence interval means
A confidence interval is a range of plausible values for an unknown population quantity, such as a mean or a proportion, calculated from a sample. The confidence level describes the method, not one result: if you drew many random samples and built a 95 % interval from each, about 95 % of those intervals would contain the true value.
It is not correct to say that there is a 95 % probability that the true value lies inside the one interval you calculated. The true value is fixed, so that interval either contains it or it does not; you just cannot tell which. The interval also says nothing about where individual observations fall.
z or t, Wilson or Wald
Use the t interval whenever the standard deviation comes from the sample itself. Because s only estimates σ, the t distribution has heavier tails than the normal and a larger critical value: at 95 %, t* is 2.2622 for n = 10 and 2.0423 for n = 31, against z* = 1.9600. Use the z interval only when σ is known from outside the sample. For large samples the two almost coincide.
For a proportion, the Wald interval is the classic textbook formula, but it covers the true value less often than the stated level when the sample is small or the proportion is close to 0 or 1. A common rule asks for at least 10 successes and 10 failures. With no successes it collapses to a single point (0 of 20 gives 0 % to 0 %), and its bounds can pass 0 % or 100 %. The Wilson interval stays between 0 % and 100 % and keeps close to the stated level even in small samples: 0 of 20 gives 0 % to 16.11 %. The tool therefore recommends Wilson and adds a note when Wald should not be trusted.
What changes the width, and what the interval assumes
- Sample size: the margin of error shrinks with √n, so halving it takes about four times as many observations.
- Confidence level: more confidence means a wider interval. In Example 1 the margin of error is 3.422 at 90 %, 4.128 at 95 % and 5.594 at 99 %.
- Spread: a larger standard deviation gives a proportionally wider interval.
- Random sample: the observations must be drawn at random and independently. The interval covers sampling error only, not bias in how the data were collected.
- Shape of the data: for a mean, the data should be roughly normal, or the sample large (about 30 or more is a common guide). Strong skew or outliers in a small sample make the interval unreliable.
To decide how many observations you need before collecting data, use the Sample Size Calculator.
Frequently asked questions
How do I calculate a 95 % confidence interval for a mean?
Divide the sample standard deviation by √n to get the standard error, multiply it by the t critical value for n − 1 degrees of freedom, then add and subtract the result from the sample mean.
What is the difference between a confidence interval and the margin of error?
The margin of error is half the width of a symmetric interval: the estimate plus and minus the margin. The Wilson interval is not symmetric around the sample proportion, so it has no single margin.
Why is the critical value not exactly 1.96?
1.96 is z* for 95 % confidence. A t interval uses a larger value that depends on the sample size, and other levels have their own values, such as 1.6449 for 90 % and 2.5758 for 99 %.
Can I use a t interval with fewer than 30 observations?
Yes, from n = 2 upwards, provided the data are roughly normal. The smaller the sample, the more that assumption matters.
Is my data uploaded anywhere?
No. Everything is calculated in your browser. Your inputs are saved only in this browser's local storage, and nothing is sent to a server.
Related tools
- Sample Size Calculator - find the sample size for a chosen margin of error.
- Percentage Calculator - convert between counts, percentages and percentage changes.
- Galton Board - watch random steps build a normal curve.
- Significant Figures Calculator - round results to a sensible number of digits.