You will write the code that assigns subjects to two groups at random, and then check that random assignment makes the groups alike on average.
The idea. Shuffle the list of subjects with random.shuffle, then put the first half in the treatment group and the rest in the control group. Over many shuffles, the mean of any feature, such as age, is about the same in both groups.
Your tasks.
assign(subjects). Shuffle a copy of the list and return two lists: the first half and the second half.mean(values). Return the mean of a list of numbers.average_gap(ages, times). Assign the ages at random times times, and return the average of the gaps (mean of the first group minus mean of the second).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…