You will write a shuffling test for two groups and use it on made-up data.
The idea. Under the null idea of no difference, the labels mean nothing. Pool the values, shuffle, split them again and record the difference in means. The p-value is the share of shuffles with a difference at least as large as the real one.
Your tasks.
difference(a, b). Return the mean of a minus the mean of b.one_shuffle(a, b). Pool the values, shuffle them with random.shuffle, and return the difference for the first len(a) values against the rest.shuffle_p(a, b, shuffles). Return the share of shuffles with a difference at least difference(a, b).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…