08 Compound probability of independent events
08 Compound probability of independent events#
%%html
<iframe width="700" height="400" src="https://www.youtube.com/embed/xSc4oLA9e8o/" frameborder="0" allowfullscreen></iframe>
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt
import seaborn as sns
coin = ['H', 'T']
def P(cond, total_lst):
cond_lst = list(filter(cond, total_lst))
return len(cond_lst) / len(total_lst), cond_lst
# P(H)
p_heads, _ = P(lambda x: x == 'H', coin)
print(p_heads)
0.5
# P(HH) = P(H) . P(H)
p_heads_heads = P(lambda x: x == 'H', coin)[0] * P(lambda x: x == 'H', coin)[0]
print(p_heads_heads)
0.25
# P(THT)
p_tails_heads_tails =P(lambda x: x == 'T', coin)[0] * P(lambda x: x == 'H', coin)[0] * P(lambda x: x == 'T', coin)[0]
print(p_tails_heads_tails)
0.125