Short answer

A confidence interval calculator turns a sample result into a range of plausible values for the true figure. Convertica's free confidence interval calculator covers a mean (t or z), a proportion such as a conversion rate (Wilson score interval) and the margin of error of a survey, at any confidence level, and shows each formula.

  • Every interval has the same shape: an estimate, plus or minus a critical value times a standard error.
  • A 95% confidence level describes the method: about 95% of intervals built this way contain the true value. It is not a 95% probability for one interval.
  • For a mean, use t whenever the standard deviation comes from the sample, which is almost always.
  • For a proportion, the Wilson interval stays inside 0% to 100% and holds up with small samples and rates near 0% or 100%, where the simple formula fails.
  • Four times the sample size gives an interval about half as wide.

Confidence interval for a mean

From a sample mean, standard deviation and sample size. Free, no sign-up. The result updates as you type.

At least 2.

Above 0, below 100.

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

95% confidence interval for the mean

46.52 to 55.48

Mean 51.00 ± 4.48. The second number is the margin of error.

Standard error: 12.00 ÷ √30 = 2.1909. Critical value: t = 2.0452 with 29 degrees of freedom.

Read it as: intervals built this way contain the true mean in about 95% of repeated samples. It is not a 95% probability for this one interval.

Formula

CI = mean ± t * s / sqrt(n)      t from Student's t, n - 1 degrees of freedom
CI = mean ± z * sigma / sqrt(n)  when the population standard deviation is known

Confidence interval for a proportion

From successes and trials, for example conversions and visitors. Wilson score interval, with the simple Wald interval beside it.

Conversions, yes answers, defects.

Visitors, respondents, items checked.

95% Wilson confidence interval for the proportion

2.68% to 3.35%

Observed proportion: 300 ÷ 10,000 = 3.00%.

Wald (simple normal) interval: 2.67% to 3.33%. The two nearly agree here, because there are plenty of successes and failures.

Width of the Wilson interval: 0.67 percentage points.

Read it as: intervals built this way contain the true proportion in about 95% of repeated samples. It is not a 95% probability for this one interval.

Formula

p      = successes / n
center = (p + z^2 / 2n) / (1 + z^2 / n)
half   = z / (1 + z^2 / n) * sqrt(p(1 - p) / n + z^2 / 4n^2)
Wilson = center ± half

Wald   = p ± z * sqrt(p(1 - p) / n)

Margin of error calculator

For a percentage from a survey or poll, from the sample size alone.

Completed responses.

Use 50 if you do not know it.

Adds the finite population correction.

Margin of error at 95% confidence

±3.10 points

50% ± 3.10 percentage points: 46.90% to 53.10%.

Critical value z = 1.9600 × standard error 1.58 points = 3.10.

50% is the widest case: any other proportion gives a smaller margin of error at this sample size.

Formula

E = z * sqrt(p(1 - p) / n)
E = z * sqrt(p(1 - p) / n) * sqrt((N - n) / (N - 1))   with a population of N

How to use the confidence interval calculator

Pick the calculator that matches what you measured. A number averaged over people or orders is a mean. A count of yes out of a total is a proportion. A survey percentage where you know only the sample size calls for the margin of error.

Which of the three calculators to use
You haveExampleUseMethod
A mean, a standard deviation and a sample sizeAverage order value, time on task, a test scoreMean calculatorStudent's t (or z)
Successes out of trialsConversions out of visitors, yes answers out of respondentsProportion calculatorWilson score interval
A survey percentage and its sample sizeA poll result, before or after it is collectedMargin of error calculatorNormal approximation
  1. Enter the sample numbers exactly as measured. Do not round the mean or the standard deviation first.
  2. Set the confidence level. 95% is the convention. Any level above 0% and below 100% works.
  3. Read the interval, then the margin of error and the critical value in the lines under it.

What is a confidence interval?

