Confidence intervals using the Normal distribution
Author: Catherine Berry, MEI
Date: 26 January 2011

This resource illustrates the definition of a confidence interval:
The P% confidence interval for the mean is an interval constructed from sample data in such a way that P% of such intervals will include the true population mean.

Press CTRL-R to create a new sample from a Normal distribution. You can set the values of the population mean, the population standard deviation and the sample size.

The sample mean is calculated and a confidence interval found from this. Press CTRL-R to create a new sample 100 times, and count how many times the true population mean does not fall within the confidence interval.

Population s.d.

Sample size

Population mean

Confidence interval captures true mean

Confidence interval does not capture true mean

σ = 10 (slider from 1 to 20, step 1)
μ = 1 (slider from -5 to 5, step 2)
n = 60 (slider from 10 to 100, step 10)
A100 = RandomNormal(μ, σ)
A99 = RandomNormal(μ, σ)
A98 = RandomNormal(μ, σ)
A97 = RandomNormal(μ, σ)
A96 = RandomNormal(μ, σ)
A95 = RandomNormal(μ, σ)
A94 = RandomNormal(μ, σ)
A93 = RandomNormal(μ, σ)
A92 = RandomNormal(μ, σ)
A91 = RandomNormal(μ, σ)
A90 = RandomNormal(μ, σ)
A89 = RandomNormal(μ, σ)
A88 = RandomNormal(μ, σ)
A87 = RandomNormal(μ, σ)
A86 = RandomNormal(μ, σ)
A85 = RandomNormal(μ, σ)
A84 = RandomNormal(μ, σ)
A83 = RandomNormal(μ, σ)
A82 = RandomNormal(μ, σ)
A81 = RandomNormal(μ, σ)
A80 = RandomNormal(μ, σ)
A79 = RandomNormal(μ, σ)
A78 = RandomNormal(μ, σ)
A77 = RandomNormal(μ, σ)
A76 = RandomNormal(μ, σ)
A75 = RandomNormal(μ, σ)
A74 = RandomNormal(μ, σ)
A73 = RandomNormal(μ, σ)
A72 = RandomNormal(μ, σ)
A71 = RandomNormal(μ, σ)
A70 = RandomNormal(μ, σ)
A69 = RandomNormal(μ, σ)
A68 = RandomNormal(μ, σ)
A67 = RandomNormal(μ, σ)
A66 = RandomNormal(μ, σ)
A65 = RandomNormal(μ, σ)
A64 = RandomNormal(μ, σ)
A63 = RandomNormal(μ, σ)
A62 = RandomNormal(μ, σ)
A61 = RandomNormal(μ, σ)
A60 = RandomNormal(μ, σ)
A59 = RandomNormal(μ, σ)
A58 = RandomNormal(μ, σ)
A57 = RandomNormal(μ, σ)
A56 = RandomNormal(μ, σ)
A55 = RandomNormal(μ, σ)
A54 = RandomNormal(μ, σ)
A53 = RandomNormal(μ, σ)
A52 = RandomNormal(μ, σ)
A51 = RandomNormal(μ, σ)
A50 = RandomNormal(μ, σ)
A49 = RandomNormal(μ, σ)
A48 = RandomNormal(μ, σ)
A47 = RandomNormal(μ, σ)
A46 = RandomNormal(μ, σ)
A45 = RandomNormal(μ, σ)
A44 = RandomNormal(μ, σ)
A43 = RandomNormal(μ, σ)
A42 = RandomNormal(μ, σ)
A41 = RandomNormal(μ, σ)
A40 = RandomNormal(μ, σ)
A39 = RandomNormal(μ, σ)
A38 = RandomNormal(μ, σ)
A37 = RandomNormal(μ, σ)
A36 = RandomNormal(μ, σ)
A35 = RandomNormal(μ, σ)
A34 = RandomNormal(μ, σ)
A33 = RandomNormal(μ, σ)
A32 = RandomNormal(μ, σ)
A31 = RandomNormal(μ, σ)
A30 = RandomNormal(μ, σ)
A29 = RandomNormal(μ, σ)
A28 = RandomNormal(μ, σ)
A27 = RandomNormal(μ, σ)
A26 = RandomNormal(μ, σ)
A25 = RandomNormal(μ, σ)
A24 = RandomNormal(μ, σ)
A23 = RandomNormal(μ, σ)
A22 = RandomNormal(μ, σ)
A21 = RandomNormal(μ, σ)
A20 = RandomNormal(μ, σ)
A19 = RandomNormal(μ, σ)
A18 = RandomNormal(μ, σ)
A17 = RandomNormal(μ, σ)
A16 = RandomNormal(μ, σ)
A15 = RandomNormal(μ, σ)
A14 = RandomNormal(μ, σ)
A13 = RandomNormal(μ, σ)
A12 = RandomNormal(μ, σ)
A11 = RandomNormal(μ, σ)
A10 = RandomNormal(μ, σ)
A9 = RandomNormal(μ, σ)
A8 = RandomNormal(μ, σ)
A7 = RandomNormal(μ, σ)
A6 = RandomNormal(μ, σ)
A5 = RandomNormal(μ, σ)
A4 = RandomNormal(μ, σ)
A3 = RandomNormal(μ, σ)
A1 = RandomNormal(μ, σ)
A2 = RandomNormal(μ, σ)
L: A1:A100
L_1 = Take(L, 1, n)
m = Mean(L_1)
e = 2.718281828459045
conf = 95 (slider from 90 to 99, step 1)
text12: "Confidence level " + conf + "%"
k = InverseNormal(0, 1, (100 - conf) / 200)
a = Segment((μ, 0.1), (μ, -0.1))
x_1: m + k * σ / sqrt(n)
x_2: m - k * σ / sqrt(n)
b = Segment((x_1, 0.1), (x_1, -0.1))
c = Segment((x_2, 0.1), (x_2, -0.1))
d = Segment((x_1, 0), (x_2, 0))
text1: "Confidence interval (" + x_1 + ", " + x_2 + ")"
text5: "Sample mean = " + m