You will simulate many repeats of a binomial experiment with a fixed seed, turn the counts into shares, and check that they match the formula. The checker uses classes of students who each cycle with probability .
The idea. One repeat counts the successes in n trials, where a trial succeeds when rng.random() < p. Many repeats give a list of counts. The share of count k is how often k appears, divided by the number of repeats.
Your tasks.
one_count(rng, n, p).simulate(n, p, repeats, seed). Make rng = random.Random(seed) and return the list of counts.shares(counts, n). Return a list of shares, for the counts to .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…