You will write three small functions: one that finds the probability of an event by counting outcomes, one that finds a conditional probability, and one that multiplies the steps along a path of a tree. The checker uses two dice and a bag of balls.
The idea. For equally likely outcomes, is the number of outcomes in divided by the total. Given , count only inside . Along a path of a tree diagram you multiply the branch probabilities.
Your tasks.
prob(event, space). Count the outcomes for which event(outcome) is true and divide by the size of the space.given(a, b, space). Return the probability of a given b.chain(steps). Multiply all the probabilities in the list. An empty list gives .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…