FLXCode Confidence Interval Calculator

FLXCode apps

Appearance

Confidence Interval Calculator

Give the sample mean, spread and size, or successes and trials, and get the interval with its margin of error.

If this box has numbers, the mean, s and n are taken from them and the three fields above are not used.

Example Confidence interval

49.0565 to 55.7435 95% confidence interval for the mean

Results
Sample mean (x̄)52.4
Critical value (t*)2.0639
Standard error1.62
Margin of error3.34352
Lower limit49.0565
Upper limit55.7435

The steps, with your numbers

Degrees of freedom: n − 1 = 25 − 1 = 24

Critical value: t* for 95% with 24 df = 2.0639

Standard error: SE = s / √n = 8.1 / √25 = 1.62

Margin of error: t* × SE = 2.0639 × 1.62 = 3.34352

Interval: x̄ ± margin = 52.4 ± 3.34352 = (49.0565, 55.7435)

No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it.

Problem or idea? Email us

Quick start

  1. Pick the type: mean with known σ (z), mean with unknown σ (t), or a proportion.
  2. Choose 90, 95 or 99%, or type any level such as 97.5.
  3. Type the numbers. For the t interval you can paste the raw data instead.
  4. Read the interval, the margin of error and the steps below it.

Formulas

TypeIntervalCritical value
Mean, σ knownx̄ ± z* × σ / √nz* from the normal curve
Mean, σ unknownx̄ ± t* × s / √nt* with n − 1 degrees of freedom
Proportionp̂ ± z* × √(p̂(1 − p̂) / n)z* from the normal curve

Critical values

These come from the same inverse functions the tool calls.

Levelz*t*, df = 9t*, df = 24t*, df = 99
90%1.64491.83311.71091.6604
95%1.962.26222.06391.9842
99%2.57583.24982.79692.6264

Worked examples

CaseInputsMargin95% interval
Mean, σ knownx̄ = 100, σ = 15, n = 364.8999195.1001 to 104.9
Mean, σ unknownx̄ = 52.4, s = 8.1, n = 253.3435249.0565 to 55.7435
Poll proportion560 of 1,0000.030770.5292 to 0.5908
Small proportion4 of 200.17530.0247 to 0.3753 (Wilson 0.08066 to 0.416)

How the width changes

The margin of error depends on three things: the confidence level, the spread of the data and the sample size. To halve the margin, you need four times the sample. That is why polls of 1,000 people give about ±3 points and going to 4,000 only gets you to about ±1.5. To check a claim against a number, find the p-value for it. To get the spread from your list first, use the standard deviation calculator.

Numbers this uses

Every constant the tool uses is listed here with its source. Where a number varies, you can edit it in the tool.

  • Critical values is computed, not looked up. z* from Acklam's inverse normal with a refinement step, t* by bisection on the exact t distribution.
  • Levels is any level above 0 and below 100. The three chips are 90, 95 and 99.
  • Proportion is Wald interval, with the Wilson interval beside it. Wald is cut at 0 and 1 and flagged when there are fewer than 10 successes or failures.

Common mistakes

  • Using z with the sample standard deviation on a small sample. Use t.
  • Reading the interval as covering 95% of the data. It is about the mean, not about individual values.
  • Entering the percentage of successes instead of the count. Type 560, not 56.

Nothing you type or paste is uploaded. We count events without cookies (details).

FAQ

What does a 95% confidence interval mean?

If you repeated the study many times and built an interval each time, about 95% of those intervals would contain the true value. It does not mean there is a 95% chance this one interval holds it. For a mean of 52.4, s = 8.1 and n = 25 the interval is 49.0565 to 55.7435.

Should I use z or t?

Use z when the population standard deviation σ is known, which is rare. Use t when you only have the sample standard deviation s, which is the usual case. t gives a wider interval for small samples: with n = 25 the critical value is 2.0639 instead of 1.95996.

How do I get a confidence interval for a proportion?

Pick Proportion and type the successes and the sample size. A poll with 560 yes answers out of 1,000 gives 56% with a margin of error of 3.08 points, so 52.9234% to 59.0766%.

What is the margin of error?

It is the part you add and subtract: the critical value times the standard error. In the z example with σ = 15 and n = 36 it is 4.89991, so the mean of 100 becomes 95.1001 to 104.9.

What happens when I raise the confidence level?

The interval gets wider. For the same data, 99% gives 47.869 to 56.931 instead of 49.0565 to 55.7435. More confidence costs precision. A bigger sample narrows it: the margin shrinks with the square root of n.

Which interval for a proportion should I trust?

The simple one (Wald) is the textbook formula and is fine for large samples. With few successes or failures it can be too narrow or leave [0, 1]. For 4 out of 20 it gives 0.0246955 to 0.375305, while the Wilson interval, also shown, gives 0.0806577 to 0.416017.

Can I paste my data instead of typing the mean and s?

Yes, for the mean with unknown σ. Paste the numbers in the data box and the tool uses their mean, sample standard deviation and count. The fields above are then ignored, and it says so.

Is my data uploaded?

No. The numbers stay in your browser and are not stored or sent. We only count which type of interval you used and which level.

More from FLXCode

Share Confidence Interval Calculator