def plot_posterior_predictive(trace, eval=None, lm=None, samples=30, **kwargs):
 import matplotlib.pyplot as plt
 if (lm is None):
  lm = (lambda x, sample: (sample['Intercept'] + (sample['x'] * x)))
 if (eval is None):
  eval = np.linspace(0, 1, 100)
 if (('lw' not in kwargs) and ('linewidth' not in kwargs)):
  kwargs['lw'] = 0.2
 if (('c' not in kwargs) and ('color' not in kwargs)):
  kwargs['c'] = 'k'
 for rand_loc in np.random.randint(0, len(trace), samples):
  rand_sample = trace[rand_loc]
  plt.plot(eval, lm(eval, rand_sample), **kwargs)
  kwargs.pop('label', None)
 plt.title('Posterior predictive')

def plot_posterior_predictive ( trace , eval = None , lm = None , samples = 30 , ** kwargs ) : import matplotlib . pyplot as plt if ( lm is None ) : lm = ( lambda x , sample : ( sample [ 'Intercept' ] + ( sample [ 'x' ] * x ) ) ) if ( eval is None ) : eval = np . linspace ( 0 , 1 , 100 ) if ( ( 'lw' not in kwargs ) and ( 'linewidth' not in kwargs ) ) : kwargs [ 'lw' ] = 0.2 if ( ( 'c' not in kwargs ) and ( 'color' not in kwargs ) ) : kwargs [ 'c' ] = 'k' for rand_loc in np . random . randint ( 0 , len ( trace ) , samples ) : rand_sample = trace [ rand_loc ] plt . plot ( eval , lm ( eval , rand_sample ) , ** kwargs ) kwargs . pop ( 'label' , None ) plt . title ( 'Posterior predictive' )
plot posterior predictive of a linear model .