x0 = np.random.random((n, ) * dim)
spacing = 1.0

n_samples, n_burn_in = 10000, 50
c_len = 500

mixing_angles = [.5 * np.pi]
angle_labels = [r'\frac{\pi}{2}']

separations = range(c_len)
opFn = lambda samples: twoPoint(samples, separation=0)
op_name = r'$\hat{O} = x^2$'
op_theory = x2_1df(mu=pot.m, n=x0.size, a=spacing, sep=0)
pacc_theory = acceptance(dtau=step_size, tau=tau, n=x0.size, m=pot.m)

acFunc = lambda t, pa, theta: hmc(pa, tau * m, 1. / tau, t)

print '> Trajectory Length: tau: {}'.format(tau)
print '> Step Size: {}'.format(step_size)
print '> Theoretical <x^2>: {}'.format(op_theory)
print '> Theoretical <P_acc>: {}'.format(pacc_theory)

if '__main__' == __name__:
    routine.main(x0,
                 pot,
                 file_name,
                 n_samples=n_samples,
                 n_burn_in=n_burn_in,
                 spacing=spacing,
                 mixing_angles=mixing_angles,
                 angle_labels=angle_labels,
a = np.asarray(a)  # the autocorrelation array
counts = np.array(counts)  # the counts at each separation
# mask = 1-np.isnan(a)
# a = a[mask]
a = a * counts
# grab errors
print 'getting errors...'
ans = uWerr(op_samples, a)
_, _, _, itau, itau_diff, _, acns = ans  # extract data
my_w = getW(itau, itau_diff, n=n_samples)  # get window length
my_err = acorrnErr(acns, my_w, n_samples)  # get autocorr errors
my_err *= np.sqrt(n_samples) / np.sqrt(counts)

# theory calclations
th_x = np.linspace(min_sep, max_sep, 1000)
th = np.array([hmc(p, phi, r, i) for i in th_x])

from scipy.optimize import curve_fit

fn = lambda x, a, b, c: a * np.cos(b * x)**2 + c
expFn = lambda x, a, b, c: a * np.exp(-b * x) + c
cos_sq = curve_fit(fn, separations[:50], acns[:50])
exp_fit = curve_fit(expFn, separations[1:80], counts[1:80])

norm_cnt = expFn(0, *exp_fit[0]) / counts[1]
a0 = a[1] * norm_cnt

pp = Pretty_Plotter()
pp._teXify()
pp._updateRC()
n, dim = 100, 1
x0 = np.random.random((n, ) * dim)
spacing = 1.

n_samples, n_burn_in = 10000, 1000
c_len = 500

mixing_angles = [.5 * np.pi]
angle_labels = [r'\frac{\pi}{2}']

separations = range(c_len)
opFn = magnetisation_sq
op_name = r'$\mathscr{M}^2$'
pacc_theory = acceptance(dtau=step_size, tau=tau, n=x0.size, m=pot.m)

acFunc = lambda t, pa, theta: hmc(pa, tau * m, 1. / tau, t)
op_theory = hmc(pacc_theory, tau * m, 1. / tau, 0)

print '> Trajectory Length: tau: {}'.format(tau)
print '> Step Size: {}'.format(step_size)
print '> Theoretical <\phi_0^2>: {}'.format(op_theory)
print '> Theoretical <P_acc>: {}'.format(pacc_theory)

if '__main__' == __name__:
    routine.main(x0,
                 pot,
                 file_name,
                 n_samples=n_samples,
                 n_burn_in=n_burn_in,
                 spacing=spacing,
                 mixing_angles=mixing_angles,