{"course":{"slug":"maths-you-need","title":"The Maths You Actually Need","url":"https://addaly.com/learn/maths-you-need","level":"intermediate","track":"deep"},"lesson":{"slug":"confidence-intervals-mechanics","title":"What a 95 per cent interval promises, and where the textbook one breaks","url":"https://addaly.com/learn/maths-you-need/confidence-intervals-mechanics","position":53,"of":76,"minutes":10,"answer":"A 95 per cent interval is a procedure that captures the truth in 95 per cent of repetitions, and the textbook estimate ± 1.96 SE breaks that promise near 0 or 1.","keyIdea":"A 95 per cent interval is a procedure that captures the truth in 95 per cent of repetitions, and the textbook estimate ± 1.96 SE breaks that promise near 0 or 1, covering only 63 per cent at p = 0.98 and n = 50, which the Wilson interval fixes by solving for the plausible true values instead."},"body":{"format":"markdown","text":"## The promise is about the procedure\n\nA 95 per cent confidence interval is a recipe with a guarantee: if you drew sample after sample and ran the recipe each time, 95 per cent of the intervals it produced would contain the true value. The guarantee is about the long run of the *procedure*. It is not a statement that the truth has a 95 per cent chance of being inside the one interval in front of you; that reading belongs to the Bayesian interval two lessons on, and it needs a prior to earn it.\n\nYou can check the promise directly.\n\n```python\nimport numpy as np\nrng = np.random.default_rng(1)\ntrue_p, n, hits = 0.7, 200, 0\nfor _ in range(10_000):\n    k = rng.binomial(n, true_p)\n    p = k / n\n    se = np.sqrt(p * (1 - p) / n)\n    hits += (p - 1.96 * se) <= true_p <= (p + 1.96 * se)\nprint(hits / 10_000)            # about 0.95\n```\n\nThe recipe here is the textbook one: estimate plus or minus 1.96 standard errors. At `p = 0.7` and `n = 200` it keeps its promise. The value 1.96 is the point on the bell curve that leaves 2.5 per cent in each tail, and the recipe leans on the central limit theorem to justify the bell.\n\n## Where the textbook interval breaks\n\nRun the same check with `true_p = 0.98` and `n = 50`. The coverage is not 95 per cent. It is **63.5 per cent**. The recipe misses the truth more than a third of the time while claiming to miss it one time in twenty.\n\nThe mechanism is visible in one example. A model scores 49 of 50:\n\n```\np = 0.98,   SE = √(0.98 × 0.02 / 50) = 0.0198\ninterval = 0.98 ± 1.96 × 0.0198 = 0.941 to 1.019\n```\n\nAn upper bound above 1 for a proportion. And a model scoring 50 of 50 gives `SE = 0`, so the interval is `[1.00, 1.00]`: a claim of certainty from fifty observations. The standard error was computed from the *estimate*, and near the boundary the estimate is a poor stand-in for the truth, so the width is wrong. This is not a small-sample curiosity. At `p = 0.9` and `n = 100`, the coverage is 93 per cent, still short, and it oscillates unpredictably as `n` changes.\n\n## The interval that keeps the promise\n\nThe Wilson interval fixes the mechanism by solving for the values of the true `p` under which the observation would be plausible, instead of assuming the estimate is the truth. With `z = 1.96` and `z² = 3.84`:\n\n```\ncentre     = (p + z²/2n) / (1 + z²/n)\nhalf-width = z × √( p(1−p)/n + z²/4n² ) / (1 + z²/n)\n```\n\nFor 49 of 50:\n\n```\ncentre     = (0.98 + 0.0384) / 1.0768 = 0.946\nhalf-width = 1.96 × √(0.000392 + 0.000384) / 1.0768 = 0.0507\ninterval   = 0.895 to 0.997\n```\n\nFor 50 of 50 it gives `0.929 to 1.000`. Both intervals stay inside `[0, 1]`, both are asymmetric, and both are wider than the textbook version on the side that matters. The centre is pulled toward 0.5 by the `z²/2n` term, which acts like adding two successes and two failures to the count; that pull is the correction.\n\n> Figure: Forty-nine right out of fifty, two intervals. Textbook: the estimate plus or minus 1.96 SE: 0.941 to 1.019, an upper bound above 1; Fifty out of fifty gives SE zero and the interval 1.00 to 1.00; Symmetric, because the recipe assumes it is; Real coverage at p = 0.98 and n = 50 is 63.5 per cent. Wilson: solve for the plausible true rates: 0.895 to 0.997; Fifty out of fifty gives 0.929 to 1.000; Asymmetric, and always inside 0 to 1; Coverage stays near the 95 it promises. The textbook width is computed from the estimate, and near 0 or 1 the estimate is a poor stand-in for the truth, so the width comes out wrong. Use Wilson whenever np or n times one minus p is under about ten, which for a rare failure rate is nearly always.\n\n```python\nfrom statsmodels.stats.proportion import proportion_confint\nproportion_confint(49, 50, method=\"wilson\")     # (0.895, 0.997)\n```\n\nIf `statsmodels` is not to hand, the two lines above are the whole formula. Use Wilson whenever `np` or `n(1 − p)` is under about 10, which for a rare failure rate is nearly always.\n\n## Means with small samples\n\nFor a mean rather than a proportion, the small-sample problem is different: `s` is a noisy estimate of `σ`, and the 1.96 should widen to account for it. The replacement is the t-distribution's quantile, which depends on `n − 1` degrees of freedom: 2.26 at `n = 10`, 2.09 at `n = 20`, 2.01 at `n = 50`, and 1.96 in the limit. At `n = 10` the interval is 15 per cent wider than the textbook one, which is the honest width.\n\n## Three things an interval cannot tell you\n\n**Bias.** An interval quantifies sampling noise only. A test set drawn from the wrong population gives a tight interval around the wrong number, and nothing in the width warns you. Module 4 and `evaluating-ai` both return to where the items came from; no interval formula does.\n\n**Which values inside are likely.** The interval is a range with a coverage guarantee, not a distribution over the range. The truth is not more likely to be at the centre in any sense the recipe licenses.\n\n**That 95 is special.** It is a convention. A 90 per cent interval is narrower by a factor of `1.645/1.96 = 0.84`, a 99 per cent one wider by `2.576/1.96 = 1.31`. Report which one you used, and prefer showing the interval to a bare yes or no about whether it excludes some number.\n\n## The habit\n\nAn accuracy is a proportion; compute Wilson. A mean over fewer than fifty items; use t. Anything else, resample. And before quoting any of them, ask whether the items were independent, because that assumption is the one no formula on this page can check."},"check":{"question":"A model gets 50 out of 50 on a test set, and the interval is computed as 1.00 ± 1.96 × 0, giving [1.00, 1.00]. What has gone wrong?","options":[{"text":"Nothing: fifty correct answers out of fifty is strong evidence, and the interval reports that faithfully.","correct":false,"tempting":"Fifty items cannot establish certainty; the zero width comes from plugging the estimate into the error formula, not from the evidence."},{"text":"The estimate's own error formula gives zero at p = 1; Wilson gives about 0.93 to 1.","correct":true},{"text":"Fifty items is too few to compute any interval at all, so the result is undefined.","correct":false,"tempting":"Small samples give wide intervals, not undefined ones; the Wilson recipe returns a perfectly usable range from fifty items."},{"text":"1.96 should have been replaced by the t-value for 49 degrees of freedom, which widens the interval.","correct":false,"tempting":"The t-correction addresses a noisy estimate of σ for a mean; for a proportion at p = 1 the standard error is zero under either constant, so this changes nothing."}]},"prev":{"slug":"standard-error-by-hand","title":"Standard error for a mean and a proportion, by hand","url":"https://addaly.com/learn/maths-you-need/standard-error-by-hand"},"next":{"slug":"the-rule-of-three","title":"Zero failures in 300 tries, and what that does not prove","url":"https://addaly.com/learn/maths-you-need/the-rule-of-three"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Source and assessment review continues. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'What a 95 per cent interval promises, and where the textbook one breaks', in The Maths You Actually Need. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/maths-you-need/confidence-intervals-mechanics (Accessed: 29 November 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"What a 95 per cent interval promises, and where the textbook one breaks","courseTitle":"The Maths You Actually Need","module":{"index":6,"slug":"estimation-from-samples","title":"Estimation: from a sample to a number you can trust"},"answer":null,"keyIdea":"A 95 per cent interval is a procedure that captures the truth in 95 per cent of repetitions, and the textbook estimate ± 1.96 SE breaks that promise near 0 or 1, covering only 63 per cent at p = 0.98 and n = 50, which the Wilson interval fixes by solving for the plausible true values instead.","hero":{"kind":"figure","figure":{"t":"figure","label":"Figure","figure":{"caption":"The textbook width is computed from the estimate, and near 0 or 1 the estimate is a poor stand-in for the truth, so the width comes out wrong. Use Wilson whenever np or n times one minus p is under about ten, which for a rare failure rate is nearly always.","left":{"title":"Textbook: the estimate plus or minus 1.96 SE","items":["0.941 to 1.019, an upper bound above 1","Fifty out of fifty gives SE zero and the interval 1.00 to 1.00","Symmetric, because the recipe assumes it is","Real coverage at p = 0.98 and n = 50 is 63.5 per cent"]},"right":{"title":"Wilson: solve for the plausible true rates","items":["0.895 to 0.997","Fifty out of fifty gives 0.929 to 1.000","Asymmetric, and always inside 0 to 1","Coverage stays near the 95 it promises"]},"title":"Forty-nine right out of fifty, two intervals","type":"compare"},"alt":"Figure: Forty-nine right out of fifty, two intervals. Textbook: the estimate plus or minus 1.96 SE: 0.941 to 1.019, an upper bound above 1; Fifty out of fifty gives SE zero and the interval 1.00 to 1.00; Symmetric, because the recipe assumes it is; Real coverage at p = 0.98 and n = 50 is 63.5 per cent. Wilson: solve for the plausible true rates: 0.895 to 0.997; Fifty out of fifty gives 0.929 to 1.000; Asymmetric, and always inside 0 to 1; Coverage stays near the 95 it promises. The textbook width is computed from the estimate, and near 0 or 1 the estimate is a poor stand-in for the truth, so the width comes out wrong. Use Wilson whenever np or n times one minus p is under about ten, which for a rare failure rate is nearly always."}},"blocks":[{"t":"h2","id":"the-promise-is-about-the-procedure","runs":[{"text":"The promise is about the procedure"}]},{"t":"p","runs":[{"text":"A 95 per cent confidence interval is a recipe with a guarantee: if you drew sample after sample and ran the recipe each time, 95 per cent of the intervals it produced would contain the true value. The guarantee is about the long run of the "},{"text":"procedure","i":true},{"text":". It is not a statement that the truth has a 95 per cent chance of being inside the one interval in front of you; that reading belongs to the Bayesian interval two lessons on, and it needs a prior to earn it."}]},{"t":"p","runs":[{"text":"You can check the promise directly."}]},{"t":"code","lang":"python","label":"Python","text":"import numpy as np\nrng = np.random.default_rng(1)\ntrue_p, n, hits = 0.7, 200, 0\nfor _ in range(10_000):\n    k = rng.binomial(n, true_p)\n    p = k / n\n    se = np.sqrt(p * (1 - p) / n)\n    hits += (p - 1.96 * se) <= true_p <= (p + 1.96 * se)\nprint(hits / 10_000)            # about 0.95"},{"t":"p","runs":[{"text":"The recipe here is the textbook one: estimate plus or minus 1.96 standard errors. At "},{"text":"p = 0.7","code":true},{"text":" and "},{"text":"n = 200","code":true},{"text":" it keeps its promise. The value 1.96 is the point on the bell curve that leaves 2.5 per cent in each tail, and the recipe leans on the central limit theorem to justify the bell."}]},{"t":"h2","id":"where-the-textbook-interval-breaks","runs":[{"text":"Where the textbook interval breaks"}]},{"t":"p","runs":[{"text":"Run the same check with "},{"text":"true_p = 0.98","code":true},{"text":" and "},{"text":"n = 50","code":true},{"text":". The coverage is not 95 per cent. It is "},{"text":"63.5 per cent","b":true},{"text":". The recipe misses the truth more than a third of the time while claiming to miss it one time in twenty."}]},{"t":"p","runs":[{"text":"The mechanism is visible in one example. A model scores 49 of 50:"}]},{"t":"code","lang":"","label":"Text","text":"p = 0.98,   SE = √(0.98 × 0.02 / 50) = 0.0198\ninterval = 0.98 ± 1.96 × 0.0198 = 0.941 to 1.019"},{"t":"p","runs":[{"text":"An upper bound above 1 for a proportion. And a model scoring 50 of 50 gives "},{"text":"SE = 0","code":true},{"text":", so the interval is "},{"text":"[1.00, 1.00]","code":true},{"text":": a claim of certainty from fifty observations. The standard error was computed from the "},{"text":"estimate","i":true},{"text":", and near the boundary the estimate is a poor stand-in for the truth, so the width is wrong. This is not a small-sample curiosity. At "},{"text":"p = 0.9","code":true},{"text":" and "},{"text":"n = 100","code":true},{"text":", the coverage is 93 per cent, still short, and it oscillates unpredictably as "},{"text":"n","code":true},{"text":" changes."}]},{"t":"h2","id":"the-interval-that-keeps-the-promise","runs":[{"text":"The interval that keeps the promise"}]},{"t":"p","runs":[{"text":"The Wilson interval fixes the mechanism by solving for the values of the true "},{"text":"p","code":true},{"text":" under which the observation would be plausible, instead of assuming the estimate is the truth. With "},{"text":"z = 1.96","code":true},{"text":" and "},{"text":"z² = 3.84","code":true},{"text":":"}]},{"t":"code","lang":"","label":"Text","text":"centre     = (p + z²/2n) / (1 + z²/n)\nhalf-width = z × √( p(1−p)/n + z²/4n² ) / (1 + z²/n)"},{"t":"p","runs":[{"text":"For 49 of 50:"}]},{"t":"code","lang":"","label":"Text","text":"centre     = (0.98 + 0.0384) / 1.0768 = 0.946\nhalf-width = 1.96 × √(0.000392 + 0.000384) / 1.0768 = 0.0507\ninterval   = 0.895 to 0.997"},{"t":"p","runs":[{"text":"For 50 of 50 it gives "},{"text":"0.929 to 1.000","code":true},{"text":". Both intervals stay inside "},{"text":"[0, 1]","code":true},{"text":", both are asymmetric, and both are wider than the textbook version on the side that matters. The centre is pulled toward 0.5 by the "},{"text":"z²/2n","code":true},{"text":" term, which acts like adding two successes and two failures to the count; that pull is the correction."}]},{"t":"code","lang":"python","label":"Python","text":"from statsmodels.stats.proportion import proportion_confint\nproportion_confint(49, 50, method=\"wilson\")     # (0.895, 0.997)"},{"t":"p","runs":[{"text":"If "},{"text":"statsmodels","code":true},{"text":" is not to hand, the two lines above are the whole formula. Use Wilson whenever "},{"text":"np","code":true},{"text":" or "},{"text":"n(1 − p)","code":true},{"text":" is under about 10, which for a rare failure rate is nearly always."}]},{"t":"h2","id":"means-with-small-samples","runs":[{"text":"Means with small samples"}]},{"t":"p","runs":[{"text":"For a mean rather than a proportion, the small-sample problem is different: "},{"text":"s","code":true},{"text":" is a noisy estimate of "},{"text":"σ","code":true},{"text":", and the 1.96 should widen to account for it. The replacement is the t-distribution’s quantile, which depends on "},{"text":"n − 1","code":true},{"text":" degrees of freedom: 2.26 at "},{"text":"n = 10","code":true},{"text":", 2.09 at "},{"text":"n = 20","code":true},{"text":", 2.01 at "},{"text":"n = 50","code":true},{"text":", and 1.96 in the limit. At "},{"text":"n = 10","code":true},{"text":" the interval is 15 per cent wider than the textbook one, which is the honest width."}]},{"t":"h2","id":"three-things-an-interval-cannot-tell-you","runs":[{"text":"Three things an interval cannot tell you"}]},{"t":"p","runs":[{"text":"Bias.","b":true},{"text":" An interval quantifies sampling noise only. A test set drawn from the wrong population gives a tight interval around the wrong number, and nothing in the width warns you. Module 4 and "},{"text":"evaluating-ai","code":true},{"text":" both return to where the items came from; no interval formula does."}]},{"t":"p","runs":[{"text":"Which values inside are likely.","b":true},{"text":" The interval is a range with a coverage guarantee, not a distribution over the range. The truth is not more likely to be at the centre in any sense the recipe licenses."}]},{"t":"p","runs":[{"text":"That 95 is special.","b":true},{"text":" It is a convention. A 90 per cent interval is narrower by a factor of "},{"text":"1.645/1.96 = 0.84","code":true},{"text":", a 99 per cent one wider by "},{"text":"2.576/1.96 = 1.31","code":true},{"text":". Report which one you used, and prefer showing the interval to a bare yes or no about whether it excludes some number."}]},{"t":"h2","id":"the-habit","runs":[{"text":"The habit"}]},{"t":"p","runs":[{"text":"An accuracy is a proportion; compute Wilson. A mean over fewer than fifty items; use t. Anything else, resample. And before quoting any of them, ask whether the items were independent, because that assumption is the one no formula on this page can check."}]}],"check":{"question":[{"text":"A model gets 50 out of 50 on a test set, and the interval is computed as 1.00 ± 1.96 × 0, giving [1.00, 1.00]. What has gone wrong?"}],"options":[{"text":[{"text":"Nothing: fifty correct answers out of fifty is strong evidence, and the interval reports that faithfully."}],"correct":false,"tempting":[{"text":"Fifty items cannot establish certainty; the zero width comes from plugging the estimate into the error formula, not from the evidence."}]},{"text":[{"text":"The estimate’s own error formula gives zero at p = 1; Wilson gives about 0.93 to 1."}],"correct":true,"tempting":null},{"text":[{"text":"Fifty items is too few to compute any interval at all, so the result is undefined."}],"correct":false,"tempting":[{"text":"Small samples give wide intervals, not undefined ones; the Wilson recipe returns a perfectly usable range from fifty items."}]},{"text":[{"text":"1.96 should have been replaced by the t-value for 49 degrees of freedom, which widens the interval."}],"correct":false,"tempting":[{"text":"The t-correction addresses a noisy estimate of σ for a mean; for a proportion at p = 1 the standard error is zero under either constant, so this changes nothing."}]}],"order":[2,3,0,1],"why":null},"prev":{"slug":"standard-error-by-hand","title":"Standard error for a mean and a proportion, by hand","minutes":9},"next":{"slug":"the-rule-of-three","title":"Zero failures in 300 tries, and what that does not prove","minutes":8}}}