↑↓ to move ↵ to open Esc to close Browse all tools

Confidence Interval Calculator

Get the confidence interval for a mean, a proportion or the difference between two groups, from summary statistics or your raw data. You see the critical value, the margin of error and each step of the formula.

What do you want to estimate?

Your data
Standard deviation
Variances
Method
Sample
Group 2
Successes can also be a percentage of n, like 64%.
95% confidence interval

Try an example

Step by step

    Runs on your device. Nothing you enter is sent to a server.

    Confidence Interval Calculator by Freebiefy, free online tools

    Embed this tool on your site

    Paste this code into your page. The tool runs in the visitor's browser, free and without signup. The height adjusts to the content. All tools you can embed

    What a confidence interval is

    A sample mean or a sample proportion is an estimate, and a different sample would give a slightly different number. A confidence interval puts a range around the estimate that reflects this sampling error. Every interval on this page has the same shape:

    General form
    estimate ± critical value × standard error
    The product of the critical value and the standard error is the margin of error.

    The confidence level, often 95%, describes the method: if you drew many samples and built an interval from each, about 95% of those intervals would contain the true population value.

    Formulas

    IntervalFormulaCritical value
    Mean, σ knownx̄ ± z* × σ/√nz*
    Mean, σ unknownx̄ ± t* × s/√nt* with n − 1 df
    Proportion, Waldp̂ ± z* × √(p̂(1 − p̂)/n)z*
    Proportion, Wilson(p̂ + z²/2n ± z√(p̂(1 − p̂)/n + z²/4n²)) ÷ (1 + z²/n)z*
    Two means, Welchx̄₁ − x̄₂ ± t* × √(s₁²/n₁ + s₂²/n₂)t* with Welch df
    Two means, pooledx̄₁ − x̄₂ ± t* × sp√(1/n₁ + 1/n₂)t* with n₁ + n₂ − 2 df
    Two proportionsp̂₁ − p̂₂ ± z* × √(p̂₁(1 − p̂₁)/n₁ + p̂₂(1 − p̂₂)/n₂)z*

    Here x̄ is the sample mean, s the sample standard deviation, σ the population standard deviation, n the sample size, p̂ the sample proportion and sp the pooled standard deviation, √(((n₁ − 1)s₁² + (n₂ − 1)s₂²) ÷ (n₁ + n₂ − 2)).

    Worked examples

    A mean. A sample of 30 pitchers has a mean age of 28 years and a standard deviation of 4.4 years. The standard error is 4.4 ÷ √30 ≈ 0.8033. With 29 degrees of freedom the 95% t value is about 2.0452, so the margin of error is 2.0452 × 0.8033 ≈ 1.643 and the interval runs from 26.357 to 29.643 years. Treating 4.4 as a known σ would use z* = 1.960 instead and give a slightly narrower 26.426 to 29.574.

    A proportion. In a sample of 1,168 adults, 747 say they are not financially prepared for retirement, so p̂ = 747 ÷ 1,168 ≈ 0.6396. The sample has 747 successes and 421 failures, both well above 10. The standard error is √(0.6396 × 0.3604 ÷ 1,168) ≈ 0.01405, and the 95% Wald interval is 0.6396 ± 1.960 × 0.01405, or 0.6120 to 0.6671. The Wilson interval, 0.6116 to 0.6666, is almost the same because the sample is large.

    z or t: the critical value

    The critical value cuts off (100% − confidence level) ÷ 2 in each tail. When the standard deviation comes from the sample, which is almost always the case, the interval uses Student’s t distribution with n − 1 degrees of freedom. Its tails are heavier than the normal curve’s, so t* is larger than z* for small samples and gets close to it as n grows:

    Confidencez*t*, 9 df (n = 10)t*, 29 df (n = 30)
    80%1.2821.3831.311
    90%1.6451.8331.699
    95%1.9602.2622.045
    98%2.3262.8212.462
    99%2.5763.2502.756
    99.9%3.2914.7813.659

    The t values come from the regularized incomplete beta function and match all three printed decimals of the NIST/SEMATECH table of t critical values in every row we checked: 1, 2, 5, 10, 20, 30, 50 and 100 degrees of freedom and the normal limit, at six confidence levels each. The z-score calculator finds z for any other area.

    Wald or Wilson for proportions

    The Wald interval is the one most textbooks teach. It relies on the normal approximation, which Penn State’s course material checks with a simple rule: at least 10 successes and 10 failures in the sample. For small samples or proportions close to 0 or 1, the Wald interval can be too narrow and can even reach below 0 or above 1, which the NIST handbook points out. The Wilson score interval avoids this. For 4 successes out of 20, Wald gives 0.0247 to 0.3753 and Wilson 0.0807 to 0.4160, an interval that is not centered on p̂ = 0.2.

    Two groups

    For the difference of two means the calculator uses Welch’s interval by default, which does not assume equal variances. Its degrees of freedom come from the Welch-Satterthwaite formula and are usually not a whole number. Some software rounds them down: Penn State’s example with 17 sophomores and 13 juniors reports 26 degrees of freedom and the interval −0.454 to 0.173, while the unrounded 26.63 gives −0.454 to 0.172. Choose the pooled interval only when you have good reason to assume equal variances. If an interval for a difference contains 0, the data do not show a difference at that confidence level.

    Planning and checking your data

    The interval is only as good as the sample: it assumes a random sample, independent observations and, for small samples of a mean, data that are roughly normal. To plan how many responses you need for a target margin of error, use the sample size calculator. To see the mean and standard deviation of raw data step by step, use the standard deviation calculator; this page uses the same sample standard deviation, dividing by n − 1.

    How to use the confidence interval calculator

    1. 1Choose Mean, Proportion, Two means or Two proportions, and set the confidence level, like 95%.
    2. 2For a mean, type the sample size, mean and standard deviation, or choose Raw data and paste your numbers. Pick From the sample (t) or σ known (z).
    3. 3For a proportion, type the number of successes and the sample size, and pick Wald (normal) or Wilson score.
    4. 4Read the interval with its margin of error, follow the steps, and press Copy result or Copy link.

    Sources

    Frequently asked questions

    What does a 95% confidence interval mean?

    It comes from a method that captures the true population value in 95% of samples. For one sample, you say: we are 95% confident that the population mean lies between the two limits. It does not mean that 95% of the data lie in the interval, and it does not say there is a 95% chance for one fixed interval; the true value is either inside or not.

    Should I use z or t?

    Use t when you estimate the standard deviation from the sample, which is almost always the case. Use z only when the population standard deviation σ is known from outside the sample. With large samples the two give nearly the same interval, because the t value approaches the z value as the degrees of freedom grow.

    What is the margin of error?

    The margin of error is the critical value times the standard error: the half-width of the interval. A 95% interval of 28 ± 1.643 has a margin of error of 1.643. It shrinks with the square root of the sample size, so four times as many observations halve it.

    Wald or Wilson for a proportion?

    The Wald interval p̂ ± z√(p̂(1 − p̂)/n) is the textbook formula and works well when the sample has at least 10 successes and 10 failures. With fewer, or with a proportion near 0 or 1, it can be too narrow or even go below 0. The Wilson score interval stays between 0 and 1 and is the better choice then. The calculator shows both.

    How does the confidence level change the interval?

    A higher confidence level needs a larger critical value, so the interval gets wider: for a proportion the z value is 1.645 at 90%, 1.960 at 95% and 2.576 at 99%. You trade precision for confidence. To get a narrower interval at the same level, collect a larger sample.

    What if the interval for a difference contains 0?

    Then the data are consistent with no difference between the two groups at that confidence level. If the whole interval lies above or below 0, the difference is statistically significant at the matching level, for example at the 5% level for a 95% interval.