You will turn survey counts into a probability table, test whether a table is a real distribution, and add up the probabilities of "at least ". The checker uses the made-up survey of brothers and sisters.
The idea. A table is a dictionary that maps each value to its probability. The probability of a value is its count divided by the total. A real distribution has no negative probability, and its probabilities add up to exactly .
Your tasks.
table_from_counts(counts). Divide each count by the total, with Fraction so the answer is exact.is_distribution(pmf). Return True only if every probability is at least and the total is .at_least(pmf, k). Add the probabilities of every value that is or more.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…