Uni-Sine
MathematicsStatistics

Confidence interval calculator

A confidence interval calculator gives a range of values that is likely to contain the true population mean or proportion, based on a sample. The interval is the estimate plus or minus a margin of error: x̄ ± t* × s/√n for a mean. Our Confidence Interval Calculator builds intervals for a mean or a proportion at 90%, 95%, 98% or 99%, shows the working, and simulates what the confidence level really means.

It opens on a 95% interval for a mean of 72.4 from a sample of 30 with standard deviation 8.5, which gives 69.226 to 75.574.

Try it

Confidence Interval Calculator

Build confidence intervals for means and proportions

Go to its page

How to use the confidence interval calculator

  1. Under Interval, choose what the interval is for: a mean with the standard deviation estimated from the sample (t), a mean with the population standard deviation known (z), or a proportion (z).
  2. Choose the Confidence level: 90%, 95%, 98% or 99%.
  3. Under Values, for a mean, choose Summary values and type the mean, standard deviation and sample size, or choose Raw data and type up to 200 values. For a proportion, type the number of successes and the number of trials.
  4. Read the interval, the estimate, the margin of error, the standard error and the critical value, with a sentence saying what the interval means.
  5. Follow the working, and look at the distribution with the middle 95% (or your level) shaded between the critical values.

Below the results, a simulation draws new samples from a population whose true value is your estimate, and counts how many of their intervals capture it. Press +1, +20 or +100 to add samples, and watch the share settle near your confidence level. Practice and help sets z-interval questions with worked solutions.

The confidence interval formulas

Interval forWhen to use itFormula
A mean, σ knownThe population standard deviation is givenx̄ ± z* × σ/√n
A mean, σ unknownYou only have the sample standard deviation sx̄ ± t* × s/√n, with n − 1 degrees of freedom
A proportionx successes out of n trialsp̂ ± z* × √(p̂(1 − p̂)/n), with p̂ = x/n

In every case the part after ± is the margin of error, the critical value times the standard error. The critical value comes from the confidence level:

Confidence levelz*
90%1.645
95%1.960
98%2.326
99%2.576

t* is bigger than z* for small samples, which widens the interval to allow for estimating σ. With 29 degrees of freedom, the 95% t* is 2.045; it gets closer to 1.960 as the sample grows.

Worked examples you can check in the calculator

Example 1: a mean with σ known (z interval)

A sample of 36 has mean 103, from a population with standard deviation 15. Find a 95% confidence interval for the mean.

\text{SE} = \frac{15}{\sqrt{36}} = 2.5 \qquad 1.960 \times 2.5 = 4.90
103 \pm 4.90 = (98.10,\ 107.90)

Choose the z interval for a mean, 95%, and type 103, 15 and 36. The calculator gives 98.1 to 107.9 with a margin of error of 4.8999.

97989910010110210310410510610710810998.1107.9x̄ = 103
The 95% interval: the sample mean plus or minus the margin of error, 4.90

Example 2: a mean with σ unknown (t interval)

A sample of 15 lap times has mean 18.6 s and standard deviation 2.4 s. With σ unknown, use t with 14 degrees of freedom, so t* = 2.1448:

\text{SE} = \frac{2.4}{\sqrt{15}} = 0.6197 \qquad 2.1448 \times 0.6197 = 1.329
18.6 \pm 1.329 = (17.27,\ 19.93)\ \text{s}

Choose the t interval, type 18.6, 2.4 and 15, and the calculator gives 17.271 to 19.929. With raw data instead, type the values and it works out the mean and the sample standard deviation first.

Example 3: a proportion

In a survey, 312 of 520 people say they walk to work. p̂ = 312 ÷ 520 = 0.6, so:

\text{SE} = \sqrt{\frac{0.6 \times 0.4}{520}} = 0.02148 \qquad 1.960 \times 0.02148 = 0.0421
0.6 \pm 0.0421 = (0.558,\ 0.642)

Choose Proportion and type 312 and 520. The calculator gives 0.5579 to 0.6421, so between about 55.8% and 64.2% of all such people walk to work. It also gives the Wilson interval, 0.5573 to 0.6412, which is almost the same here.

Example 4: changing the confidence level

