V.5 · Statistics
What does 95% describe: this interval or the procedure?
Generate actual iid normal samples, keep the true mean fixed, and see which computed intervals cover it. Compare nominal confidence with realized finite-run coverage.
Generate intervals, keep the parameter fixed
Fixed true mean: solid vertical line. Covered intervals: solid with a circle. Misses: dashed with a cross.
Inspect actual samples and interval endpoints
| Run | Observed data | Mean | Interval | Contains μ? |
|---|---|---|---|---|
| 1 | 2.97304, 2.33777, 3.43706, 3.20148, 5.05031, -0.938388, 3.38556, 3.70112 | 2.89349 | [1.85407, 3.93292] | Yes |
| 2 | 2.78429, 4.62035, 2.8021, 1.89325, 3.55988, 2.41692, 3.56162, 1.68905 | 2.91593 | [1.8765, 3.95536] | Yes |
| 3 | 3.59197, 0.339878, 1.34199, 1.53675, -2.34097, 2.24434, 3.14056, -0.134639 | 1.21499 | [0.175558, 2.25441] | Yes |
| 4 | -0.0822681, 1.85551, 1.94851, 3.00234, 3.32026, -0.640119, 1.4655, 2.78329 | 1.70663 | [0.667201, 2.74606] | Yes |
| 5 | 2.61597, -0.478017, 1.17727, 1.24757, 2.03046, 1.34251, 2.43678, 1.63054 | 1.50039 | [0.460958, 2.53981] | Yes |
| 6 | 3.26609, 3.23589, 2.86899, 1.24482, 4.1721, 1.97058, 3.52642, 2.27551 | 2.82005 | [1.78062, 3.85948] | Yes |
| 7 | 3.2789, 1.31012, 0.778484, 4.46444, 1.59884, 1.83696, 3.52106, 0.549473 | 2.16728 | [1.12786, 3.20671] | Yes |
| 8 | 1.94841, 1.38685, 0.485856, 1.20657, 3.43691, 2.96584, -1.30809, 5.36958 | 1.93649 | [0.897063, 2.97592] | Yes |
| 9 | 0.886605, 3.69259, 0.896441, 1.00305, 1.23726, 1.74526, 2.1706, 5.90224 | 2.19176 | [1.15233, 3.23118] | Yes |
| 10 | 1.35523, 0.935627, 1.94937, -0.395398, 2.22155, 4.00398, -0.391373, 7.01441 | 2.08667 | [1.04725, 3.1261] | Yes |
| 11 | 2.45392, 1.51618, 2.00619, 4.45934, -1.37533, 0.754752, 3.91502, 0.70203 | 1.80401 | [0.764586, 2.84344] | Yes |
| 12 | 2.3616, 1.97117, 0.865305, 3.57084, 0.185172, 1.56461, 3.04802, -0.917901 | 1.5811 | [0.541674, 2.62053] | Yes |
| 13 | 1.97943, 1.65591, 2.08807, 1.61595, 2.28695, 3.00654, 1.56046, 1.03717 | 1.90381 | [0.864381, 2.94324] | Yes |
| 14 | -0.40359, 0.995094, 2.39025, 3.07418, 3.6261, 0.0122935, 4.31671, 3.52222 | 2.19166 | [1.15223, 3.23109] | Yes |
| 15 | 2.39587, 3.46295, 0.235254, 1.24608, 3.76126, 2.47818, 4.70542, 3.87903 | 2.77051 | [1.73108, 3.80993] | Yes |
| 16 | 2.23797, 4.12205, 4.48604, 4.051, 0.14299, 2.23633, -0.375721, 2.19484 | 2.38694 | [1.34751, 3.42637] | Yes |
| 17 | 0.543875, 2.62113, 3.01202, 0.944039, 2.13269, 2.26187, -1.39411, 3.14233 | 1.65798 | [0.618553, 2.69741] | Yes |
| 18 | 2.38296, 0.900644, 0.674948, 1.32291, 3.0563, 4.4221, 3.20713, 1.39036 | 2.16967 | [1.13024, 3.2091] | Yes |
| 19 | 3.13602, 3.59136, -0.422838, 5.07176, 3.93563, 1.58585, 2.73937, 4.14817 | 2.97316 | [1.93374, 4.01259] | Yes |
| 20 | 3.18813, 1.90995, 1.2839, 2.255, 0.384163, 2.78901, 1.46473, 4.20472 | 2.18495 | [1.14552, 3.22438] | Yes |
| 21 | 1.18132, -0.658202, 3.07692, 0.0745426, 4.16757, 2.37307, -0.448357, 2.57531 | 1.54277 | [0.503343, 2.5822] | Yes |
| 22 | 3.62391, 2.26872, 2.07639, 2.48207, 0.5452, 2.22347, 2.41897, 0.435419 | 2.00927 | [0.969842, 3.0487] | Yes |
| 23 | 0.414517, -0.202615, 3.32201, 1.04712, 1.1255, 0.998438, 3.1793, 2.21774 | 1.51275 | [0.473323, 2.55218] | Yes |
| 24 | -2.53737, 1.45541, 3.17531, 2.31494, 1.33247, -0.284611, 1.79253, 4.67409 | 1.49034 | [0.450917, 2.52977] | Yes |
Assumptions: iid normal observations; σ is known and positive. This model has exact normal coverage at n = 1 as well as larger n. Realized coverage is never forced to match nominal confidence.
Independent Normal(2, 1.5²) observations, known positive sigma. Solid intervals with circles contain the true mean; dashed intervals with crosses miss it. 24 of 24 realized intervals contain the fixed true mean 2; realized coverage ≈ 100%. Nominal confidence is 95%. A fixed realized interval either contains the fixed parameter or misses it.
- Fixed true population mean
- 2
- Known population standard deviation
- 1.5
- Normal critical value
- 1.959964
- Theoretical standard error
- 0.53033
- Interval width
- 2.078856
- Realized finite-run coverage
- 1
- Analytic model coverage (CDF error ≤ 2e−9)
- 0.95
= exact finite-data/model quantity · ≈ binary64 approximation; empirical results describe this run
from 0.5 to 5, up to 2 decimal places
from 1 to 64, whole numbers only
from 1 to 80, whole numbers only
from 0 to 4294967295, whole numbers only
24 of 24 realized intervals contain the fixed true mean 2; realized coverage ≈ 100%. Nominal confidence is 95%. A fixed realized interval either contains the fixed parameter or misses it.
Specify the repeated-sampling model
The parameter stays fixed while independent samples vary. Sigma is known; no estimated-sigma or asymptotic small-sample shortcut is used.
Intuition
Before sampling, an interval is random because its center depends on unseen data. The population mean stays fixed. After observing a sample, the computed interval has fixed endpoints: it either contains that mean or misses it. Repeating the procedure makes this distinction visible.
Definition
Assume with known . For confidence , define . The normal quantile satisfies . Confidence is the procedure’s coverage .
Mechanics
The true mean is fixed at 2. Change known σ, sample size, repetition count, confidence level or seed. Each interval comes from its own independently generated sample, whose observed values and endpoints are available in the table. Covered intervals use solid lines and circles; misses use dashed lines and crosses. Replay preserves the run; Reset restores the canonical experiment.
Derivation
Normality gives for every positive n. The event is equivalent to and has probability . This is an exact finite-sample normal-model statement; no large-sample approximation or estimated σ is hidden in the derivation.
Worked examples
At 95% confidence, . Known and give half-width approximately 1.03943, so an observed mean of 2 gives endpoints approximately 0.960572 and 3.03943. If the mean instead equals 4, the interval approximately [2.96057,5.03943] misses the fixed true mean 2. The simulation calculates its actual means without replacing them by either example.
Worked example: Generate intervals, keep the parameter fixed
Fixed true mean: solid vertical line. Covered intervals: solid with a circle. Misses: dashed with a cross.
Inspect actual samples and interval endpoints
| Run | Observed data | Mean | Interval | Contains μ? |
|---|---|---|---|---|
| 1 | 2.97304, 2.33777, 3.43706, 3.20148, 5.05031, -0.938388, 3.38556, 3.70112 | 2.89349 | [1.85407, 3.93292] | Yes |
| 2 | 2.78429, 4.62035, 2.8021, 1.89325, 3.55988, 2.41692, 3.56162, 1.68905 | 2.91593 | [1.8765, 3.95536] | Yes |
| 3 | 3.59197, 0.339878, 1.34199, 1.53675, -2.34097, 2.24434, 3.14056, -0.134639 | 1.21499 | [0.175558, 2.25441] | Yes |
| 4 | -0.0822681, 1.85551, 1.94851, 3.00234, 3.32026, -0.640119, 1.4655, 2.78329 | 1.70663 | [0.667201, 2.74606] | Yes |
| 5 | 2.61597, -0.478017, 1.17727, 1.24757, 2.03046, 1.34251, 2.43678, 1.63054 | 1.50039 | [0.460958, 2.53981] | Yes |
| 6 | 3.26609, 3.23589, 2.86899, 1.24482, 4.1721, 1.97058, 3.52642, 2.27551 | 2.82005 | [1.78062, 3.85948] | Yes |
| 7 | 3.2789, 1.31012, 0.778484, 4.46444, 1.59884, 1.83696, 3.52106, 0.549473 | 2.16728 | [1.12786, 3.20671] | Yes |
| 8 | 1.94841, 1.38685, 0.485856, 1.20657, 3.43691, 2.96584, -1.30809, 5.36958 | 1.93649 | [0.897063, 2.97592] | Yes |
| 9 | 0.886605, 3.69259, 0.896441, 1.00305, 1.23726, 1.74526, 2.1706, 5.90224 | 2.19176 | [1.15233, 3.23118] | Yes |
| 10 | 1.35523, 0.935627, 1.94937, -0.395398, 2.22155, 4.00398, -0.391373, 7.01441 | 2.08667 | [1.04725, 3.1261] | Yes |
| 11 | 2.45392, 1.51618, 2.00619, 4.45934, -1.37533, 0.754752, 3.91502, 0.70203 | 1.80401 | [0.764586, 2.84344] | Yes |
| 12 | 2.3616, 1.97117, 0.865305, 3.57084, 0.185172, 1.56461, 3.04802, -0.917901 | 1.5811 | [0.541674, 2.62053] | Yes |
| 13 | 1.97943, 1.65591, 2.08807, 1.61595, 2.28695, 3.00654, 1.56046, 1.03717 | 1.90381 | [0.864381, 2.94324] | Yes |
| 14 | -0.40359, 0.995094, 2.39025, 3.07418, 3.6261, 0.0122935, 4.31671, 3.52222 | 2.19166 | [1.15223, 3.23109] | Yes |
| 15 | 2.39587, 3.46295, 0.235254, 1.24608, 3.76126, 2.47818, 4.70542, 3.87903 | 2.77051 | [1.73108, 3.80993] | Yes |
| 16 | 2.23797, 4.12205, 4.48604, 4.051, 0.14299, 2.23633, -0.375721, 2.19484 | 2.38694 | [1.34751, 3.42637] | Yes |
| 17 | 0.543875, 2.62113, 3.01202, 0.944039, 2.13269, 2.26187, -1.39411, 3.14233 | 1.65798 | [0.618553, 2.69741] | Yes |
| 18 | 2.38296, 0.900644, 0.674948, 1.32291, 3.0563, 4.4221, 3.20713, 1.39036 | 2.16967 | [1.13024, 3.2091] | Yes |
| 19 | 3.13602, 3.59136, -0.422838, 5.07176, 3.93563, 1.58585, 2.73937, 4.14817 | 2.97316 | [1.93374, 4.01259] | Yes |
| 20 | 3.18813, 1.90995, 1.2839, 2.255, 0.384163, 2.78901, 1.46473, 4.20472 | 2.18495 | [1.14552, 3.22438] | Yes |
| 21 | 1.18132, -0.658202, 3.07692, 0.0745426, 4.16757, 2.37307, -0.448357, 2.57531 | 1.54277 | [0.503343, 2.5822] | Yes |
| 22 | 3.62391, 2.26872, 2.07639, 2.48207, 0.5452, 2.22347, 2.41897, 0.435419 | 2.00927 | [0.969842, 3.0487] | Yes |
| 23 | 0.414517, -0.202615, 3.32201, 1.04712, 1.1255, 0.998438, 3.1793, 2.21774 | 1.51275 | [0.473323, 2.55218] | Yes |
| 24 | -2.53737, 1.45541, 3.17531, 2.31494, 1.33247, -0.284611, 1.79253, 4.67409 | 1.49034 | [0.450917, 2.52977] | Yes |
Assumptions: iid normal observations; σ is known and positive. This model has exact normal coverage at n = 1 as well as larger n. Realized coverage is never forced to match nominal confidence.
Independent Normal(2, 1.5²) observations, known positive sigma. Solid intervals with circles contain the true mean; dashed intervals with crosses miss it. 24 of 24 realized intervals contain the fixed true mean 2; realized coverage ≈ 100%. Nominal confidence is 95%. A fixed realized interval either contains the fixed parameter or misses it.
- Fixed true population mean
- 2
- Known population standard deviation
- 1.5
- Normal critical value
- 1.959964
- Theoretical standard error
- 0.53033
- Interval width
- 2.078856
- Realized finite-run coverage
- 1
- Analytic model coverage (CDF error ≤ 2e−9)
- 0.95
= exact finite-data/model quantity · ≈ binary64 approximation; empirical results describe this run
from 0.5 to 5, up to 2 decimal places
from 1 to 64, whole numbers only
from 1 to 80, whole numbers only
from 0 to 4294967295, whole numbers only
24 of 24 realized intervals contain the fixed true mean 2; realized coverage ≈ 100%. Nominal confidence is 95%. A fixed realized interval either contains the fixed parameter or misses it.
Specify the repeated-sampling model
The parameter stays fixed while independent samples vary. Sigma is known; no estimated-sigma or asymptotic small-sample shortcut is used.
Executable reference code
Run the exact mechanics and the NumPy companion. Both use literal assertions on the worked examples; simulations are never conditioned on a favorable coverage or fit outcome.
"""Runnable intervals reference, assumptions explicit."""
from statistics import NormalDist
from math import sqrt
mu, sigma, n, confidence = 2., 1.5, 8, .95
# A hand-observed sample; the parameter is fixed, the sample mean is computed.
sample = [1.,2.,3.,1.,2.,3.,1.,3.]
mean = sum(sample)/len(sample)
z = NormalDist().inv_cdf((1+confidence)/2)
lo, hi = mean-z*sigma/sqrt(n), mean+z*sigma/sqrt(n)
assert mean==2 and lo<mu<hi
assert abs((2*NormalDist().cdf(z)-1)-confidence)<1e-14
print((lo,hi), 'contains fixed mu:', lo<=mu<=hi)"""Runnable intervals reference, assumptions explicit."""
import numpy as np
from statistics import NormalDist
sample=np.array([1.,2.,3.,1.,2.,3.,1.,3.]); mu=2.;sigma=1.5
z=NormalDist().inv_cdf(.975)
interval=sample.mean()+np.array([-1.,1.])*z*sigma/np.sqrt(sample.size)
assert sample.mean()==2 and interval[0]<mu<interval[1]
print(interval, 'sigma known; exact normal model, not an estimated-sigma interval')Explore
Hold confidence and σ fixed and quadruple n: width halves. Double σ: width doubles. Hold n fixed and change repetitions: the nominal confidence and each interval width stay the same, while the realized coverage proportion can change. Try n=1 and explain why the exact normal assumptions still validate the formula.
Common mistakes and counterexamples
A 95% frequentist interval does not assign 95% posterior probability to the fixed parameter after seeing the data. A posterior statement requires a prior and a Bayesian model. Nor does nominal confidence promise that exactly 95 of the next 100 intervals will cover. Estimated σ needs a different normal-theory procedure using Student’s t; dependent or nonnormal data can invalidate this model’s coverage.
Numerical considerations
The 90%, 95% and 99% normal critical values are explicit binary64 constants, independently checked against Python NormalDist. Endpoints and Box–Muller normal samples are binary64 approximations; the reference-comparison tolerance is 2e−12 times max(1, absolute expected value). Analytic coverage uses the accepted normal CDF with absolute interval-probability error at most 2e−9. The seeded generator consumes two uniforms per observation and discards the sine partner; 1−u is positive so logarithms stay finite. The experiment stores at most 80 samples of 64 observations. Coverage classifications compare the computed endpoints directly; no sample is adjusted to achieve nominal coverage.
Engineering and ML connections
Repeated measurement and model evaluation often report intervals. Their validity depends on the data-generating assumptions and procedure, including selection, dependence and uncertainty in σ. More data narrow a valid interval but do not cure a biased collection process. MAP later introduces posterior inference with a prior; it has a different interpretation.
Exercises
Calculate from observed data and state the assumptions before interpreting a result. Corrective feedback identifies the corresponding misconception.
Summary and checkpoints
Explain what varies across repetitions, derive the coverage event, distinguish nominal from realized coverage and state the model assumptions. Relate width to σ and n, and reject the posterior-probability interpretation of a fixed frequentist interval.