A confidence interval is a range, calculated from a sample, that is built to contain the true population value a stated share of the time. A 95% confidence interval comes from a method that captures the true value in about 95% of repeated samples. The narrower the interval, the more precisely the sample pins the value down.

The confidence level belongs to the method, not to any one interval. The true mean or proportion is a fixed number: your interval either contains it or does not, and the data cannot tell you which. What you know is that the procedure is right about 95% of the time. NIST's handbook page on confidence limits for the mean makes the same point.

So the careful way to report a result is: "the 95% confidence interval for the mean is 46.52 to 55.48". Not "there is a 95% chance the mean is between 46.52 and 55.48".

What is the confidence interval formula?

The confidence interval formula is the estimate plus or minus a margin of error, and the margin of error is a critical value multiplied by the standard error of the estimate. The critical value comes from the confidence level. The standard error measures how much the estimate would vary from one sample to the next.

confidence interval = estimate ± critical value * standard error

mean         standard error = s / sqrt(n)             critical value: t, n - 1 degrees of freedom
proportion   standard error = sqrt(p(1 - p) / n)      critical value: z

For a confidence level of 95%, alpha is 0.05 and the critical value cuts off 2.5% in each tail. The z value depends only on the level. The t value also depends on the sample size, and is larger for small samples because the standard deviation is itself an estimate.

Two-sided critical values by confidence level: z, and t for three sample sizes
Confidence levelAlphazt, n = 10t, n = 30t, n = 100
80%0.21.2821.3831.3111.290
90%0.11.6451.8331.6991.660
95%0.051.9602.2622.0451.984
98%0.022.3262.8212.4622.365
99%0.012.5763.2502.7562.626
99.9%0.0013.2914.7813.6593.392

How do you calculate a confidence interval for a mean?

To calculate a confidence interval for a mean, divide the standard deviation by the square root of the sample size to get the standard error, multiply by the t critical value for n - 1 degrees of freedom, then add and subtract the result from the sample mean. Use z only when the population standard deviation is known.

Worked example: mean order value

A sample of 30 orders has a mean value of 51.00 and a standard deviation of 12.00. These are the default values in the first calculator, made up to show the arithmetic.

  1. Standard error: 12.00 / √30 = 12.00 / 5.4772 = 2.1909.
  2. Degrees of freedom: 30 - 1 = 29. The t critical value for 95% is 2.0452.
  3. Margin of error: 2.0452 × 2.1909 = 4.4809.
  4. Interval: 51.00 ± 4.48 = 46.52 to 55.48.

With z (1.9600) the margin would be 4.29 and the interval 46.71 to 55.29: slightly narrower, and slightly too confident, because it ignores the uncertainty in the standard deviation. The gap between t and z shrinks as the sample grows, which the critical value table above shows.

When to use t and when to use z

  • t: the standard deviation was calculated from the same sample as the mean. This is the usual case, at any sample size.
  • z: the population standard deviation is known from outside the sample, for example from a long-running process with a stable spread.

Either way the method assumes a random sample of independent observations, and a sample mean that is close to normally distributed. That holds when the data are roughly normal, or when the sample is large enough for the averaging to smooth out their shape. Heavily skewed data, such as order values with a few very large orders, need a larger sample before the interval can be trusted.

How do you calculate a confidence interval for a proportion?

To calculate a confidence interval for a proportion, this calculator uses the Wilson score interval. It shifts the center toward 50% and sets the width from the observed rate and the sample size, which keeps it inside 0% to 100% and dependable for small samples. The textbook formula, p plus or minus z standard errors, is the Wald interval.

The two differ because the Wald interval takes its standard error from the observed proportion alone. With few successes or few failures that estimate is poor, and at 0 successes it is zero. The Wilson interval is the set of true proportions that a z-test would not reject given your data, so it has no such gap. NIST's handbook gives the same formula in its section on confidence intervals for a proportion, and notes that its lower limit cannot be negative.

Worked example: a conversion rate

