from correlations.errors import uWerr, acorrnErr, getW from theory.clibs.autocorrelations.exponential import hmc from theory.operators import magnetisation_sq from correlations.acorr import acorrMapped from results.common.utils import prll_map from results.data.store import load from plotter.pretty_plotting import Pretty_Plotter min_sep = 0. max_sep = 50 max_x_view = 10. max_y_view = 2. file_desc = 'acorr_mag2_hmc' acs = load('results/data/numpy_objs/{}_acs.json'.format(file_desc)) t = load('results/data/numpy_objs/{}_trajs.json'.format(file_desc)) p = load('results/data/other_objs/{}_probs.pkl'.format(file_desc)) s = load('results/data/numpy_objs/{}_samples.json'.format(file_desc)) op_samples = magnetisation_sq(s) av_op = op_samples.mean() tsum = np.cumsum(t) n, dim = s.shape[1], 1 spacing = 1. n_samples, n_burn_in = s.shape[0], 50 c_len = 10000 m = 1.0 n_steps = 20 step_size = 1. / ((3. * np.sqrt(3) - np.sqrt(15)) * m / 2.) / float(n_steps)
break if plateau_plot == True: fig_plateau = plt.figure() ax_plateau = fig_plateau.add_subplot(111) ax_plateau.plot(tplot) ax_plateau.plot((W, W), (0,tplot[W])) ax_plateau.set_xlabel(r'$W$') ax_plateau.set_ylabel(r'$\tau_{int}$') ax_plateau.set_title(r'$\tau_{int}$ in dependence of $W$') dtint = np.sqrt(4*(W + 0.5-tint)/float(self.N)) * tint return tint,dtint,W # load data from christian and use his data comparison_xx = load(comparison_loc) comparison_xx = np.asarray(comparison_xx) print 'Comparing autocorrelation calculations...' # assert that the autocorrelation routine is the same av_xx = comparison_xx.mean() norm = ((comparison_xx-av_xx)**2).mean() my_acorr = np.asarray(map(lambda s: myAcorr(comparison_xx, av_xx, s), np.asarray(separations))) christian_class = Christian_Autocorrelation(comparison_xx) christian_acorr = christian_class.acf()[:c_len] christian_acorr = np.asarray(christian_acorr) diffs = christian_acorr[:my_acorr.size] - my_acorr print " > av. difference: {}".format(diffs.mean())
#!/usr/bin/env python import numpy as np from results.data.store import load # from theory.autocorrelations import M2_Exp as Theory from common.acorr import plot from common.utils import saveOrDisplay save = False file_name = 'acorr_mag2_khmc' dest = 'results/data/other_objs/{}_allPlot.pkl'.format(file_name) a = load(dest) pa = load('results/data/other_objs/{}_probs.pkl'.format(file_name)) # m = 0.1 # n_steps = 1000 # step_size = 1./((3.*np.sqrt(3)-np.sqrt(15))*m/2.)/float(n_steps) # tau = step_size*n_steps # # n, dim = 10, 1 # x0 = np.random.random((n,)*dim) # spacing = 1.0 # # n_samples, n_burn_in = 1000000, 50 # c_len = 100000 # # th = Theory(tau=tau, m=m) # vFn = lambda x: th.eval(t=x, pa=pa, theta=np.pi/2)/th.eval(t=0, pa=pa, theta=np.pi/2.) # # l = a['lines'].keys()[0] # x, f0 = a['lines'][l]
ax[0].legend(bbox_to_anchor=(0., -0.3, 1., .102), loc=9, ncol=6, mode="expand", borderaxespad=0.) fig.subplots_adjust(bottom=0.3) pp.save_or_show(save, PLOT_LOC) pass if __name__ == '__main__': from results.common.utils import saveOrDisplay file_name = __file__ save = True # load the existing parameters dest = "results/optimalParams_minimiseCost_xx_hmc_params_coarse.pkl" output = store.load(dest) # in this case best_params: [best_theta, best_] best_params, best_fn, arg_grid, fn_grid = output print '\n\n__Model details__' print 'Potential:\tFree-Field' print 'Lattice:\t(100,1)' print 'Mass:\t\t0.01' print '\nBest parameters:\n\tstep_size: {:10.5f}\n\tn_steps: {:10.5f}\n\ttau: {:10.5f}'.format( best_params[0], best_params[1], np.prod(best_params)) x,y = arg_grid z = fn_grid l = z.shape[0] # this is the grid length (square grid)
try: from theory.clibs.autocorrelations.exponential import hmc cpp = True except: cpp = False print 'failed to import c++' from theory.operators import magnetisation_sq from correlations.acorr import acorrMapped, acorrMapped_noDups from results.common.utils import prll_map from results.data.store import load from plotter import Pretty_Plotter, PLOT_LOC from common.utils import saveOrDisplay, multiprocessing import ctypes fname = 'acorr_mag2_hmc' acs = load('results/data/numpy_objs/{}_acs.json'.format(fname)) seps = load('results/data/numpy_objs/{}_trajs.json'.format(fname)) p = load('results/data/other_objs/{}_probs.pkl'.format(fname)) s = load('results/data/numpy_objs/{}_samples.json'.format(fname)) save = True op = magnetisation_sq(s) av_op = op.mean() n, dim = 10, 1 spacing = 1. n_samples, n_burn_in = 100000, 50 c_len = 1000 m = 1.0 n_steps = 20 step_size = 1. / ((3. * np.sqrt(3) - np.sqrt(15)) * m / 2.) / float(n_steps)
#!/usr/bin/env python import numpy as np from results.data.store import load from correlations.acorr import acorr as getAcorr from correlations.errors import uWerr, gW from common.uWerrWind import plot, preparePlot from common.utils import saveOrDisplay save = False file_name = 'uWerrWind_mag2_hmc.py' dest = 'results/data/other_objs/uWerrWind_mag2_hmc_allPlot.pkl' a = load(dest) m = 1.0 n_steps = 10 step_size = 1. / ((3. * np.sqrt(3) - np.sqrt(15)) * m / 2.) / float(n_steps) tau = step_size * n_steps n, dim = 100, 1 x0 = np.random.random((n, ) * dim) spacing = 0.05 op_name = r'$\hat{O} = \phi_0^2 :\phi_0 = \mathcal{F}^{-1}\tilde{\phi}_0 = '\ + r' \sum_{x\in\mathbb{Z}^d_\text{L}}\tilde{\phi}_0$' subtitle = r"Potential: {}; Lattice Shape: ".format('Klein Gordon') \ + r"${}$; $a={:.1f}; \delta\tau={:.1f}; n={}$".format( x0.shape, spacing, step_size, n_steps) plot(save=saveOrDisplay(save, file_name), **a)