def dic(trace, model=None):
 model = modelcontext(model)
 mean_deviance = ((-2) * np.mean([model.logp(pt) for pt in trace]))
 free_rv_means = {rv.name: trace[rv.name].mean(axis=0) for rv in model.free_RVs}
 deviance_at_mean = ((-2) * model.logp(free_rv_means))
 return ((2 * mean_deviance) - deviance_at_mean)

def dic ( trace , model = None ) : model = modelcontext ( model ) mean_deviance = ( ( - 2 ) * np . mean ( [ model . logp ( pt ) for pt in trace ] ) ) free_rv_means = { rv . name : trace [ rv . name ] . mean ( axis = 0 ) for rv in model . free_RVs } deviance_at_mean = ( ( - 2 ) * model . logp ( free_rv_means ) ) return ( ( 2 * mean_deviance ) - deviance_at_mean )
calculate the deviance information criterion of the samples in trace from model read more theory here - in a paper by some of the leading authorities on model selection - dx .