from IPython.display import Image import prettyplotlib as ppl from prettyplotlib import plt import numpy as np import scipy as sp import seaborn as sns sns . set_context ( 'talk' ) from matplotlib import rc rc ( 'font' , ** { 'family' : 'sans-serif' , 'sans-serif' :[ 'Helvetica' ], 'size' : 22 }) rc ( 'xtick' , labelsize = 12 ) rc ( 'ytick' , labelsize = 12 ) ## for Palatino and other serif fonts use: #rc('font',**{'family':'serif','serif':['Palatino']}) rc ( 'text' , usetex = True ) % matplotlib inline from IPython.html import widgets # Widget definitions from IPython.display import display # Used to display widgets in the notebook from IPython.html.widgets import interact , interactive from IPython.display import clear_output , display , HTML def gen_plot ( success = ( 0 , 100 ), failure = ( 0 , 100 )): alpha = 5 + success beta = 5 + failure fig = plt . figure ( figsize = ( 8 , 6 )) x = np . linspace ( 0 , 1 , 100 ) ax = fig . add_subplot ( 111 , xlabel = 'Chance of success (beating the market)' , ylabel = 'Probability of hypothesis' , title = r'Posterior probability distribution of $\theta$' ) ax . plot ( x , sp . stats . beta ( alpha , beta ) . pdf ( x ), linewidth = 3. ) ax . set_xticklabels ([ '0\%' , '20\%' , '40\%' , '60\%' , '80\%' , '100\%' ]);