# In class-examples, February 11, 2020

In [4]:
def joint_probability_of_independent_events(list_of_events):
prob = 1
for x in list_of_events:
prob = prob * x
return prob

In [5]:
three_coins = [0.5, 0.5, 0.5]
print(joint_probability_of_independent_events(three_coins))

0.125

In [6]:
# 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)

In [7]:
print(union_of_independent_events([0.5, 0.5]))

0.75

In [8]:
print(union_of_independent_events(three_coins))

1.375


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.

In [ ]: