ToolNimba
๐Ÿ”ข Math & Numbers

Confidence Interval Formula: How to Calculate It (With Examples)

Shihab Mia By Shihab Mia June 27, 2026 8 min read

Illustration of a bell curve with a shaded central band representing a 95 percent confidence interval around a sample mean

Quick answer

A confidence interval for a mean is sample mean plus or minus the margin of error, where the margin of error = z times (standard deviation / square root of n). For 95 percent confidence, z = 1.96. So if your mean is 50, the standard deviation is 10, and n is 100, the margin is 1.96 times (10 / 10) = 1.96, giving an interval of 48.04 to 51.96.

When you calculate an average from a sample, that average is only a best guess at the true average for the whole population. A confidence interval turns that single guess into a range, a band of values that is plausible for the real population mean. It is one of the most quoted numbers in research, polling, and business analytics, and the formula behind it is short enough to work out by hand.

In this guide we will define a confidence interval, break the formula down piece by piece, list the z values you need, walk through a full worked example, cover the small sample t case, and clear up what 95 percent confidence actually means. We will also flag the mistakes that trip people up most often.

What is a confidence interval?

A confidence interval is a range of values, calculated from your sample, that is likely to contain the true population mean. Instead of saying the average is exactly 50, you say the average is somewhere between roughly 48 and 52 with a stated level of confidence. The width of that range reflects how much uncertainty there is in your estimate.

Every confidence interval has two ingredients: a point estimate (your sample mean, which sits in the middle) and a margin of error (how far you reach out on either side). Add and subtract the margin from the mean and you have the interval. A narrow interval signals a precise estimate; a wide one signals more uncertainty.

Confidence intervals are closely tied to the standard error of the mean and to related ideas like percent error, so understanding one makes the others click into place.

The confidence interval formula

The confidence interval for a population mean is calculated like this:

The formula

CI = sample mean plus or minus z times (standard deviation / square root of n)

The part after the plus or minus sign is the margin of error. Here is what each symbol means:

  • Sample mean is the average of your sample, the center of the interval.
  • z is the critical value for your chosen confidence level (for example, 1.96 for 95 percent).
  • standard deviation is the spread of the data, written as the Greek letter sigma when the population value is known, or s when estimated from the sample.
  • n is the sample size, the number of observations you collected.
  • standard deviation / square root of n is the standard error, which measures how precise the mean is.

Notice the structure: you take the standard error of the mean and multiply it by a critical value that depends on how confident you want to be. A higher confidence level uses a larger z, which widens the interval. Because n sits under a square root, you need to quadruple your sample size to cut the margin of error in half.

Z values for common confidence levels

The z value, also called the critical value or z star, is fixed for each confidence level. Memorize the three most common ones and you can build most intervals on sight.

Critical z values for the most common confidence levels

Confidence levelCritical value (z)What it covers
90 percent1.645Central 90 percent of the normal curve
95 percent1.96Central 95 percent of the normal curve
99 percent2.576Central 99 percent of the normal curve

By far the most common choice is 95 percent, with z = 1.96. Use 1.645 when 90 percent confidence is enough and you want a tighter range, and 2.576 when you need 99 percent confidence and can accept a wider range.

Conceptual illustration showing a normal curve with a shaded central band and a sample mean marker at the center
The confidence level sets how much of the curve the interval covers; higher confidence means a wider band.

Worked example: a 95 percent confidence interval

Suppose you measure the daily screen time of 100 users and find a sample mean of 50 minutes with a standard deviation of 10 minutes. Here is how to build a 95 percent confidence interval for the true average screen time.

  1. Write down your numbers. Sample mean = 50, standard deviation = 10, n = 100.
  2. Pick the z value. For 95 percent confidence, z = 1.96.
  3. Find the standard error. Divide the standard deviation by the square root of n: 10 / square root of 100 = 10 / 10 = 1.
  4. Calculate the margin of error. Multiply z by the standard error: 1.96 times 1 = 1.96.
  5. Build the interval. Subtract and add the margin: 50 minus 1.96 = 48.04, and 50 plus 1.96 = 51.96.
  6. State the result. You are 95 percent confident that the true average screen time is between 48.04 and 51.96 minutes.

