示例#1
0
        * You get the data: H, H, H
        * You get the data: T, H, T
        * You get the data: H, H, H, H
        * You get the data: T, H, T, H'''

bayes_uniform = Bayes(prior_dict.copy(),likelihood_func=likelihood)
bayes_uniform.update('H')

fig, axs = plt.subplots(4,2, figsize=(14,8))
scenarios = ['H','T',['H','H'],['T','H'],['H','H','H'],['T','H','T'],['H','H','H','H'],['T','H','T','H']]
i = 1
for scenario, ax in zip(scenarios, axs.flatten()):
    bayes = Bayes(prior_dict.copy(),likelihood_func=likelihood)
    for flip in scenario:
        bayes.update(flip)
    bayes.plot(ax,title='Scenario #'+str(i)+': '+ ', '.join(scenario))
    i+=1
plt.tight_layout()
plt.show()

'''On a single graph, Use the coin.py random coin generator and overlay the initial uniform prior with the prior after 1, 2, 10, 50 and 250 flips..
Use the color parameter to give a different color to each layer. Use the label parameter to label each label.
This simulation gives us the Beta Distribution! The shape parameters (alpha and beta) are 1 + # heads and 1 + # tails!
We'll get into this more later.'''

mycoin = Coin()
# print(mycoin.flip())
# print(mycoin.flip())

fig, ax = plt.subplots(1,1, figsize=(14,9))
scenarios = []