You will write the rule for the standard error of a sample share, check it with a simulation, and use it to plan the size of a sample.
The idea. The standard error of a sample share is . A simulation makes many samples, finds the share in each, and measures how much the shares spread.
Your tasks.
se_rule(p, n). Return .simulated_spread(p, n, repeats). Make repeats samples. In each, count how many of n random numbers are below p, and divide by n. Return statistics.pstdev of the shares.size_for(p, target). Return the smallest whole n for which se_rule(p, n) is at most target.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…