CCalclabhub

Statistics

How To Calculate A Confidence Interval

A confidence interval turns a single sample estimate into a range, and the width of that range is the honest measure of how much the sample actually tells you.

Quick Answer

confidence interval = mean +/- z x (standard deviation / sqrt(n))

x bar
Sample mean, the centre of the interval
s
Sample standard deviation
n
Sample size
z
Critical value for the chosen confidence level

Divide the standard deviation by the square root of the sample size to get the standard error, multiply by the z score for your confidence level, then add and subtract that margin from the mean. A mean of 100 with standard error 2.5 gives 95.1 to 104.9 at 95 percent confidence.

What Is A Confidence Interval?

A confidence interval is a range around a sample estimate that is likely to contain the true population value. A sample mean of a hundred with a margin of error of 4.9 gives an interval from 95.1 to 104.9 at ninety five percent confidence.

The margin of error is the z score multiplied by the standard error. The standard error is the standard deviation divided by the square root of the sample size, and it is the standard deviation of the sample mean rather than of the data.

The square root of n is why larger samples help, and why they help with diminishing returns. Quadrupling the sample size halves the margin of error. Going from a hundred to four hundred observations buys the same precision as going from four to sixteen.

The z score encodes how confident you want to be. Roughly 1.645 for ninety percent, 1.96 for ninety five, and 2.576 for ninety nine. Wider confidence requires a larger multiplier, so the interval gets wider exactly when you are asking for more certainty.

What the interval means is narrower than most people assume. It does not say that ninety five percent of the data lies inside it, and it does not give a ninety five percent probability that the true value is in this particular interval under the standard frequentist reading.

The correct interpretation is about the procedure. If you took many samples and built an interval from each in the same way, about ninety five percent of those intervals would contain the true value. The method has a ninety five percent success rate, not the specific interval.

The calculation assumes the sample is random and the observations are independent. A biased sample produces a confident, narrow, and completely wrong interval, which is the failure mode worth worrying about most.

For small samples, the z score is replaced by a t value from the t distribution, which is wider to reflect the extra uncertainty in estimating the standard deviation from few observations. Below about thirty observations the difference matters.

A confidence interval for a proportion uses a slightly different standard error, the square root of p times one minus p over n. The structure is identical: an estimate plus or minus a multiplier times a standard error.

Reporting an interval is far more informative than reporting a single number. Two studies with the same mean but very different sample sizes have very different intervals, and the difference is exactly the uncertainty that a bare point estimate hides.

Finally, a wide interval is not a failure. It is an accurate statement that the data does not pin the value down precisely. Narrowing it requires more data, a better measurement process, or accepting less confidence.

Formula

SE = s / sqrt(n)

The standard deviation of the sample mean. Shrinks with the square root of the sample size.

SymbolMeaning
SEStandard error
sStandard deviation
nSample size

margin = z x SE

The half width of the interval. The z score sets the confidence level.

SymbolMeaning
EMargin of error
zCritical value
SEStandard error

mean +/- margin

The lower bound is the mean minus the margin and the upper bound is the mean plus it.

SymbolMeaning
lowerLower bound
upperUpper bound
meanSample mean
EMargin of error

How To Calculate A Confidence Interval

  1. 1

    Work out the standard error

    Divide the standard deviation by the square root of the sample size. A standard deviation of fifteen with thirty six observations gives an error of 2.5.

  2. 2

    Choose the z score for your confidence level

    1.645 for ninety percent, 1.96 for ninety five and 2.576 for ninety nine. Rounding 1.96 to 2 is common and makes the interval slightly wider than stated.

  3. 3

    Multiply to get the margin of error

    1.96 times 2.5 is 4.9. This is the half width, not the full width, and confusing the two halves or doubles the reported interval.

  4. 4

    Add and subtract from the sample mean

    A mean of a hundred gives a lower bound of 95.1 and an upper bound of 104.9. The interval is centred on the sample mean by construction.

  5. 5

    Check the assumptions before trusting it

    Random sampling, independent observations and either a roughly normal distribution or a large enough sample. A biased sample gives a precise but meaningless interval.

