Repository for a workshop on Bayesian statistics
"""This file contains code used in "Think Stats",1by Allen B. Downey, available from greenteapress.com23Copyright 2013 Allen B. Downey4License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html5"""67from __future__ import print_function, division89import math10import numpy1112from matplotlib import pyplot1314import thinkplot15import thinkbayes2161718def RenderPdf(mu, sigma, n=101):19"""Makes xs and ys for a normal PDF with (mu, sigma).2021n: number of places to evaluate the PDF22"""23xs = numpy.linspace(mu-4*sigma, mu+4*sigma, n)24ys = [thinkbayes2.EvalNormalPdf(x, mu, sigma) for x in xs]25return xs, ys262728def main():29xs, ys = RenderPdf(100, 15)3031n = 3432pyplot.fill_between(xs[-n:], ys[-n:], y2=0.0001, color='blue', alpha=0.2)33s = 'Congratulations!\nIf you got this far,\nyou must be here.'34d = dict(shrink=0.05)35pyplot.annotate(s, [127, 0.002], xytext=[80, 0.005], arrowprops=d)3637thinkplot.Plot(xs, ys)38thinkplot.Show(title='Distribution of IQ',39xlabel='IQ',40ylabel='PDF',41legend=False)424344if __name__ == "__main__":45main()464748