Confidence interval calculator
For a mean (Student t) or a proportion (Wilson). The standard error and every step are shown, and your data are drawn under the interval.
How it is calculated
For a mean, the calculator uses Student’s t interval[1]:
With the starting data (ten values with mean 5.1 and s = 0.2789), the standard error is s/√n = 0.2789/√10 = 0.0882. The 95 % critical value of t with 9 degrees of freedom is 2.2622, so the margin of error is 2.2622 × 0.0882 = 0.1995 and the interval runs from 4.9005 to 5.2995. The standard error is the piece that comes from the square-root law: it is the estimated standard deviation of sample means like yours. established
For a proportion, with x successes in n trials, p = x/n and the estimated standard error is √(p(1 − p)/n). The calculator reports the Wilson score interval[2]:
and shows the textbook Wald interval p ± z*·SE beside it. Brown, Cai and DasGupta showed that the Wald interval’s coverage falls far below 95 % for many combinations of n and p, even with hundreds of trials, and recommended Wilson’s instead[3]. With 48 successes in 120 trials the two nearly agree: Wilson gives 0.3168 to 0.4894, Wald 0.3123 to 0.4877. With 0 successes in 20 the Wald interval collapses to the single point 0, which cannot be right; Wilson gives 0 to 0.1611. established
Reading the answer
A 95 % interval comes from a method that catches the true value in 95 % of the samples it is used on. It is not a range that holds 95 % of the data. When you paste data, the dots under the interval show the difference: ten values spread from 4.7 to 5.6, while the interval for their mean is about 0.4 wide, and it would keep shrinking like 1/√n with more data while the dots stayed just as spread out. What 95 % really means runs the method a thousand times so you can count.
Assumptions
- The observations are independent: a simple random sample, or a randomized experiment. Clustered or time-ordered data need wider intervals than these.
- For a mean, the t interval is exact when the population is normal. For other shapes it relies on the sample mean being close to normal, which can take large samples for strongly skewed data: at n = 5 from the site’s skewed population, a nominal 95 % t interval catches the mean noticeably less often. See when coverage fails.
- For a proportion, x and n must be whole numbers with 0 ≤ x ≤ n. Wilson’s interval stays inside 0 to 1; the Wald ends are shown unclipped so you can see when they leave it.
- Results are rounded half-up for display: interval ends to four decimals, or to more significant figures when that is needed to show a small value or to tell the two ends apart; the steps keep more. A value that is not exactly 0 or 1 is never shown as 0 or 1: values below 0.000001 are written in scientific notation, and a value within 0.00005 of 1 gets enough decimals for three significant figures of its distance from 1, taken from the computed value, so no digit is padding. No number is shown to more than twelve significant figures, except a Wald end just above 1, which keeps three significant figures of its excess; values from 1012 up are written in scientific notation. Pasted entries that are not finite numbers (text, or values too large for a browser, such as 1e400) are ignored, with a note.
- Sample sizes, trials and successes can be at most 10,000,000 (107), the range over which every number the calculator shows has been checked; larger counts, typed or in a shared link, are refused with a message.
- The confidence level can be from 50 % to 99.9999 %. Closer to 100 % a browser’s arithmetic can no longer tell the level from 100 %; below 50 % an interval misses more often than it catches, and is of little use.
Sources
- (2012). NIST/SEMATECH e-Handbook of Statistical Methods, §7.1.4 What are confidence intervals?. National Institute of Standards and Technology. standard
- (1927). Probable inference, the law of succession, and statistical inference. Journal of the American Statistical Association 22(158), 209–212. doi:10.1080/01621459.1927.10502953. primary
- (2001). Interval estimation for a binomial proportion. Statistical Science 16(2), 101–133. doi:10.1214/ss/1009213286. primary