300 conversions from 10,000 visitors, the default values in the second calculator.

  1. p = 300 / 10,000 = 0.0300. For 95%, z = 1.9600 and z² = 3.8415.
  2. Center: (0.0300 + 0.000192) / 1.000384 = 0.030180. The shift is z² / 2n and the divisor is 1 + z² / n.
  3. Half-width: (1.9600 / 1.000384) × √0.0000029196 = 0.003348.
  4. Wilson interval: 0.030180 ± 0.003348 = 2.68% to 3.35%.
  5. Wald, for comparison: 0.0300 ± 1.9600 × 0.001706 = 2.67% to 3.33%.

With 300 successes the two nearly agree. They part company when the counts are small:

95% intervals for a proportion: the simple Wald formula beside the Wilson score interval
Successes of trialsObserved rateWald intervalWilson intervalWhat happens
0 of 500.00%0.00% to 0.00%0.00% to 7.13%Wald has no width at all
3 of 407.50%-0.66% to 15.66%2.58% to 19.86%Wald runs outside 0% to 100%
8 of 4002.00%0.63% to 3.37%1.02% to 3.90%Fewer than 10 successes: Wald is unreliable
30 of 1,0003.00%1.94% to 4.06%2.11% to 4.25%The two nearly agree
300 of 10,0003.00%2.67% to 3.33%2.68% to 3.35%The two nearly agree
3,000 of 100,0003.00%2.89% to 3.11%2.90% to 3.11%The two nearly agree

The first two rows are failures you can see: zero successes in 50 trials does not show that the true rate is exactly 0%, and no proportion can be negative. The third is one you cannot see. A 95% interval is supposed to contain the true rate in about 95% of samples, and that can be checked exactly by adding up the binomial probability of every sample the method gets right:

How often a 95% interval contains the true rate (exact, from the binomial distribution)
True rateTrialsExpected successesWald intervalWilson interval
2.0%50163.5%92.2%
7.5%40380.4%97.2%
3.0%100380.2%96.9%
2.0%400889.5%95.4%
3.0%1,0003093.5%94.9%
3.0%10,00030094.9%95.1%

With 3 expected successes, the "95%" Wald interval is right only 80.2% of the time. The Wilson interval is an approximation too, as the first row shows, but it stays close to its stated level where the Wald interval does not. Both assume independent trials with two outcomes and a number of trials fixed in advance.

How much can you trust a measured conversion rate?

A measured conversion rate is an estimate, and its confidence interval says how good an estimate it is. A 3% rate from 1,000 visitors is compatible with a true rate anywhere from 2.11% to 4.25%. The same 3% from 10,000 visitors narrows that to 2.68% to 3.35%.

The table runs one observed rate through the proportion calculator at seven sample sizes. The numbers illustrate the arithmetic. They are not a benchmark.

A 3% conversion rate at different sample sizes: 95% Wilson interval
VisitorsConversions95% intervalWidth (points)Upper limit ÷ lower limit
10031.03% to 8.45%7.438.2
400121.72% to 5.17%3.453.0
1,000302.11% to 4.25%2.142.0
2,500752.40% to 3.74%1.341.6
10,0003002.68% to 3.35%0.671.2
40,0001,2002.84% to 3.17%0.331.1
100,0003,0002.90% to 3.11%0.211.1
  • Small samples say little. At 100 visitors the top of the interval is 8.2 times the bottom. A rate read off a slow week, a small segment or a new landing page is this kind of number.
  • Precision is bought with the square root of the sample. Going from 10,000 to 40,000 visitors, four times the traffic, leaves the interval 0.50 times as wide.
  • A change smaller than the interval is not yet a change. If this month's rate sits inside last month's interval, the move may be noise.

To get the rate itself, use the conversion rate calculator. To compare two versions of a page, do not eyeball two separate intervals: two rates can differ significantly even when their intervals overlap a little. The statistical significance calculator gives one interval for the difference between them. And to decide how much traffic a test needs before you start, use the A/B test sample size calculator.

