Epidemiology & clinical research

Confidence Interval Calculator: Mean, Median, Proportion, Differences, Odds Ratio, Relative Risk and Rates

Get a confidence interval for almost any common estimate: a mean (from summary numbers or raw data), a median, a proportion with six methods, the difference between two means or two proportions, an odds ratio or relative risk, a rate, a correlation coefficient or a standard deviation. Every result shows the formula, the margin of error and a sentence you can paste into your results.

✅ No login needed100% freeRuns in your browserYour data stays on your device
Confidence Interval Calculator✅ Free · no login📚 Cite this tool
Your data never leaves your PC. Your data is analysed on your own computer or phone, even when you upload a CSV or Excel file. Nothing is uploaded, stored or seen by Codanics, and no login is needed.
  • PriceFree, no login or sign-up needed
  • Your dataProcessed in your browser, never uploaded
  • Works onPhone, tablet or computer, any modern browser
  • Made byDr. Muhammad Aammar Tufail, Codanics
  • Published17 November 2026
  • Last updated16 November 2026

📚 How to cite this tool

This tool is free. If it helped your thesis, paper, report or assignment, please cite it. It keeps the tools free and helps other students find them.

Citation · APA 7th edition

Tufail, M. A. (2026). Confidence interval calculator: mean, median, proportion, differences, odds ratio, relative risk and rates [Online tool]. Codanics. Retrieved 16 November 2026, from https://codanics.com/tools/confidence-interval-calculator/

In-text citation: (Tufail, 2026) · Narrative: Tufail (2026)

The access date is today’s date, filled in automatically. Author: Muhammad Aammar Tufail. Published 17 November 2026.

🚀 Follow Codanics channel on WhatsApp for more updatesNew free tools, scholarships, PhD positions and research tips, straight to your phone. Free lessons on YouTube too.

How to use the confidence interval calculator

  1. Set the confidence level (95% is the usual choice) at the top. It applies to every tab.
  2. Pick the tab for your estimate: a mean or median, a single proportion, two means, two proportions (with RR and OR), or a rate, correlation or standard deviation.
  3. Type your numbers. For a mean you can enter the mean, SD and n from a paper, or paste the raw values to also get the median and its interval.
  4. Read the interval and the method used. For proportions, all six common methods are shown side by side, with the recommended Wilson interval highlighted.
  5. Copy the results sentence or the table into your report.

What a confidence interval means

A 95% confidence interval gives a range of values for the true population value that are compatible with your data. If you repeated the study many times and calculated a 95% CI each time, about 95% of those intervals would contain the true value. A narrow interval means a precise estimate; a wide one means more data are needed. Journals and the CONSORT, STROBE and STARD guidelines ask for confidence intervals rather than p-values alone, because they show both the size of an effect and its uncertainty.

Formulas used

Mean (t): x̄ ± t(1 − α/2, n − 1) × s/√n (z instead of t if σ is known) Median: order statistics k and n − k + 1, k = qbinom(α/2, n, ½) Wilson score: [p + z²/2n ± z√(p(1 − p)/n + z²/4n²)] / (1 + z²/n) Clopper–Pearson: Beta(α/2; x, n − x + 1) to Beta(1 − α/2; x + 1, n − x) Agresti–Coull: p̃ ± z√(p̃(1 − p̃)/ñ), ñ = n + z², p̃ = (x + z²/2)/ñ Jeffreys: Beta(α/2; x + ½, n − x + ½) to Beta(1 − α/2; x + ½, n − x + ½) Two means (Welch): (x̄₁ − x̄₂) ± t(df_W) × √(s₁²/n₁ + s₂²/n₂) Two proportions: Newcombe hybrid score interval (method 10) RR, OR: exp(ln est ± z × SE), SE(ln RR) = √(1/a − 1/n₁ + 1/c − 1/n₂), SE(ln OR) = √(1/a + 1/b + 1/c + 1/d) Poisson count: [χ²(α/2, 2x)/2, χ²(1 − α/2, 2x + 2)/2] Correlation: tanh( atanh(r) ± z/√(n − 3) ) Standard deviation: √((n − 1)s²/χ²(1 − α/2)) to √((n − 1)s²/χ²(α/2))

