diagnostic_iter_thres:, :] chain_array.vals['accepted'] = chain_array.vals['accepted'][ diagnostic_iter_thres:] # %% Plot traces of simulated chain for i in range(model.num_params()): ps.trace(chain_array.get_param(i), title=r'Traceplot of $\theta_{{{}}}$'.format(i + 1), xlabel='Iteration', ylabel='Parameter value') # %% Plot running means of simulated chain for i in range(model.num_params()): ps.running_mean( chain_array.get_param(i), title=r'Running mean plot of parameter $\theta_{{{}}}$'.format(i + 1), xlabel='Iteration', ylabel='Running mean') # %% Plot histograms of marginals of simulated chain for i in range(model.num_params()): ps.hist(chain_array.get_param(i), bins=30, density=True, title=r'Histogram of parameter $\theta_{{{}}}$'.format(i + 1), xlabel='Parameter value', ylabel='Parameter relative frequency')
import matplotlib.pyplot as plt from numpy import genfromtxt from statistics import mean import kanga.plots as ps # %% Read chains chains = genfromtxt('chain01.csv', delimiter=',') num_iters, num_pars = chains.shape # %% Running mean plot of a single chain with default trace input arguments ps.running_mean(chains[:, 0]) # %% Running mean plot of a single chain with a custom range of x values ps.running_mean(chains[:, 0], x=range(1000, 1000 + num_iters)) # %% Running mean plot of a single chain with some non-default trace input arguments ps.running_mean( chains[:, 0], ylim=[-2.7, 0.5], margins=0.01, title=r'Running mean plot of parameter $\theta_{{{}}}$'.format(1), xlabel='Iteration', ylabel='Running mean' )