An interval tells you how well a rate is measured, not why it is what it is. Convertica's free CRO audit looks at the page behind the number: eight checks, each scored out of 100, and three fixes to make first.

Get your free CRO audit

Enter your website and email and the audit starts right away. Watch it check your page live: eight checks, each scored out of 100, and three fixes you can make now.

How do you calculate the margin of error?

The margin of error of a survey percentage is the critical value times the standard error of the proportion: z × √(p(1 - p) / n). It is half the width of the confidence interval. With p at 50%, the widest case, and 95% confidence, a sample of 1,000 gives a margin of error of 3.10 percentage points.

Worked example: a survey of 1,000

  1. p(1 - p) / n = 0.50 × 0.50 / 1,000 = 0.000250. Its square root, the standard error, is 0.015811.
  2. Margin of error: 1.9600 × 0.015811 = 0.030990, or 3.10 percentage points.
  3. A result of 50% is therefore reported as 50% ± 3.10 points: 46.90% to 53.10%.
  4. If the 1,000 came from a population of only 5,000, multiply by the finite population correction, √(4,000 / 4,999) = 0.8945. The margin falls to 2.77 points.

The finite population correction matters only when the sample is a noticeable share of the population. Surveying 1,000 people out of millions leaves the margin as it was. Surveying 1,000 out of 5,000 does not.

Margin of error in percentage points, by sample size and confidence level (proportion 50%, large population)
Sample size90% confidence95% confidence99% confidence
100±8.22±9.80±12.88
200±5.82±6.93±9.11
400±4.11±4.90±6.44
600±3.36±4.00±5.26
1,000±2.60±3.10±4.07
1,500±2.12±2.53±3.33
2,400±1.68±2.00±2.63

Turned around, the same formula gives the sample size for a margin of error you want: n = z² × p(1 - p) / E², rounded up, and then n × N / (n + N - 1) for a population of N.

Sample size needed for a margin of error at 95% confidence (proportion 50%)
Margin of errorLarge populationPopulation of 10,000Population of 1,000
±10 points979688
±5 points385370278
±4 points601567376
±3 points1,068965517
±2 points2,4011,937707
±1 point9,6044,900906

The margin of error covers sampling error only: the luck of who happened to be in the sample. It assumes a simple random sample. It says nothing about people who did not answer, questions that lead the respondent, or a sample that does not look like the population. Those errors can be larger than the margin, and no formula on this page measures them.

What makes a confidence interval wider or narrower?

Three things set the width of a confidence interval: the confidence level, the sample size and the variability of the data. A higher level needs a larger critical value, so the interval widens. A larger sample shrinks the standard error. More variable data, or a proportion nearer 50%, enlarges it.

  • Confidence level. Going from 95% to 99% raises z from 1.960 to 2.576, which makes the interval 31% wider. More confidence is paid for in width.
  • Sample size. The standard error falls with the square root of n, so halving the width takes four times the sample.
  • Variability. You cannot choose it, but you can sometimes reduce it, for example by measuring a more consistent metric.

How do confidence intervals relate to p-values?

A confidence interval and a p-value from the same method carry the same information about one hypothesis. A two-tailed test at the 0.05 level rejects a hypothesized value exactly when that value lies outside the 95% confidence interval. The interval goes further: it shows every value the data are compatible with, and therefore how large the effect could be.

That is why a result is better reported as an estimate with its interval than as "significant" or "not significant". To turn a z, t or chi-square statistic into a p-value, use the p-value calculator.

How to calculate a confidence interval in Excel or Google Sheets

Excel and Google Sheets have a function that returns the margin of error for a mean, and functions for the critical values. With the mean in A1, the standard deviation in B1, the sample size in C1 and alpha in D1 (0.05 for 95%), these formulas work in both.