Examples

Example 1: A mean of 100 from 36 observations

Sample mean
100
Standard deviation
15
Sample size
36
Z score
1.96
StepCalculationResult
Standard error15 / sqrt(36)2.5
Lower bound100 - 4.995.1
Margin of error1.96 x 2.54.9

Result: The margin of error is 4.9, giving a 95 percent interval from 95.1 to 104.9 around the sample mean.

Example 2: A mean of 50 with a 99 percent interval

Sample mean
50
Standard deviation
10
Sample size
25
Z score
2.576
StepCalculationResult
Standard error10 / sqrt(25)2
Lower bound50 - 5.15244.848
Margin of error2.576 x 25.152

Result: Asking for 99 percent confidence widens the margin to 5.152, giving an interval of 44.848 to 55.152.

Example 3: A mean of 200 from 100 observations

Sample mean
200
Standard deviation
30
Sample size
100
Z score
1.645
StepCalculationResult
Standard error30 / sqrt(100)3
Lower bound200 - 4.935195.065
Margin of error1.645 x 34.935

Result: A hundred observations with a ninety percent level gives a margin of 4.935, an interval from 195.065 to 204.935.

Calculator

Margin of error

4.9

Standard error
2.5
Lower bound
95.1
Upper bound
104.9

Values update as you type. This calculator covers the single scenario its formula assumes — see Common Mistakes for what it leaves out.

Prefer a full-width tool? Open the A Confidence Interval calculator page.

Common Mistakes

  • Dividing by n instead of the square root of n

    The standard error uses the square root of the sample size. Dividing by n directly makes the interval far too narrow and overstates the precision badly.

  • Reporting the margin of error as the full width

    The margin is the half width. The interval spans two margins, so calling 4.9 the width when the interval is 9.8 wide halves the reported uncertainty.

  • Saying 95 percent of the data lies in the interval

    That is a different and much wider interval. A ninety five percent confidence interval is about the location of the mean, not about the spread of individual observations.

  • Using a z score for a small sample

    Below roughly thirty observations the t distribution should be used instead, and it gives a wider interval to reflect the extra uncertainty.

  • Ignoring the sampling assumptions

    The formula assumes random, independent observations. A biased sample produces a tight interval around the wrong value, which is worse than a wide honest one.

  • Choosing the z score after seeing the data

    The confidence level should be fixed in advance. Selecting 99 percent only when the result looks marginal is a form of cherry picking.

  • Comparing overlapping intervals as if they proved no difference

    Overlapping confidence intervals do not by themselves establish that two estimates are statistically indistinguishable. The comparison needs its own test.

FAQ

What is the formula for a confidence interval?

The sample mean plus or minus the z score multiplied by the standard error, where the standard error is the standard deviation divided by the square root of the sample size.

What does a 95 percent confidence interval actually mean?

It means the method produces intervals that capture the true value about ninety five percent of the time. It is a statement about the procedure, not a probability about this particular interval.

Why does a bigger sample give a narrower interval?

Because the standard error divides by the square root of the sample size. Quadrupling the sample halves the margin of error, so precision improves with diminishing returns.

What z score should I use?

About 1.645 for ninety percent confidence, 1.96 for ninety five and 2.576 for ninety nine. For small samples use the corresponding t value instead.

Can the interval be too narrow to be believable?

Yes, and that usually signals a problem. A very narrow interval from a small or biased sample suggests the assumptions were violated rather than that the estimate is precise.

How do I interpret overlapping intervals?

Overlap does not prove the two estimates are the same, and non-overlap does not always prove they differ. A proper comparison of two means needs its own test.

References

  1. [1]Wikipedia, Confidence interval — https://en.wikipedia.org/wiki/Confidence_interval
  2. [2]Wikipedia, Standard error — https://en.wikipedia.org/wiki/Standard_error
  3. [3]Wikipedia, Margin of error — https://en.wikipedia.org/wiki/Margin_of_error
  4. [4]Wikipedia, Student's t-distribution — https://en.wikipedia.org/wiki/Student%27s_t-distribution