Confidence Interval Calculator

Calculate a confidence interval for a population mean (t or z) or a proportion (with the Wilson interval), with the margin of error, standard error and critical value.

Confidence interval calculator
Interval for a
Confidence interval

    Working

    Mean: x̄ ± t* × s ÷ √n (or z* × σ ÷ √n when σ is known). Proportion: p̂ ± z* × √(p̂(1 − p̂) ÷ n), with the Wilson score interval shown as a more accurate alternative. Assumes a random sample.

    On this page

    A confidence interval calculator gives a range of plausible values for a population mean or proportion, based on a sample, at a chosen confidence level such as 95%. For a mean, it uses the t-distribution when the standard deviation comes from your sample and the normal (z) distribution when the population standard deviation is known. For a proportion, it gives the standard interval and the more accurate Wilson score interval, with the standard error, critical value and margin of error.

    For example, a sample of 40 with a mean of 72.5 and a standard deviation of 8.2 gives a 95% confidence interval of 69.88 to 75.12. If 230 out of 400 people say yes, the 95% interval for the true proportion is about 52.7% to 62.3%.

    How to use the calculator

    1. Choose Mean for averages, such as heights, scores or times, or Proportion for percentages, such as the share of customers who are satisfied.
    2. For a mean, enter the sample mean, the standard deviation and the sample size, and say whether the standard deviation came from your sample or is known for the whole population.
    3. For a proportion, enter the number of successes and the sample size.
    4. Choose a confidence level. 95% is the most common.
    5. Press Calculate to see the interval and the full working.

    What is a confidence interval?

    A sample gives you an estimate, such as an average or a percentage, but a different sample would give a slightly different number. A confidence interval puts a range around the estimate to show how precise it is. A 95% confidence interval is built by a method that captures the true population value in 95% of samples. In everyday terms, you can be 95% confident that the true value lies within the range.

    A narrower interval means a more precise estimate. Intervals get narrower with larger samples and less variable data, and wider when you ask for more confidence.

    Confidence interval for a mean

    CI = x̄ ± t* × s ÷ √n

    Here x̄ is the sample mean, s is the sample standard deviation, n is the sample size and t* is the critical value from the t-distribution with n − 1 degrees of freedom. The term s ÷ √n is the standard error of the mean, and t* × s ÷ √n is the margin of error.

    When the population standard deviation σ is genuinely known, which is rare outside textbooks and quality-control settings, use z* instead of t*: CI = x̄ ± z* × σ ÷ √n.

    Worked example

    A sample of 40 students has a mean score of 72.5 and a standard deviation of 8.2. The standard error is 8.2 ÷ √40 ≈ 1.2965. With 39 degrees of freedom, t* for 95% confidence is about 2.0227. The margin of error is 2.0227 × 1.2965 ≈ 2.6225, so the interval is 72.5 ± 2.62, or 69.88 to 75.12.

    Confidence interval for a proportion

    CI = p̂ ± z* × √(p̂(1 − p̂) ÷ n)

    Here p̂ is the sample proportion, the number of successes divided by the sample size. For 230 yes answers out of 400, p̂ = 0.575. The standard error is √(0.575 × 0.425 ÷ 400) ≈ 0.0247, and with z* = 1.96 the margin of error is about 0.0484. So the interval is 57.5% ± 4.84 percentage points, or about 52.7% to 62.3%.

    The Wilson score interval

    The simple formula above, called the Wald interval, works well when there are at least 10 successes and 10 failures. With small samples or proportions close to 0% or 100%, it can be badly off, and it can even extend below 0% or above 100%. The Wilson score interval fixes these problems and is recommended by many statisticians. For 3 successes out of 20, the simple interval is 0% to 30.6%, while the Wilson interval is 5.2% to 36.0%. The calculator shows both.

    Critical values

    Confidence levelz*t* (df = 9)t* (df = 29)
    90%1.6451.8331.699
    95%1.9602.2622.045
    99%2.5763.2502.756

    The t-values are larger than z-values for small samples, which widens the interval to allow for the extra uncertainty in estimating the standard deviation. As the sample grows, t* gets closer to z*.

    t or z: which should you use?

    • Use t when the standard deviation is calculated from your sample. This is the usual case.
    • Use z when the population standard deviation is known from long experience or a specification.
    • For proportions, z is standard, because the standard error comes from the proportion itself.

    What affects the width of the interval?

    • Sample size: the width shrinks with √n, so quadrupling the sample halves the margin of error.
    • Variability: more spread-out data gives a wider interval.
    • Confidence level: 99% intervals are wider than 95% intervals, which are wider than 90% intervals. More confidence costs precision.

    Interpreting a confidence interval correctly

    A 95% confidence interval does not mean there’s a 95% chance that this particular interval contains the true value; once calculated, it either does or doesn’t. It means the method produces intervals that capture the true value 95% of the time. It also doesn’t mean that 95% of individual values fall inside the interval; that’s a different idea, called a prediction or reference interval, and it’s much wider.

    Confidence intervals are useful for comparisons. If the interval for a difference between two groups excludes zero, the difference is statistically significant at the matching level. If two separate intervals overlap only slightly, the groups may still differ, so it’s better to calculate an interval for the difference directly.

    Same data, different confidence levels

    Using the sample of 40 students again, with a mean of 72.5 and a standard deviation of 8.2, here’s how the interval changes with the confidence level. At 90%, t* is about 1.685, giving roughly 70.32 to 74.68. At 95%, it’s 69.88 to 75.12. At 99%, t* is about 2.708, giving roughly 68.99 to 76.01. The estimate in the middle never changes; only the width of the safety margin around it does. Choose the level before you look at the results, based on how costly it would be to be wrong.

    Confidence intervals in the news

    When a poll reports that 48% of voters support a candidate “with a margin of error of plus or minus 3 points”, it’s describing a 95% confidence interval from 45% to 51%. If two candidates are at 48% and 46%, their intervals overlap heavily, so the poll can’t say who is really ahead. Medical studies report confidence intervals for treatment effects in the same way, and an interval that includes no effect at all is a sign that the result may be due to chance.

    Assumptions

    • The data comes from a random sample, and the observations are independent.
    • For a mean, the data is roughly normal, or the sample is large enough (often 30 or more) for the central limit theorem to apply.
    • For a proportion, there are enough successes and failures, or the Wilson interval is used.

    Common mistakes

    • Using z instead of t for a small sample with an estimated standard deviation, which makes the interval too narrow.
    • Entering the standard error instead of the standard deviation.
    • Treating a proportion’s margin of error in percentage points as a percentage of the estimate.
    • Assuming a confidence interval fixes bias from a non-random sample. It only measures random sampling error.

    Related calculations

    Two other tools work well alongside this one: the standard deviation calculator, to find the standard deviation and variance of a data set, and the p-value calculator, to find the p-value from a test statistic.

    Frequently asked questions

    For a mean, take the sample mean plus or minus t* × s ÷ √n, where t* is about 2 for moderate samples. For a proportion, use p̂ ± 1.96 × √(p̂(1 − p̂) ÷ n).

    It means the method captures the true population value in 95% of samples. You can be 95% confident the true value lies within the range.

    Use t when the standard deviation is estimated from your sample, which is almost always. Use z only when the population standard deviation is known.

    Increase the sample size, reduce variability with better measurement, or accept a lower confidence level.

    Half the width of the confidence interval: the critical value multiplied by the standard error.

    An improved interval for proportions that stays within 0% to 100% and is more accurate for small samples or extreme proportions.

    No. It describes uncertainty about the population mean or proportion, not the spread of individual values.

    It depends on the margin of error you want. Use a sample size calculator to work it out before collecting data.

    The t-distribution has heavier tails to allow for the uncertainty of estimating the standard deviation from a small sample. It approaches 1.96 as the sample grows.

    For a single sample mean, the degrees of freedom are n − 1. They set which t-distribution is used.

    For a mean, yes, if values can be negative. For a proportion, a correct interval stays between 0% and 100%.