That is the whole calculation. The hardest part is usually getting the standard deviation and choosing the right critical value; the arithmetic after that is quick. If you want to check your work fast, our average calculator can confirm the mean before you start.

When to use the t distribution instead of z

The z formula assumes you know the population standard deviation, or that your sample is large enough for the sample standard deviation to stand in safely. With small samples and an unknown population standard deviation, that assumption breaks down, and you should use the t distribution instead.

The structure of the formula stays identical. You simply swap the z critical value for a t critical value:

The small sample version

CI = sample mean plus or minus t times (s / square root of n)

The t value depends on both your confidence level and your degrees of freedom, which equal n minus 1. For small samples the t value is larger than the matching z value, which widens the interval to account for the extra uncertainty of estimating the spread from limited data. As the sample grows past roughly 30, the t value drifts toward the z value and the two approaches nearly agree.

Choosing between z and t for a confidence interval of the mean

SituationUse this critical value
Population standard deviation knownz value
Large sample (n at least 30), standard deviation estimatedz value is acceptable
Small sample, population standard deviation unknownt value (degrees of freedom = n minus 1)

What does 95 percent confidence actually mean?

This is the most misunderstood idea in all of statistics. A 95 percent confidence interval does not mean there is a 95 percent chance the true mean falls inside your specific interval. The true mean is a fixed number; it is either in your interval or it is not.

What 95 percent confidence really means is this: if you repeated the sampling process many times and built an interval each time, about 95 percent of those intervals would contain the true population mean. The confidence is a property of the long run method, not of any single interval you happen to compute.

Confidence describes how often the method works across many samples, not the probability that one particular interval is correct.

In everyday practice, you treat your one interval as a reasonable range of plausible values for the true mean, while keeping in mind that there is always a small chance your sample was one of the unlucky ones that missed.

Common mistakes to avoid

The confidence interval formula is short, but a handful of errors show up again and again. Watch out for these.

  • Misreading what confidence means. Saying there is a 95 percent chance the true mean is in your one interval is the classic error. The 95 percent refers to the long run success rate of the method.
  • Using z when you should use t. With a small sample and an unknown population standard deviation, the z formula gives an interval that is too narrow and overconfident.
  • Forgetting the square root of n. The margin divides the standard deviation by the square root of the sample size, not by n itself. Skipping the square root shrinks the interval far too much.
  • Picking the wrong z value. Mixing up 1.645, 1.96, and 2.576 quietly changes your confidence level. Double check which level you actually want.
  • Ignoring sampling bias. A biased sample produces a tidy, narrow interval centered on the wrong number, which looks precise but is simply precisely wrong.

Where confidence intervals are used

Confidence intervals are not just an academic exercise. They appear wherever people estimate an unknown average from a sample.

  • Polling and surveys. The plus or minus figure quoted in election polls is a confidence interval around a percentage.
  • Medical research. Clinical trials report confidence intervals to show the plausible range of a treatment effect, not just a single number.
  • Business analytics. Teams compare average revenue per user or conversion rates and use intervals to judge whether a difference is real.
  • Quality control. Factories track confidence intervals on measured dimensions to confirm a process is staying on target.

If you are working through related topics, our standard error guide covers the precision measure that sits at the heart of every interval, and the average calculator walkthrough shows how to nail down the mean that anchors it.

๐Ÿ“Š Try the free tool Confidence Interval Calculator Free confidence interval calculator for a mean. Enter sample mean, standard deviation and size, pick 90, 95 or 99% and get the margin of error and bounds fast.

A confidence interval looks intimidating until you see that it is just your sample mean plus or minus a margin of error, and that the margin is a critical value times the standard error. Pick your confidence level, grab the matching z value (or a t value for small samples), multiply by the standard deviation over the square root of n, and add and subtract from the mean. Remember that the confidence describes how often the method succeeds over many samples, not the certainty of any single interval, and you will read and build these ranges with confidence.

Frequently asked questions

Tools used in this guide

Keep reading