You will simulate many surveys from a town where the true share is known, and count how often the 95% interval catches it.
The idea. Each survey asks n people. Each person says yes when a random number is below the true share p. The survey's interval is .
Your tasks.
one_interval(p, n). Simulate one survey and return its interval (low, high).caught(pair, p). Return True when p lies from low to high.coverage(p, n, repeats). Return the share of repeats intervals that catch p.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…