def joint_probability_of_independent_events(list_of_events): prob = 1 for x in list_of_events: prob = prob * x return prob
three_coins = [0.5, 0.5, 0.5] print(joint_probability_of_independent_events(three_coins))
# DON'T WRITE THIS DOWN, THERE'S A BUG. def union_of_independent_events(list_of_events): sum_of_events = sum(list_of_events) return sum_of_events - joint_probability_of_independent_events(list_of_events)
So we'll talk in class about why that last one is wrong---and I'm not going to implement a correct version, because it'll require more combinatorial gnarliness than I'm willing to figure out how to code up today---but if you want to see what the deal is in advance, check out this wikipedia page.