A/B tests · For studentsConfidence interval calculator

An online confidence interval solved step by step: for a proportion, Wilson, Clopper–Pearson and Wald side by side, with an explanation of where the simple formula breaks; for a mean, a t-interval from data or a summary; the survey margin of error and how many people to survey for the precision you need. Levels of 90, 95 or 99%, Python and R code.

Your numbers stay in the browser and are never sent anywhere

01Data02Result03Step by step04Code05Problems06Questions07Related
01

Data

What to estimate
Confidence level

A share of successes: conversion, defect rate, share answering “yes”. Three methods side by side, Wilson by default.

Need an interval for the difference of two proportions?Statistical significance

For the difference of two means:Student's t-test

02

Result

The proportion is 78.6 % to 95.7 %
Observed proportion 90.0 % (45 of 50). Wilson interval at 95 %: an interval built this way covers the true proportion in 95 % of cases.
Three methods for a proportion
Wilson78.6 % … 95.7 %
Recommended by default: works correctly near the edges too
Clopper–Pearson78.2 % … 96.7 %
Exact: never narrower than it should be, so slightly wider
Wald81.7 % … 98.3 %
Few successes or failures: the interval is shifted and too narrow
03

Step by step

  1. 1
    Proportion and z
    p̂ = 4550 = 0.9000z = 1.960
  2. 2
    Centre of the interval
    centre = p̂ + z²/2n1 + z²/n = 0.8715
  3. 3
    Half-width
    h = z1 + z²/n · √p̂(1 − p̂)/n + z²/4n² = 0.0851
  4. 4
    Interval
    0.8715 ± 0.0851 → 78.6 % … 95.7 %
04

Check in Python / R

Check in Python / R
from statsmodels.stats.proportion import proportion_confint

proportion_confint(45, 50, alpha=0.05, method="wilson")  # "beta" — Клоппер–Пирсон, "normal" — Вальд
05

Problems

06

Frequently asked questions

A range that most likely contains the true value of a proportion or a mean. It is built from a sample, and the more data, the narrower it is. For example, 45 satisfied customers out of 50 surveyed is 90%, but about all customers you can only say “78.6 to 95.7%” at the 95% level. A single number without an interval hides how imprecise it is.

Updated