Spreadsheet formulas: mean in A1, standard deviation in B1, sample size in C1, alpha in D1
You wantFormula
Margin of error for a mean, using t=CONFIDENCE.T(D1,B1,C1)
Margin of error for a mean, using z=CONFIDENCE.NORM(D1,B1,C1)
Lower and upper limits=A1-CONFIDENCE.T(D1,B1,C1) and =A1+CONFIDENCE.T(D1,B1,C1)
t critical value=T.INV.2T(D1,C1-1)
z critical value=NORM.S.INV(1-D1/2)
Margin of error for a proportion in A1=NORM.S.INV(1-D1/2)*SQRT(A1*(1-A1)/C1)

For the Wilson interval, type the center and half-width formulas from the proportion calculator into cells, or use the calculator.

An interval measures precision. These tools cover the questions on either side of it.

See all free tools and how they fit together.

Confidence interval calculator FAQ

What does a confidence interval calculator do?

A confidence interval calculator takes a result from a sample and returns a range of values that the true population figure plausibly lies in, at a confidence level you choose. This one handles a mean, a proportion such as a conversion rate, and the margin of error of a survey percentage, and shows the critical value and standard error it used.

How do I calculate a 95% confidence interval?

Take your estimate and add and subtract the margin of error: the critical value times the standard error. For a mean with the standard deviation taken from the sample, the standard error is s divided by the square root of n and the critical value comes from the t distribution with n - 1 degrees of freedom. For a large sample it is close to 1.96.

What is the z score for a 95% confidence interval?

The z score for a 95% confidence interval is 1.96. It is 1.645 for 90% and 2.576 for 99%. These are the points that leave half of the remaining probability in each tail of the standard normal distribution: 2.5% in each tail for a 95% interval.

Does a 95% confidence interval mean there is a 95% chance the true value is inside it?

No. The true value is fixed, and one calculated interval either contains it or does not. The 95% describes the method: if you repeated the sampling many times and built an interval each time, about 95% of those intervals would contain the true value. You cannot tell from the data whether yours is one of them.

When should I use t instead of z?

Use t for a mean whenever the standard deviation was calculated from the sample, which covers nearly every real case. Use z only when the population standard deviation is known in advance. With a large sample the two give almost the same interval, so t is the safe default. Proportions use z.

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

The margin of error is half the width of a symmetric confidence interval: the amount you add to and subtract from the estimate. An estimate of 50% with a margin of error of 3 percentage points is the confidence interval 47% to 53%. The margin of error is always quoted at a confidence level, usually 95%.

Why use the Wilson interval for a proportion?

The Wilson interval never goes below 0% or above 100% and stays reliable with small samples and rates near the ends, where the simple Wald formula breaks. With 3 successes in 40 trials, Wald gives -0.66% to 15.66%, an impossible range, and Wilson gives 2.58% to 19.86%. With large counts the two nearly agree.

Is a p-value of 0.05 the same as a 95% confidence interval?

They are two views of the same test when they are built from the same method. A two-tailed test at the 0.05 level rejects a hypothesized value exactly when the 95% confidence interval does not contain it. The interval tells you more: every value the data are compatible with, not only whether one value is ruled out.

What makes a confidence interval narrower?

A larger sample, less variable data or a lower confidence level. Sample size works through its square root, so four times the data gives an interval about half as wide. Lowering the confidence level also narrows the interval, but only by accepting that the method misses the true value more often.

What sample size do I need for a given margin of error?

Divide z squared times p times (1 - p) by the margin of error squared, and round up. At 95% confidence with p at 50%, the widest case, a margin of 5 percentage points needs 385 responses and a margin of 3 points needs 1,068. A small population needs fewer, through the finite population correction.

Can I use a confidence interval to compare two conversion rates?

Not by checking whether two separate intervals overlap: two rates can differ significantly even when their intervals overlap a little. To compare a control and a variant, calculate one interval for the difference between them. Convertica's statistical significance calculator does that from visitors and conversions.

Find out what is costing you conversions

Enter your website and email and the audit starts right away. Watch it check your page live: eight checks, each scored out of 100, and three fixes you can make now.