Premium problem125. Does the 95% Interval Contain the Truth?

Medium Locked

Repeat trials times: draw n values from N(0,1)\mathcal{N}(0,1), build the interval xˉ±1.96 σ/n\bar{x} \pm 1.96\,\sigma/\sqrt{n} using the known σ=1\sigma = 1, and check whether it contains the true mean of 0. Return the fraction that did.

This is what "95% confidence" actually means: a statement about how often the procedure captures the parameter, not about any single interval.

Seed np.random.seed(seed) inside solve, immediately before drawing.

Input

n = 30
trials = 2000
seed = 0

Output

0.947

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)