17/32
Part 4 of 6 · The worked exampleLearn and do
The confidence level describes the method, not one interval
The worked example's 95% interval runs from 0.54 to 4.46 points. To see what its 95% promises, run the experiment again and again.
import random
rng = random.Random(5)
true_gap = 0.125 - 0.10
covered = 0
for _ in range(10_000):
conv_a = rng.binomialvariate(2000, 0.10)
conv_b = rng.binomialvariate(2000, 0.125)
low, high = two_proportion_test(conv_a, 2000, conv_b, 2000)["ci"]
covered += low <= true_gap <= high
print(f"{covered / 10_000:.1%} of the intervals hold the true gap")
10,000 experiments, a 95% interval each. What share of them hold the true gap?
Pick one to see what it prints.
Pick an answer above to see the rest
You've built one 95% interval. Is there a 95% chance the true gap is inside it?
Pick an answer above to see the rest