Set the precision and import the necessary packages
%precision %g
%run "~/github/butools/Python/BuToolsInit.py"
Load the trace data from file
tr = np.loadtxt("../test/data/bctrace.iat")
Calculate the marginal moments $\mu_k$ from the trace data $x_i$ as $\mu_k=\frac{1}{N}\sum_{i=1}^N x_i$
MarginalMomentsFromTrace (tr, 5)
Calculate the lag $k$ moments $\eta_{ij}$ from the trace data as $\eta_{ij}=\frac{1}{N}\sum_{i=1}^{N-k} x_i x_{i+k}$
LagkJointMomentsFromTrace (tr, 1, 5)
Obtain the density function (pdf) of the trace
(x,y) = PdfFromTrace (tr, np.linspace(0, 0.2, 250))
Plot the body and the tail of the pdf
plt.figure(1, figsize=(12,4))
plt.subplot(121)
plt.plot(x,y)
plt.xlim(0,0.012)
plt.subplot(122)
plt.loglog(x,y)
plt.xlim(1e-3,2e-1)
Calculate the lag $k$ autocorrelation function of the trace as $r_k=\frac{1}{N-k}\frac{1}{\sigma^2}\sum_{i=1}^{N-k}(x_i-\mu_1)(x_{i+k}-\mu_1)$
acf = LagCorrelationsFromTrace (tr, 20000)
Plot the lag $k$ autocorrelation function on log scale
plt.figure(2, figsize=(12,4))
plt.subplot(121)
plt.plot(acf)
plt.xlim(1,10)
plt.subplot(122)
plt.loglog(acf)
plt.xlim(1,20000)