Confidence Interval Calculator

This confidence interval calculator finds the interval for a population mean or a proportion at the confidence level you choose. It shows the margin of error and lets you compare methods side by side.

Checks on your data

  • With n = 40 the sample is large enough for this interval to be reasonable, provided the data are a random sample.

Results

95% confidence interval for the mean
12.0243 to 13.1757
t interval, 39 df
Sample mean
12.6
Margin of error
± 0.575668
t critical value
2.0227
Standard error
0.284605
Sample SD / n
1.8 / 40
95% CI for the standard deviation
1.47449 to 2.31126
chi-square based, assumes normal data
Width of interval
1.15134
Same data: t interval vs z interval
t interval: 12.02 to 13.18z interval (using s): 12.04 to 13.161212.513
Margin of error shrinks as n grows (same SD)
051015102030405060youSample size n
Same estimate at different confidence levels
ConfidenceLowerUpper
90%12.120513.0795
95%12.024313.1757
99%11.829313.3707
Show step-by-step solution
  1. n = 40, x̄ = 12.6, s = 1.8; standard error = s ÷ √n = 0.284605.
  2. t* (39 df) = 2.0227.
  3. Margin of error = 2.0227 × 0.284605 = 0.575668; CI = 12.6 ± 0.575668.
Mean (σ unknown)x̄ ± t*·s/√n
ProportionWilson recommended
95% meansMethod captures truth 95% of the time
Wider whenHigher confidence, smaller n, larger SD

What Is Confidence Interval?

A confidence interval gives a range of plausible values for a population parameter. A 95 % interval means that if you repeated the sampling many times, about 95 % of the intervals built this way would contain the true value. It does not mean there is a 95 % chance that this particular interval contains it.

For a mean, the calculator uses a t interval when σ is unknown and a z interval when σ is known. For a proportion it offers the Wald, Wilson and Agresti-Coull intervals, because the simple Wald interval can perform poorly for small samples or extreme proportions. For a confidence interval for a population variance, use the sample variance calculator linked below.

Below you will find the formulas, a variables table, a worked example and answers to common questions such as how to find the 95 % confidence interval and how sample size affects the margin of error.

How to Use the Confidence Interval Calculator

  1. Choose whether you want an interval for a mean or a proportion.
  2. For a mean, enter raw data or summary statistics (mean, SD, n). For a proportion, enter the number of successes and the sample size.
  3. Pick a confidence level.
  4. Read the interval and margin of error. The chart compares methods; the table shows how the interval widens at higher confidence.

Confidence Interval Formula

Mean, σ unknown (t interval)

xˉ±tn−1∗sn\bar{x}\pm t^{*}_{n-1}\frac{s}{\sqrt n}

Mean, σ known (z interval)

xˉ±z∗σn\bar{x}\pm z^{*}\frac{\sigma}{\sqrt n}

Proportion, Wald

p^±z∗p^(1−p^)n\hat p\pm z^{*}\sqrt{\frac{\hat p(1-\hat p)}{n}}

Proportion, Wilson

p^+z22n±zp^(1−p^)n+z24n21+z2n\frac{\hat p+\frac{z^2}{2n}\pm z\sqrt{\frac{\hat p(1-\hat p)}{n}+\frac{z^2}{4n^2}}}{1+\frac{z^2}{n}}

Confidence Interval Variables Explained

SymbolMeaningNotes
x̄Sample meanCentre of the interval
s or σSample or population standard deviationt interval or z interval
nSample size
t*, z*Critical valueDepends on confidence level
MEMargin of errorCritical value × standard error
p̂Sample proportionFor proportion intervals

Confidence Interval Worked Example

Using the example values (press “Load example” above to try them):

  1. n = 40, x̄ = 12.6, s = 1.8; standard error = s ÷ √n = 0.284605.
  2. t* (39 df) = 2.0227.
  3. Margin of error = 2.0227 × 0.284605 = 0.575668; CI = 12.6 ± 0.575668.

Result: 95% confidence interval for the mean = 12.0243 to 13.1757; Sample mean = 12.6; Margin of error = ± 0.575668.

How to interpret a confidence interval

The correct reading is about the procedure, not about this one interval: the method produces intervals that contain the true value in 95% of repeated samples. It is not correct to say there is a 95% probability that the true value lies in your particular interval, though that is a common and usually harmless shorthand.

Intervals are more informative than p-values alone. If a 95% interval for a difference excludes zero, the result is significant at the 5% level, and the interval also shows how large the effect might be.

Critical values for common confidence levels
Confidencez*Alpha
80%1.2820.20
90%1.6450.10
95%1.9600.05
99%2.5760.01
99.9%3.2910.001

What controls the width of the interval

  • Confidence level: higher confidence needs a wider interval.
  • Sample size: the margin of error shrinks with 1/√n, so quadrupling n halves the width.
  • Variability: more spread in the data means a wider interval.
  • Method: for small samples the t interval is wider than a z interval to account for estimating s.

Which proportion interval should I use?

The Wald interval is taught first but performs poorly when the sample is small or the proportion is near 0 or 1: its real coverage can fall well below 95% and the limits can go outside 0 and 1. The Wilson interval fixes both problems and is the recommended default. The Agresti-Coull interval is a simple adjustment that gives similar results.

Proportion interval methods
MethodSmall nExtreme pComment
WaldPoorPoorSimplest; use only for large n and p near 0.5
WilsonGoodGoodRecommended default
Agresti-CoullGoodGoodAdd z²/2 successes and failures, then use Wald

Where Confidence Interval Is Used

Estimating a population mean

Reporting a mean with an interval instead of a single number.

Survey results

Giving the margin of error for a percentage.

Choosing a proportion method

Comparing Wald, Wilson and Agresti-Coull for small samples.

Margin of error

Seeing how sample size and confidence level change the width of the interval.

Common Confidence Interval Mistakes to Avoid

  • Using z instead of t with a small sample and unknown σ.
  • Using the population SD formula (n) rather than the sample SD (n − 1).
  • Interpreting the interval as containing 95% of the data. It describes the mean, not individual values.
  • Comparing two groups by checking whether their separate intervals overlap; use an interval for the difference instead.
  • 95% is conventional but not magical; choose the level that suits the stakes.
  • For small samples check normality or use a bootstrap interval.
  • Report the interval with the estimate: 12.6 (95% CI 12.0 to 13.2).

Confidence Interval Terms and Definitions

Margin of error
Half the width of the interval: critical value times standard error.
Confidence level
The long-run proportion of such intervals that contain the true parameter.
Coverage
The actual proportion of intervals that capture the truth; may differ from the stated level.

Confidence Interval FAQs

What does a 95% confidence interval mean?

If you repeated the sampling many times and built an interval each time, about 95% of the intervals would contain the true population value.

When should I use t instead of z?

Use t whenever the population standard deviation is unknown and you estimate it from the sample, which is the usual situation. For large samples the two are nearly identical.

How do I make a confidence interval narrower?

Increase the sample size, accept a lower confidence level, or reduce variability in the measurements.

What is the margin of error?

It is half the interval width, equal to the critical value multiplied by the standard error.

Which interval should I use for a proportion?

The Wilson interval is recommended, especially for small samples or proportions near 0 or 1.

Can a confidence interval be used for hypothesis testing?

Yes. If the hypothesised value is outside the 95% interval, you reject it at the 5% level in a two-sided test.

Does a wider interval mean a worse study?

It means less precision. Wide intervals indicate more uncertainty about the true value.

Related calculators

Last updated 2026-11-09. See our disclaimer.