Confidence Interval Calculator: Mean, Proportion, Two Groups

An average worked out from a sample is almost never exactly the true average. Twelve apartment listings in one neighborhood average $1,501.67 a month, but a different twelve listings would give a different figure. A confidence interval shows how far off that figure could reasonably be: here, $1,442.04 to $1,561.29 at 95% confidence.

This calculator builds that range for a mean (from a summary or from raw data), for a proportion, and for the difference between two groups. It picks t or z correctly, offers four methods for proportions, shows one-sided bounds, and draws the interval at 90%, 95% and 99% (for a proportion, side by side for each method) so you can see what each choice changes. It is set to the rent example below.

Confidence Interval Calculator

Use “σ unknown” when the standard deviation came from your own sample, which is nearly always the case.

Confidence interval –
The interval at several confidence levels
Step by step

    What You’re Estimating Decides the Formula

    Every interval in the calculator has the same shape: an estimate, plus or minus a critical value times a standard error. What changes from case to case is how each of those three parts is worked out.

    You want an interval forEstimateStandard errorCritical valueTab
    A mean, SD from your samplex̄s ÷ √nt with n − 1 dfMean (summary) or Mean from data
    A mean, population SD knownx̄σ ÷ √nzMean (summary), “σ known”
    A proportionp̂ = x ÷ nDepends on the methodzProportion
    A difference between two meansx̄₁ − x̄₂√(s₁²/n₁ + s₂²/n₂)t with Welch’s dfTwo means
    A difference between two proportionsp̂₁ − p̂₂Built from each group’s intervalzTwo proportions

    Unless the population standard deviation is known from outside your sample, the first row is the one to use, and that holds at any sample size. The rule “use z once n reaches 30” leaves the interval too narrow: at n = 30, t* is 2.045 against z’s 1.960, and with 12 values it is 2.201. The t table shows how fast t* settles toward z as the sample grows.

    Average Rent From 12 Listings, Worked Through

    Here are 12 monthly rents, in dollars, for one-bedroom apartments in the same neighborhood:

    1450, 1380, 1520, 1610, 1395, 1475, 1550, 1420, 1690, 1505, 1440, 1585

    1. Mean. The rents add up to 18,020, so x̄ = 18,020 ÷ 12 = 1,501.67.
    2. Standard deviation. Square each rent’s distance from the mean and add them: 96,866.67. Divide by n − 1 = 11 and take the square root: s = 93.84. (The standard deviation calculator shows this step row by row.)
    3. Standard error. s ÷ √n = 93.84 ÷ √12 = 27.09. This is how much the mean itself tends to move from sample to sample.
    4. Critical value. With 11 degrees of freedom and 2.5% in each tail, t* = 2.201.
    5. Margin of error. 2.201 × 27.09 = 59.62.
    6. Interval. 1,501.67 ± 59.62 = $1,442.04 to $1,561.29.

    In Excel or Google Sheets, =CONFIDENCE.T(0.05, 93.84, 12) returns the margin, 59.62, which you then add to and subtract from the mean. CONFIDENCE.NORM gives 53.09 instead, because it uses z. With a sample SD that is the wrong function, and it makes the interval about 11% too narrow.

    When you write the result up, give the estimate, the interval and the level together, for example: average rent $1,501.67 (95% CI $1,442.04 to $1,561.29, n = 12). The sample size matters to the reader, because it shows how much data stands behind the width.

    What “95% Confident” Is About, and What It Isn’t

    The 95% belongs to the method, not to this one interval. If many people each took their own random sample of 12 listings and built an interval the same way, about 95 out of 100 of those intervals would contain the true neighborhood average. To see it, we drew 100 simulated samples of 12 from a population with a true mean of $1,500: 94 of the 100 intervals contained 1,500 and 6 missed it. Over 100,000 simulated samples the share came to 95.06%.

    Your own interval is one of those draws. It either contains the true mean or it doesn’t, and you can’t tell which. “95% confident” is shorthand for trusting a procedure that is right 95% of the time.

    Three readings of the rent interval are wrong:

    • “95% of apartments here rent for $1,442 to $1,561.” Only 5 of the 12 listed rents fall inside that range. The interval is about the average, not about individual apartments.
    • “There’s a 95% chance the true average is in this range.” The true average is a fixed number. The chance applies to the method before the data arrive, not to this particular range afterwards.
    • “A new sample’s average will land in this range 95% of the time.” It won’t. A second sample’s mean has its own random error on top of the first one’s, so it falls inside less often than that.

    If you need a range for a single apartment, you want a prediction interval: x̄ ± t* × s × √(1 + 1/n). For the rents that is 1,501.67 ± 214.98, or $1,286.69 to $1,716.64, about 3.6 times as wide as the confidence interval. The extra width is the spread of individual rents around the average, which never shrinks however many listings you collect.

    Why Using a Sample SD Falls Short

    Swapping t* for z* looks like a small rounding choice. It changes how often the method works. With 12 values from a normal population, an interval built with z = 1.96 and a sample standard deviation contains the true mean 92.4% of the time, not 95%. The shortfall depends on the sample size:

    Sample sizeCoverage of a “95%” interval using z with s
    587.8%
    1292.4%
    3094.0%
    10094.7%

    These figures come straight from the t distribution: they are the chance that a t value with n − 1 degrees of freedom stays within ±1.96. The calculator always uses t when you choose “σ unknown”, and it shows the z version next to it so you can see the difference.

    90%, 95% or 99%: What the Choice Costs

    With the same 12 rents, only the confidence level changes the width:

    Confidencet* (11 df)z* (for comparison)Rent intervalWidth
    90%1.7961.645$1,453.02 to $1,550.32$97.30
    95%2.2011.960$1,442.04 to $1,561.29$119.25
    99%3.1062.576$1,417.53 to $1,585.80$168.27

    Going from 95% to 99% makes this interval 41% wider, and going down to 90% makes it 18% narrower. The calculator’s chart draws all three, with your chosen level highlighted.

    The direction is easy to flip by mistake when the choice is described through α, the share left in the tails. A higher confidence level means a smaller α and a wider interval. Raising α, say from 0.01 to 0.05, narrows it. Watch the 99% critical value as well: z* is 2.576. The figure 2.807 that turns up in some tables belongs to 99.5% confidence (0.25% in each tail), and using it for 99% makes the interval about 9% too wide.

    No level is correct in general. 95% is the convention in many fields. A lower level gives a tighter range that misses more often, and a higher level gives a range that misses less often but may be too wide to act on.

    A Proportion: 3 Crash Reports From 50 Users

    An app team asks 50 beta testers whether the app crashed, and 3 say yes. That is p̂ = 3 ÷ 50 = 6%. The textbook formula, called the Wald interval, gives:

    6% ± 1.96 × √(0.06 × 0.94 ÷ 50) = 6% ± 6.58%, which runs from −0.58% to 12.58%.

    A crash rate can’t be negative, so the lower end is cut off at 0%. The calculator offers three other methods, and with counts this small they disagree with Wald:

    Method95% interval for 3 of 50How often it really contains the true rate if that rate is 6%
    Wald0% to 12.58%80.7%
    Wilson score2.06% to 16.22%97.1%
    Agresti–Coull1.44% to 16.84%97.1%
    Clopper–Pearson (exact)1.25% to 16.55%99.1%

    The last column is worked out exactly from the binomial distribution, by adding up the chances of every count from 0 to 50 whose interval contains 6%. Wald’s 95% interval behaves like an 80.7% one here. A review in Statistical Science (Brown, Cai and DasGupta, 2001) found that the Wald interval’s poor coverage persists well beyond tiny samples, and it recommends Wilson for small n. That’s why Wilson is the calculator’s default.

    Wilson’s interval is not centred on 6%. It reaches 3.94 points below and 10.22 points above, because a rate this close to zero has more room to be higher than lower. Exact (Clopper–Pearson) is the cautious choice: it never covers less than the stated level, so it tends to be a little wider.

    Zero Successes Doesn’t Mean a Zero Rate

    Suppose 40 customers try a new checkout and none of them hits an error. The Wald formula gives 0% ± 0%, a range with no width at all, as if 40 trials proved the error rate is exactly zero. The other methods disagree:

    • Wilson: 0% to 8.76%
    • Clopper–Pearson: 0% to 8.81%

    A shortcut known as the rule of three gives a rough 95% upper limit when nothing has gone wrong in n trials: 3 ÷ n. For 40 trials that is 3 ÷ 40 = 7.5%. It comes from asking how high the rate could be while 0 out of n still has at least a 5% chance; the exact answer for 40 trials is 7.22%. So 40 clean trials are still consistent with an error rate of around 1 in 14.

    Two Means: Fertilizer A Against Fertilizer B

    A grower tests two fertilizers on 30 tomato plants each. Plants on fertilizer A yield 4.8 kg on average (SD 0.9 kg), and plants on fertilizer B yield 4.3 kg (SD 1.0 kg).

    The difference is 4.8 − 4.3 = 0.5 kg. Its standard error is √(0.9²/30 + 1.0²/30) = 0.2456. Welch’s formula gives 57.37 degrees of freedom and t* = 2.002, so the margin is 0.4918 and the 95% interval for the difference runs from 0.008 to 0.992 kg per plant.

    The interval leaves out 0, so the data favor fertilizer A, although only just. The lower end says the gain could be as small as 8 grams per plant. A two-sided t-test on the same numbers gives p = 0.0464, and the two results always agree: a 95% interval leaves out 0 exactly when the test’s p-value is below 0.05. The p-value calculator runs that test from a t statistic.

    Now look at each fertilizer on its own. A’s 95% interval is 4.46 to 5.14 kg and B’s is 3.93 to 4.67 kg. The two ranges overlap, from 4.46 to 4.67, yet the difference is significant. Checking whether two intervals overlap is a cruder test than building the interval for the difference, and it misses real differences. When you compare two groups, use the interval for the difference.

    Welch or pooled? The pooled method assumes both groups have the same spread; Welch doesn’t. When the SDs are similar the two agree closely: pooled gives 0.0083 to 0.9917 kg here, against Welch’s 0.0082 to 0.9918. When they aren’t, Welch stays close to its stated confidence while pooled can drift from it, so the calculator starts with Welch.

    Same plants measured twice? If each unit is measured before and after, the two lists aren’t independent groups. Subtract each pair, type the differences into the “Mean from data” tab, and the interval for their mean is the interval for the average change. The paired tab of the t-test calculator does the subtraction for you and adds the p-value.

    Two Rates: An A/B Test in Percentage Points

    An online shop shows page A to 400 visitors and page B to 410. Page A gets 62 sign-ups (15.5%) and page B gets 45 (10.98%). The difference is 4.52 percentage points.

    The calculator’s default here is Newcombe’s method, which builds each group’s Wilson interval first (12.28% to 19.37% for A, 8.30% to 14.37% for B) and then combines them. The 95% interval for the difference is −0.15 to 9.23 percentage points. The plain Wald formula gives −0.14 to 9.19, close at these sample sizes.

    Two readings follow:

    • The interval includes 0, so these visitors can’t rule out that the pages convert equally well. Page A could be up to 9 points better, or very slightly worse.
    • The difference is in points, not percent. Going from 10.98% to 15.5% is 4.52 points, which is a 41.2% relative lift. Saying “page A converts 4.52% better” mixes the two.

    Running the test longer narrows the interval. The sample size calculator shows how many visitors a given margin needs.

    One-Sided Bounds: “At Most” and “At Least”

    Sometimes only one direction matters. A safety team may only need to say the crash rate is at most some figure, and nobody needs a lower limit for that claim. A one-sided 95% bound puts the whole 5% error in one tail, so the single bound sits closer to the estimate than the matching end of a two-sided interval.

    For the 3 crashes in 50, the Wilson one-sided 95% upper bound is 14.09%, against 16.22% for the upper end of the two-sided interval. Choose “Upper bound only” or “Lower bound only” under the inputs. Decide which side you need before looking at the data. Picking the direction after seeing which way the result leans makes the stated 95% too optimistic.

    When the Interval Can’t Be Trusted

    The arithmetic is always the same, but the stated confidence holds only if the data meet a few conditions:

    • A random sample. Twelve rents taken from one landlord’s buildings describe that landlord, not the neighborhood. No formula fixes that.
    • Independent observations. Twenty measurements of the same plant are not twenty plants.
    • A reasonable shape for small samples. With few values, the t interval assumes the data come from a roughly normal population. If a handful of values run far to one side, the calculator flags the skew and suggests more data or a log scale.
    • Counts that aren’t too small for the method. With fewer than about 10 successes or 10 failures, use Wilson or exact, not Wald. The calculator says so when your counts fall in that range.

    A 95% interval also covers only random sampling error. If the question was worded to lead people, or only satisfied customers replied, the interval can be narrow and still wrong.

    Six Statements About One Interval: Right or Wrong?

    A gym measures the resting heart rate of 20 members and reports a 95% confidence interval for the mean of 66 to 72 beats per minute.

    1. “About 95% of members have a resting heart rate between 66 and 72.” Wrong. The interval is for the mean. Individual members vary much more.
    2. “If the gym repeated the study many times, about 95% of the intervals would contain the true mean.” Right. That is what the 95% describes.
    3. “A 99% interval from the same data would be narrower.” Wrong. More confidence needs a wider net. In the calculator’s chart, the 99% bar is the longest.
    4. “With 80 members instead of 20, the interval would be about half as wide.” Right, roughly, if the SD stays about the same. Width shrinks with √n, and √(80 ÷ 20) = 2. It comes out slightly less than half, because t* with 79 degrees of freedom is a little smaller than with 19.
    5. “The interval leaves out 65, so a test of ‘mean = 65’ would reject it at the 5% level.” Right. A two-sided 95% interval and a test at α = 0.05 always agree.
    6. “The sample mean was 69.” Right. A t interval for a mean is symmetric, so the sample mean sits exactly in the middle: (66 + 72) ÷ 2 = 69. That doesn’t hold for Wilson or exact intervals for a proportion.