Which interval for a proportion?

The Wald interval taught in many textbooks (p ± 1.96√(p(1 − p)/n)) can be badly wrong when n is small or p is close to 0% or 100%, and it can even go below 0. The Wilson score interval is the best general choice and is recommended by Agresti and Coull (1998) and by Newcombe (1998). The Clopper–Pearson exact interval guarantees at least 95% coverage but is wider than necessary; many clinical journals still ask for it. Whatever you choose, name the method in your report.

Checked against R. Means and differences match t.test(); proportions match binom::binom.confint() (Wilson, exact, Agresti–Coull, asymptotic), prop.test() and binom.test(); Jeffreys matches qbeta(); the Agresti–Caffo interval matches PropCIs::wald2ci(adjust = "AC"); counts match poisson.test(); and the correlation interval matches cor.test().

References: Agresti A, Coull BA (1998) Am Stat 52:119–126 · Newcombe RG (1998) Stat Med 17:857–872 and 873–890 · Brown LD, Cai TT, DasGupta A (2001) Stat Sci 16:101–133 · Agresti A, Caffo B (2000) Am Stat 54:280–288 · Altman DG et al. (2000) Statistics with Confidence, 2nd ed. BMJ Books.

Learn the statistics behind these numbers. Codanics has free statistics, R and Python lessons on YouTube and full courses for researchers.

Frequently asked questions

How do I calculate a 95% confidence interval for a mean?

Calculate the standard error (SD ÷ √n), multiply it by the t critical value for n − 1 degrees of freedom (about 2.02 for n = 40), and add and subtract the result from the mean. For a mean of 72.4, SD 9.8 and n 40, that gives 69.27 to 75.53.

What is the difference between a confidence interval and a margin of error?

The margin of error is half the width of the confidence interval. A survey result of 30% ± 3% has a margin of error of 3 percentage points and a confidence interval of 27% to 33%.

Why do my confidence interval results differ from Excel's CONFIDENCE function?

Excel’s CONFIDENCE.NORM uses the normal (z) distribution, which assumes the population SD is known. With a sample SD, the t distribution (CONFIDENCE.T) is correct and gives a slightly wider interval, especially for small samples.

Which confidence interval should I use for a proportion with 0 events?

Use the Wilson or Clopper–Pearson interval. The Wald interval gives 0 to 0, which is meaningless. As a quick check, the ‘rule of three’ says the 95% upper limit is about 3/n.

Does a 95% CI that excludes zero mean the result is significant?

For a difference, yes: if the 95% CI excludes 0, the two-sided p-value is below 0.05. For a ratio (RR, OR), the null value is 1 instead of 0.

Can I get a confidence interval for a median?

Yes. Choose Raw data on the Mean / median tab. The tool gives a distribution-free interval based on order statistics, which does not assume a normal distribution.

Do I need to log in or create an account to use the confidence interval calculator?

No. There is no login, no sign-up and no email required. Open the page and start using it straight away, for free, on any device.

How do I cite this tool in my thesis or paper?

Use the citation box on this page. In APA 7th edition: Tufail, M. A. (2026). Confidence interval calculator: mean, median, proportion, differences, odds ratio, relative risk and rates [Online tool]. Codanics. Retrieved [date you used it], from https://codanics.com/tools/confidence-interval-calculator/. BibTeX, RIS (EndNote, Mendeley, Zotero), MLA, Harvard, Chicago and Vancouver formats are also available.

Free guides and courses from Codanics

More free tools

See all free Codanics tools → · Codanics on YouTube · WhatsApp channel

Made by Dr. Muhammad Aammar Tufail, Codanics. First published 17 November 2026, last updated 16 November 2026. Found a bug or have an idea for a new tool? Tell us on the WhatsApp channel or in the comments on YouTube. Results are for learning and planning; check important analyses with a statistician or your supervisor.