黑客贝叶斯方法样式表

这个例子演示了贝叶斯黑客方法 [1] 在线书籍中使用的风格。

[1] http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/

黑客贝叶斯方法样式表示例

  1. from numpy.random import beta
  2. import matplotlib.pyplot as plt
  3. plt.style.use('bmh')
  4. def plot_beta_hist(ax, a, b):
  5. ax.hist(beta(a, b, size=10000), histtype="stepfilled",
  6. bins=25, alpha=0.8, density=True)
  7. fig, ax = plt.subplots()
  8. plot_beta_hist(ax, 10, 10)
  9. plot_beta_hist(ax, 4, 12)
  10. plot_beta_hist(ax, 50, 12)
  11. plot_beta_hist(ax, 6, 55)
  12. ax.set_title("'bmh' style sheet")
  13. plt.show()

下载这个示例