Go back to Example 1 and switch to 99%. z* rises to 2.576, the margin to 6.44, and the interval widens to 96.56 to 109.44. At 90% it narrows to 98.89 to 107.11. More confidence costs a wider interval.

What a 95% confidence interval means

If you took many samples and built a 95% interval from each, about 95% of those intervals would contain the true mean. It does not mean there is a 95% chance the true mean is in this particular interval: the true mean is fixed, and this interval either contains it or it does not. The calculator's simulation shows this: each line is a new interval, and roughly 1 in 20 misses at 95%. Check your reading:

practice
Pick an answer, then check it.
A 95% confidence interval for a population mean is (12.4, 15.8). Which statement is correct?

Margin of error and sample size

The margin of error shrinks with the square root of the sample size. Quadruple n and the margin halves: Example 1 with n = 144 instead of 36 gives 103 ± 2.45. To find the sample size for a target margin E, rearrange E = z*σ/√n:

n = \left(\frac{z^* \sigma}{E}\right)^2 = \left(\frac{1.960 \times 15}{2}\right)^2 = 216.1 \Rightarrow n = 217

Always round up. For a proportion with no prior estimate, use p̂ = 0.5, which gives the largest n: for a margin of 3 percentage points at 95%, n = 1.960² × 0.25 ÷ 0.03² = 1,067.1, so 1,068 people. The calculator has no sample size mode, so this step is by hand.

The Wilson interval for small counts

The textbook proportion interval goes wrong when successes or failures are few. With 3 successes in 40 trials, it gives −0.0066 to 0.1566, and a proportion cannot be negative. The calculator warns when there are fewer than 5 successes or failures, and gives the Wilson interval, 0.0258 to 0.1986, alongside. Statisticians recommend Wilson-type intervals because they keep closer to the stated confidence level for small samples.

What the calculator does not do

  • One sample only. There is no interval for the difference between two means or two proportions. Use (x̄₁ − x̄₂) ± z*√(σ₁²/n₁ + σ₂²/n₂) by hand.
  • Four confidence levels. It offers 90%, 95%, 98% and 99%. For another level, find z* from the Probability Calculator and work by hand.
  • Means and proportions only. It has no interval for a standard deviation or a variance.

Common mistakes

  • Using z when σ is unknown. If you only have the sample standard deviation, use t with n − 1 degrees of freedom.
  • Forgetting the square root of n. The standard error is σ/√n, not σ/n.
  • Saying "95% chance the mean is in this interval". The 95% belongs to the method, not to one interval.
  • Rounding the sample size down. Round n up, or the margin of error will be slightly too big.
  • Using the proportion interval with very few successes. Check there are at least 5 successes and 5 failures, or use the Wilson interval.

Practise statistics in a short timed paper

The normal distribution and hypothesis tests behind confidence intervals come up in AP Statistics practice, and in A-level Maths: Statistics in the UK. Each daily paper is a short timed paper of 8 questions worth 25 to 35 marks, and the papers mix topics. To test a claim rather than estimate a value, see our p-value calculator guide.

Common questions

How do you calculate a confidence interval?
Find the estimate (the sample mean or proportion), the standard error, and the critical value for your level. The interval is the estimate plus or minus the critical value times the standard error.
What is the z value for a 95% confidence interval?
1.960. For 90% it is 1.645, for 98% 2.326 and for 99% 2.576.
When do you use t instead of z?
Use t for a mean when the population standard deviation is unknown and you estimate it from the sample. Use z when σ is known, and for proportions.
What is the margin of error?
The amount added to and taken from the estimate: the critical value times the standard error. It is half the width of the interval.
Why is a 99% confidence interval wider than a 95% one?
To be more confident of capturing the true value you need a bigger critical value, 2.576 instead of 1.960, which widens the interval.
How does sample size affect a confidence interval?
A bigger sample gives a narrower interval. The margin of error depends on 1/√n, so four times the sample size halves it.

Revision cards

Say the answer first, then flip the card to check it.

Where to go next

  • Solve it

    Confidence Interval Calculator

    Build confidence intervals for means and proportions

    Open the tool
  • Learn it

    Probability

    Distributions, expected values and the maths behind uncertainty

    Start the course
  • Test it

    AP Statistics

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Maths · AlgebraInterval notation: brackets, infinity and examplesInterval notation explained: when to use square or round brackets, how to write infinity and unions, and how to turn inequalities into intervals.