%% ================================================================
\chapter{Scientific context}
\label{chap:history}

%% ----------------------------------------------------------------
\section{Theory}

In 1924, the physicist Satyendra Nath Bose\index{Bose,~S.N.} examined the
quantum statistics of \plainidx{photons}.  In 1925, collaborating with Bose,
Albert Einstein\index{Einstein,~A.} realized that the same could be done with
non-interacting massive particles.  He also discovered the
\plainidx{condensation} phenomenon:  a macroscopic occupation of the
(single-particle) \plainidx{ground state} of the external potential
\cite{bib:lssy}.  Moreover, Einstein predicted a \plainidx{critical
temperature} for the phenomenon.  This temperature was so low --- at the
nanokelvin scale --- that \plainidx{Bose-Einstein condensation} attracted
little interest in the physics community.

Feynman\index{Feynman,~R.P.} in 1953, along with Penrose and Onsager in 1956
\cite{bib:feynman,bib:penons}, developed the theoretical notion of
\plainidx{long permutation cycles} in the \plainidx{Feynman-Kac representation}
of the Bose gas.  Feynman claimed that long cycles correspond to Bose-Einstein
condensation.

Andr\'as S\"ut\H{o} referred to the existence of long permutation cycles as
\emphidx{cycle percolation}.  He proved in 1993 that BEC implies cycle
percolation in the ideal (non-interacting) gas \cite{bib:suto1}, and proved the
converse in 2002.  S\"ut\H{o} moreover proved in the 2002 paper that there are
infinitely many macroscopic cycles in the condensation of the non-ideal Bose
gas.

For the ideal Bose gas, BEC is defined as the \plainidx{macroscopic occupation}
of the single-particle ground state of the \plainidx{external potential}.  For
an interacting Bose gas, Hamiltonian eigenfunctions do not factor and thus
there are no single-particle ground states.  BEC is carefully defined for
interacting systems \cite{bib:lssy} in terms of the largest eigenvalue of a
\plainidx{density-matrix operator}.  The 1983 work of Buffet and Pul\`e
\cite{bib:buffetpule} examines the macroscopic occupation of the \plainidx{zero
Fourier mode}.

%% ----------------------------------------------------------------
\section{Experiments}

Liquid helium was produced in the laboratory by Kammerlingh Onnes
\index{Onnes,~H.K.} in 1908; Fritz London\index{London,~F.} in 1938
\cite{bib:london} connected superfluidity of \plainidx{liquid helium} with
Bose-Einstein condensation.  Here, however, atoms of liquid helium are strongly
interacting --- they attract only weakly, due to helium being a noble gas, but
there are strong repulsive effects due to the high density of the liquid.
Thus, Einstein's non-interacting theory could not explain the phenomenon.

Several groups attempted during the 1990s to produce BECs in vapors of
spin-polarized hydrogen, but were not able to achieve low enough temperatures.
The group of Cornell and Wieman \cite{bib:boulder}, using hybrid cooling
methods, successfully brought \plainidx{rubidium} atoms to well below the
critical temperature and made numerous measurements on the resulting
condensates.  (Cornell, Wieman, and Ketterle received the 2001 Nobel prize in
physics for this work.)

Interest in BECs was sparked by this experimental success:  thousands of
papers, both theoretical and experimental, have been published on BECs in the
years since.  The work of Cornell and Wieman was of interest for several
reasons:

\begin{itemize}

\item Condensates were directly imaged.  Measurements were taken of temperature,
density, position, velocity, particle number, and the fraction of the
condensate occupying the ground state of the 3D harmonic trapping potential.

\item The method was able to vary temperature and density through wide ranges;
the \plainidx{condensate fraction} was varied from zero to 100 percent.

\item The gaseous rubidium condensate was \emphidx{weakly interacting} ---
permitting a perturbative analysis which liquid helium, with its strong
interactions, did not allow.  (Note in particular that recent mathematical
studies are weak-interaction theories; they are valid only to first order in
the scattering length.)

\end{itemize}

%% ----------------------------------------------------------------
\section{Critical temperature}
\label{sec:critical_temperature}

Recall that Einstein predicted a critical temperature $T_c$ for the ideal Bose
gas.  It is a long-standing question to discover the effects of
\plainidx{scattering length} \plainidx{$a$} on the critical temperature.
Moreover, one may fix the density $\rho_c{(a)}$ and obtain a critical
temperature $T_c{(a)}=1/\beta_c{(a)}$ or vice versa; also, both of these
critical parameters depend on the scattering length $a$.  One expects the
critical combination of parameters to be a manifold in $(\rho,\beta,a)$ space.
(See figure \ref{fig:critical_manifold}.)

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics{figures/critical_manifold.eps}
\caption{Critical manifold in $(\rho,\beta,a)$ for small $a$.
	\label{fig:critical_manifold}}
\end{center}
\end{figure}

Much is known about the $a=0$ line of this critical manifold; off $a=0$, even
the crude shape has been under debate.  The following findings are described by
\cite{bib:baymetal}:  The superfluid transition temperature of liquid helium is
lower than that of an ideal gas of the same density.  Thus, assuming that
helium superfluidity is a strongly interacting BEC, one would expect
interactions to decrease the critical temperature for the strongly interacting
case.  Various theoretical work (tabulated below) suggested either an increase
or a decrease in critical temperature; path-integral simulations for low
density (i.e. weak interactions) suggested that the critical temperature
increases with scattering length.  The emerging consensus is that
$$
	\Delta T_c(a) = \frac{T_c{(a)}-T_c{(0)}}{T_c{(0)}}
$$
is linear in $a$ for small $a$, i.e.
$$
	\Delta T_c(a) = c a + O(a^2).
$$

The following summary of the theoretical work on this question is found in
\cite{bib:su09}.  (See also \cite{bib:arnoldmoore,bib:kps,bib:nl04} for a
review on the widely varying analytical and simulational results on $T_c{(a)}$;
see \cite{bib:baymetal} for a thorough listing of the progress up to 2001 and
\cite{bib:su09} for an up-to-date survey.)

\begin{itemize}

\item 1964:
\emph{Huang}:
$\Delta T_c(a) \sim (a \rho^{1/3})^{3/2}$, increases

\item 1971:
\emph{Fetter \& Walecka}: % Analysis
$\Delta T_c(a)$ decreases

\item 1982:
\emph{Toyoda}: % Analysis
$\Delta T_c(a)$ decreases

\item 1992:
\emph{Stoof}: % Analysis
$
\Delta T_c(a) = c \, a \rho^{1/3} + o(a \rho^{1/3}), \quad c>0
$

\item 1996:
\emph{Bijlsma \& Stoof}: % Analysis
$c=4.66$

\item 1997:
\emph{Gr\"uter, Ceperley, Lalo\"e}: % PIMC
$c=0.34$

\item 1999:
\emph{Holzmann, Gr\"uter, Lalo\"e}: % Analysis
$c=0.7$;
{\emph{ Holzmann, Krauth}}: $c=2.3$;

\item 1999:
\emph{Baym et.\ al.}: % Analysis
$c=2.9$

\item 2000:
\emph{Reppy et.\ al.}: % Analysis
$c=5.1$

\item 2001:
\emph{Kashurnikov, Prokof'ev, Svistunov}: % PIMC
$c=1.29$

\item 2001:
\emph{Arnold, Moore}: % phi^4 field theory
$c=1.32$

\item 2004:
\emph{Kastening}: % Analysis
$c=1.27$

\item 2004:
\emph{Nho, Landau}: % PIMC
$c=1.32$

\end{itemize}

%% ----------------------------------------------------------------
\section{Context of dissertation}
\label{sec:context}

The work of Ueltschi and Betz \cite{bib:bu07,bib:ducycles,bib:qmath} extends
the permutation point of view originated by Feynman, Penrose, and Onsager,
drawing on the work of S\"ut\H{o}, Buffet, and Pul\`e
\cite{bib:feynman,bib:penons,bib:suto1,bib:suto2,bib:buffetpule} to develop a
model of random spatial permutations.  (See chapter \ref{chap:model_defns} for
precise definition of the model.) In the permutation representation, this
condensate transition manifests itself as the onset of long permutation cycles.
The central point of this approach is that the system energy has been recast in
terms of permutations, which are amenable to analysis and simulation.  This
permits a new perspective on an old question: the main goal of Ueltschi and
Betz's long-term project is to quantify the shift in critical temperature, as a
function of scattering length, for non-ideal Bose gases in the
small-scattering-length regime.

The interaction terms for the permutation representation of the Bose gas are
difficult to compute.  Moreover, it is interesting to consider the model of
random spatial permutations (which we sometimes refer to as the random-cycle
model) for its own sake.  Thus, Ueltschi, Betz, Gandolfo, Ruiz, and the author
take various approaches with varying degrees of fidelity to the physical
Bose-gas model.  In section \ref{sec:prb_model}, we will see a random-cycle
model for $N$ particles which is parameterized by $N$ \emphidx{cycle weights}
$\{\alpha_\ell\} = \alpha_1$, $\ldots$, $\alpha_N$.  The remainder of this
section involves results that may be obtained, analytically or simulationally,
when various constraints are placed on the cycle weights.

In the papers \cite{bib:qmath,bib:bu07}, Betz and Ueltschi examine the Bose-gas
permutation weights with point positions allowed to vary in the continuum; an
exact expression for the critical temperature is stated and proved for a
simplified interaction model in which only two-cycles interact.  The
cycle-weight parameter $\alpha_2$ is expressed in terms of the scattering
length $a$; all other cycle weights are set to zero.  In \cite{bib:bu08}, this
approach is extended to a model in which all the cycle weights $\alpha_\ell$
may vary, but with the constraint that $\alpha_\ell$ goes to zero faster than
$1/\log(\ell)$.  Here, an expression for the shift in critical temperature is
found, as a function of all $N$ cycle weights.  It is key to note that these
$\alpha_\ell$'s are not computed directly from the physical scattering length
$a$; rather, the result obtained is true for \emph{any} cycle weights
$\{\alpha_\ell\}$ satisfying the decaying-cycle-weight hypothesis.  In
\cite{bib:bu10}, Ueltschi and Betz estimate, to first order, cycle weights
$\{\alpha_\ell\}$ for the Bose gas.

Betz, Ueltschi, and Velenik \cite{bib:buv09} examine cycle weights
$\{\alpha_\ell\}$ with various hypotheses, including the Ewens \cite{bib:ewens}
case in which cycle weights are constant for all cycle lengths $\ell$.  These
random permutations are non-spatial, i.e. $T=0$ in the vocabulary of chapter
\ref{chap:model_defns}.  Their work is relevant to section \ref{sec:theory_fI}
of this dissertation.

As is often the case in statistical mechanics, the study of this interacting
system necessitates the use of computational methods --- specifically,
Markov-chain Monte Carlo.  In \cite{bib:gru}, a simulational approach is taken
for points held fixed on the cubic unit lattice in the non-interacting case
($\alpha_\ell \equiv 0$ in the language of chapter \ref{chap:model_defns}).

This dissertation, the only known simulation approach to the interacting model,
applies MCMC methods to the case where $N=L^3$ points are held fixed on the
fully occupied cubic unit lattice, with small additional probability weights
depending on cycle lengths.  This extends from\cite{bib:gru} as well as
\cite{bib:buv09}.  We find that even though lattice positions are used, and
even though the decaying-cycle-weight hypothesis is invalidated, one nonetheless
recovers the shift in critical temperature as predicted in the
decaying-cycle-weight model of \cite{bib:bu08}.

%% ----------------------------------------------------------------
\section{Literature review}

In addition to the many references made in previous sections of this chapter,
we point out the following.

The papers
\cite{bib:gcl97},
\cite{bib:kps},
\cite{bib:ceperley}, and
\cite{bib:nl04}
are among \plainidx{path-integral Monte Carlo} simulational approaches to Bose-Einstein
condensation --- perhaps the closest relatives to the numerical work done in
\cite{bib:gru} and in this dissertation.

The doctoral dissertations of Peter Gr\"uter and Markus Holzmann
\cite{bib:gruter1996,bib:holzmann2000} are paradigmatic examples of clear
dissertation writing; the latter also provided insight into finite-size scaling.
%\cite{bib:feynman}
% Feynman,~R.P.
% \newblock {\em Atomic Theory of the $\lambda$ Transition in Helium}.
% \newblock The Physical Review, vol. 91, no. 6 (1953).
%
% \cite{bib:penons}
% Penrose,~O. and Onsager,~L.
% \newblock {\em Bose-Einstein Condensation and Liquid Helium}.
% \newblock The Physical Review, vol. 104, no. 3 (1956).
%
% \cite{bib:london}
% London,~F.
% \newblock Phys. Rev. vol. 54, no. 947 (1938).
%
%\cite{bib:boulder}
% Anderson,~M.H., Ensher,~J.R., Matthews,~M.R., Wieman,~C.E., and Cornell,~E.A.
% \newblock {\em Observation of Bose-Einstein Condensation in a Dilute Atomic
%   Vapor}.
% \newblock \emph{Science}, vol. 269, issue 5221 (Jul. 14 1995), 198-201.
%
% \cite{bib:baymetal}
% Baym,~G., Blaizot,~J.-P., Holzmann,~M., Lalo\"e,~F., and Vautherin,~D.
% \newblock {\em Bose-Einstein transition in a dilute interacting gas}.
% \newblock \texttt{arXiv:cond-mat/0107129v2}.
%
% \cite{bib:lssy}
% Lieb,~E.H., Seiringer,~R., Solovej,~J.P., and Yngvason,~J.
% \newblock {\em The Mathematics of the Bose Gas and its Condensation}.
% \newblock Oberwolfach Seminars, vol. 34.
% \newblock Birkh\"auser, 2005.
%
% \cite{bib:su09},
% Seiringer,~R. and Ueltschi,~D.
% \newblock {\em Rigorous upper bound on the critical temperature of dilute Bose
% gases}.
% %\newblock \texttt{arXiv.org:0904.0050}.
% \newblock Phys. Rev. B 80, 014502 (2009).
%
% \cite{bib:arnoldmoore}.
% Arnold,~X. and Moore,~X.
% \newblock {\em BEC transition temperature of a dilute homogeneous imperfect
%   Bose gas}.
% \newblock Phys. Rev. Lett. vol. 87, no. 12, Sept. 2001.

%% ----------------------------------------------------------------
%The model of random spatial permutations is developed by Ueltschi and Betz
%in
%\cite{bib:ducycles},
% Ueltschi,~D.
% \newblock {\em Feynman cycles in the Bose gas.}
% \newblock \texttt{arXiv:math-ph/0605002v2}.
%\cite{bib:bu07},
% Betz,~V. and Ueltschi,~D.
% \newblock{\em Spatial random permutations and infinite cycles}.
% %\newblock \texttt{arXiv:0711.1188}.
% \newblock Commun. Math. Phys. 285, 469-501 (2009).
%
%\cite{bib:qmath}.
% Ueltschi,~D.
% \newblock {\em The model of interacting spatial permutations and its relation
% to the Bose gas.}
% %\newblock \texttt{arXiv:0712.2443v3}.
% \newblock Mathematical Results in Quantum Mechanics, pp. 225-272,
% World Scientific (2008).
%and \cite{bib:bu08}.
% Betz,~V. and Ueltschi,~D.
% \newblock {\em Spatial random permutations with small cycle weights.}
% %\newblock \texttt{arXiv:0812.0569v1}.
%Their work uses the Fourier method of Buffet and Pul\'e \cite{bib:buffetpule}.
% \cite{bib:buffetpule}
% Buffet,~E. and Pul\`e,~J.V.
% \newblock {\em Fluctuation properties of the imperfect Bose gas}.
% \newblock J. Math. Phys. vol. 24, no. 6, June 1983.
%
% \cite{bib:suto1} and \cite{bib:suto2}
% S\"ut\H{o},~A.
% \newblock {\em Percolation transition in the Bose gas.}
% \newblock J. Phys. A: Math. Gen. \textbf{26} (1993) 4689-4710.
%
% S\"ut\H{o},~A.
% \newblock {\em Percolation transition in the Bose gas II.}
% \newblock J. Phys. A: Math. Gen. \textbf{35} (2002) 6995-7002.
% \newblock Probabl. Th. Rel. Fields (2010).
%The only published work on simulation of the random-cycle model, which treats
%the non-interacting model, is \cite{bib:gru}.
% Gandolfo,~D., Ruiz,~J., and Ueltschi,~D.
% \newblock {\em On a model of random cycles}.
% %\newblock \texttt{arXiv:cond-mat/0703315}.
% \newblock Statist. Phys. 129, 663-676 (2007).
%This dissertation is the first published work on simulations of the
%interacting model.

% %% ----------------------------------------------------------------
Mean longest cycle for uniformly distributed (i.e. non-interacting,
non-spatial) permutations ($T=0$ and $\alpha=0$ in the language of chapter
\ref{chap:model_defns}) was discussed by \cite{bib:shepplloyd}, following a
question posed by \plainidx{Golomb}\index{Shepp and Lloyd} on the basis of
experimental data \cite{bib:golomb}.  See also sections
\ref{sec:known_results} and \ref{sec:conj}.
% Shepp,~L.A. and Lloyd,~S.P.
% \newblock{\em Ordered Cycle Length in a Random Permutation}.
% \newblock Trans. Amer. Math. Soc. 121, (1966), 340-357.
%
% Golomb,~S.W.
% \newblock {\em Random permutations}.
% \newblock Bull. Amer. Math. Soc. 70 (1964), 747.
%
Non-uniformly distributed non-spatial permutations with constant cycle weights
($T=0$ and $\alpha\ne 0$ in the language  of chapter \ref{chap:model_defns})
arose in mathematical biology \cite{bib:ewens}.
% Ewens,~W.J.
% \newblock {\em The sampling theory of selectively neutral alleles}.
% \newblock Theor. Popul. Biol. 3, 87-112 (1972).

% %% ----------------------------------------------------------------
Background in quantum mechanics and statistical mechanics may be found in
%
\cite{bib:griffiths},
% Griffiths,~D.J.
% \newblock {\em Introduction to Quantum Mechanics} (2nd ed.).
% \newblock Pearson Prentice Hall, 2005.
%
\cite{bib:huang},
% Huang,~K.
% \newblock {\em Introduction to Statistical Physics}.
% \newblock CRC Press, 2001.
%
and \cite{bib:sakurai}.
% Sakurai,~J.J.
% \newblock {\em Modern Quantum Mechanics} (2nd ed.).
% \newblock Addison Wesley, 1993.

% %% ----------------------------------------------------------------
Worm algorithms\index{worm algorithms} for path-integral Monte Carlo, which
inspired my random-spatial-permutation worm algorithm of chapter
\ref{chap:worm}, are used throughout simulational physics.  See in particular
%
\cite{bib:bps06} and
% Boninsegni,~M., Prokof'ev,~N.V., and Svistunov,~B.V.
% \newblock {\em Worm algorithm and diagrammatic Monte Carlo:  A new approach
%   to continuous-space path integral Monte Carlo simulations.}
% \newblock Physical Review E \textbf{74}, 036701 (2006).
%
\cite{bib:pst98}.
% Prokof'ev,~N.V., Svistunov,~B.V., and Tupitsyn,~I.S.
% \newblock {\em Exact, complete, and universal continuous-time worldline Monte
%   Carlo approach to the statistics of discrete quantum systems.}
% \newblock Journal of Experimental and Theoretical Physics, vol. 87, no. 2
%   (1998).

% %% ----------------------------------------------------------------
Finite-size scaling\index{finite-size scaling} techniques are employed for
path-integral Monte Carlo simulations in
%
\cite{bib:gcl97},
% Gr\"uter,~P. and Ceperley,~D.
% \newblock {\em Critical temperature of Bose-Einstein condensation of
%   hard-sphere gases.}
% \newblock Physical Review Letters, vol. 79, no. 19 (1997).
%
\cite{bib:hk99},
% Holzmann,M. and Krauth,~W.
% \newblock {\em Transition temperature of the homogeneous, weakly interacting
%   Bose gas.}
% \newblock Physical Review Letters, vol. 83, no. 14 (1999).
%
\cite{bib:kps},
% Kashurnikov,~V.A., Prokof'ev,~N.V., and Svistunov,~B.V.
% \newblock {\em Critical temperature shift in weakly interacting Bose gas}.
% \newblock Physical Review Letters, vol. 87, no. 12 (2001).
%
\cite{bib:nl04},
% Nho,~K. and Landau,~D.P.
% \newblock {\em Bose-Einstein condensation temperature of a homogeneous
%   weakly interacting Bose gas:  Path integral Monte Carlo study.}
% \newblock Physical Review A \textbf{70}, 053614 (2004)
%
\cite{bib:pc87},
% Pollock,~E.L. and Ceperley,~D.M.
% \newblock {\em Path-integral computation of superfluid densities.}
% \newblock Physical Review B, vol. 36, no. 16 (1987).
%
\cite{bib:pgp08},
% Pilati,~S., Giorgini,~S., and Prokof'ev,~N.V.
% \newblock {\em Critical temperature of interacting Bose gases in two and
%   three dimensions.}
% \newblock Physical Review Letters \textbf{100}, 140405 (2008).
%
and \cite{bib:pr92}.
% Pollock,~E.L. and Runge,~K.J.
% \newblock {\em Finite-size-scaling analysis of a simulation of the
%   ${}^4$He superfluid transition}.
% \newblock Physical Review B, vol. 46, no. 6 (1992).
%
Citation trails in the above-cited works lead back to \cite{bib:barber}.
%
Some background information is found in \cite{bib:landaubinder};
% Landau,~D.P. and Binder,~K.
% \newblock {\em A Guide to Monte Carlo Simulations in Statistical Physics}
%   (2nd ed.).
% \newblock Cambridge University Press, 2005.
%
an excellent survey, encompassing and explicating all the above methods ---
truly a blessing for the aspiring learner --- is \cite{bib:pv}.

% %% ----------------------------------------------------------------
\plainidx{Markov chain Monte Carlo} methods are discussed in
\cite{bib:landaubinder};
% Landau,~D.P. and Binder,~K.
% \newblock {\em A Guide to Monte Carlo Simulations in Statistical Physics}
%   (2nd ed.).
% \newblock Cambridge University Press, 2005.
%
this dissertation has been influenced most heavily by \cite{bib:berg}.  Indeed,
my appendix \ref{appx:eta} is an elaboration on Berg's discussion of integrated
autocorrelation time.
% Berg,~B.
% \newblock {\em Markov Chain Monte Carlo Simulations and Their Statistical
%   Analysis}.
% \newblock World Scientific Publishing, 2004.
%
The probability background necessary for either Landau and Binder or Berg
may be found, with increasing levels of sophistication, in
\cite{bib:lawler}, \cite{bib:gs}, and \cite{bib:oksendal}.
% Grimmett,~G. and Stirzaker,~D.
% \newblock {\em Probability and Random Processes}, 3rd ed.
% \newblock Oxford, 2001.
%
% Lawler,~G.
% \newblock {\em Introduction to Stochastic Processes} (2nd ed.).
% \newblock Chapman \& Hall/CRC, 2006.
%
% {\O}ksendal,~B.
% \newblock {\em Stochastic Differential Equations} (6th ed.).
% \newblock Springer, 2007.
%
The standard reference for statistical analysis, including confidence
intervals, is \cite{bib:cb}.
% Casella,~G. and Berger,~R.L.
% \newblock {\em Statistical Inference} (2nd ed.).
% \newblock Duxbury Press, 2001.
More practical aspects of the statistical reduction of experimental data
are found in \cite{bib:young}.
% Young,~H.D.
% \newblock {\em Statistical Treatment of Experimental Data}.
% \newblock McGraw-Hill, 1962.

% %% ----------------------------------------------------------------
The \plainidx{Mersenne Twister} \cite{bib:mersenne} is the pseudo-random-number
generator used in the this dissertation's computational work.  Another good
generator is pseudo-DES \cite{bib:nr}.  Moreover, any numerical dissertation
without a reference to \emph{Numerical Recipes} is incomplete; its inclusion
here is as good a point as any to end the literature review.
% Matsumoto,~M. and Nishimura,~T.
% \newblock{Mersenne twister: a 623-dimensionally equidistributed uniform
% pseudo-random number generator}.
% \newblock ACM Transactions on Modeling and Computer Simulation,
% Volume 8, Issue 1 (Jan. 1998), pp 3-30.
%
% Press,~W. et al.
% \newblock {\em Numerical Recipes} (2nd ed.).
% \newblock Cambridge, 1992.

%% ----------------------------------------------------------------
\section{Originality of dissertation}

Last, we delineate the originality of work presented in this dissertation.
Chapters \ref{chap:history}-\ref{chap:RV_theory} are a
rephrasing and an elaboration on \cite{bib:bu07,bib:bu08,bib:qmath}.  Chapter
\ref{chap:MCMC} is quite standard; the contribution made here is to present
familiar general results in the specific context of random permutations.  The
essential SO algorithm of chapter \ref{chap:SO_SAR}, with a small modification,
was presented in \cite{bib:gru}; likewise for the SO $\Delta H$ computations in
chapter \ref{chap:Delta_H}.  The treatment here is the first correctness proof
of the SO algorithm.  The SAR algorithm of chapter \ref{chap:SO_SAR} was
suggested by Daniel Ueltschi.  The band-update algorithm (chapter
\ref{chap:band_updates}) is due to the author.  The worm algorithm and its
correctness proof (chapter \ref{chap:worm}) are due to the author, along with
the remaining $\Delta H$ computations of chapter \ref{chap:Delta_H}.  The
remaining chapters, \ref{chap:sw}-\ref{chap:future_work}, are also original
work.  Appendix \ref{appx:eta} is a new take on an old question; see also
\cite{bib:berg}.  The correlated-uniform Markov process is original, as is the
explicit comparison of batched and non-batched means for exponentially
correlated stationary Markov processes.

%% ================================================================
\chapter{The model of random spatial permutations}
\label{chap:model_defns}

Here we review concepts from \cite{bib:bu07,bib:bu08}, fixing notation and
intuition to be used in the rest of the paper.

%% ----------------------------------------------------------------
\section{The probability model}
\label{sec:prb_model}

Our \plainidx{state space} is $$ \Omega_{\Lambda,N} = \Lambda^N \times \SN $$
where $\Lambda=[0,L]^3$ with \plainidx{periodic boundary conditions} and $\SN$
is the group of \plainidx{permutations} of $N$ points\footnote{One may of
course consider $\Lambda=[0,L]^d$ for $d=1,2$, but for this paper, $d=3$
only.}. Point positions\index{point positions} are $\vecX = (\vecx_1, \ldots,
\vecx_N)$ for $\vecx_1, \ldots, \vecx_N \in \Lambda$.  These are called
\plainidx{spatial permutations} in that they involve the permutation $\pi$ as
well as the $N$ point positions $\vecx_1, \ldots, \vecx_N$.  See figure
\ref{fig:pmt1}.

The \plainidx{probability measure} on this state space will be constructed via
\plainidx{Gibbs measure}, $P = e^{-H}/Z$, on a
\index{$H$}\plainidx{Hamiltonian} $H$.  The background probability measure is
discrete (uniform) in $\pi$ and continuous (Lebesgue) in $\vecX$.  The
Hamiltonian takes one of two forms.  In the first, relevant to the Bose gas, we
have
\begin{align}
\label{eqn:RCM_H_gen_V}
	H(\vecX,\pi) &= \frac{T}{4} \sum_{i=1}^N \|\vecx_i-\vecxpii\|_\Lambda^2
		+ \sum_{1 \le i<j \le N} V(\vecx_{i}, \vecx_{\pi(i)}, \vecx_{j}, \vecx_{\pi(j)})
\end{align}
where $T=1/\beta$ and the $V$ terms are \plainidx{interactions} between
permutation jumps.  The notation $\|\cdot\|_\Lambda$ indicates the natural
distance on the 3-torus:
\begin{align}
\label{eqn:prb_model_torus_diff}
	\|\vecx - \vecy\|_\Lambda &=
		\min_{\vecn\in \Z^3} \{\|\vecx - \vecy + L \vecn\|\}
\end{align}
For the $V$ terms in equation \eqref{eqn:RCM_H_gen_V}, the permutation jump
$\vecxi\mapsto\vecxpii$ interacts with the permutation jump
$\vecxj\mapsto\vecxpij$.  The temperature scale factor $T/4$, not $\beta/4$, is
atypical in statistical mechanics.  For purposes of the current work, this may
be considered an \plainidx{ansatz}; in \cite{bib:bu07}, this choice of scale
factor is shown to be appropriate for permutation representation of the Bose
gas.  In particular, as will be explained in more detail below, only the
identity permutation appears at high $T$, and (with $V \equiv 0$) uniformly
weighted permutations appear at zero $T$.

In the second form of the Hamiltonian, considered in this paper, we use
interactions which are dependent solely on cycle lengths:
\begin{align}
\label{eqn:RCM_H_rell_V}
	H(\vecX,\pi) &= \frac{T}{4} \sum_{i=1}^N \|\vecx_i-\vecxpii\|_\Lambda^2
		+ \sum_{\ell=1}^N \alpha_\ell r_\ell(\pi),
\end{align}
where $r_\ell(\pi)$ is the number of $\ell$-cycles in $\pi$, for $\ell$ from
$1$ and $N$, and the $\alpha_\ell$'s are free parameters, called \emphidx{cycle
weights}.  One ultimately hopes to choose the $\alpha_\ell$'s appropriately for
the Bose gas; even if not, the model is well-defined and of its own
mathematical interest.

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=1.0]{figures/pmt1.eps}
\caption[A spatial permutation on $N=26$ points.]
	{A spatial permutation on $N=26$ points.  There are 11 one-cycles, three
	two-cycles, one four-cycle, and one five-cycle.  We say $r_1(\pi)=11$,
	$r_2(\pi)=3$, $r_4(\pi)=1$, $r_5(\pi)=1$, and $r_\ell(\pi) = 0$ for all
	other $\ell$.
	\label{fig:pmt1}}
\end{center}
\end{figure}

The first contribution to the energy\footnote{The papers \cite{bib:bu07} and
\cite{bib:qmath} generalize from $\|\vecx_i-\vecxpii\|_\Lambda$ to
$\xi(\vecx_i,\vecxpii)$ where $\xi$ is a spherically symmetric
non-negative-valued function on $\R^d$ having integrable $e^{-\xi}$.  This
generalization is not of interest in this dissertation.} is the sum of squares
of permutation jump lengths.  Since we will use a Gibbs distribution with $P =
e^{-H}/Z$, the highest-probability permutations will be the ones with lowest
energy.  Thus, permutations with long jumps will be disfavored; permutations
with many short jumps will be less strongly disfavored.  The second
contribution to the energy involves cycle weights.  We consider only small
cycle weights, which perturb the critical temperature but which do not
qualitatively modify the effects of the distance-related terms.  More intuition
for the model will be presented in section \ref{sec:qual_long_cycles}.

Choices of point positions $\vecx_1, \ldots, \vecx_N$ yield two cases: (1) In
the \emphidx{annealed model}, point positions are variable in the
\plainidx{continuum} (here, uniform random) and are averaged over.  One has a
particle \plainidx{density} $\rho=N/L^3$.  This model is examined analytically
in \cite{bib:bu07,bib:qmath,bib:bu08}.  (2) In the \emphidx{quenched model},
point positions are held fixed.  Specifically, we consider $N=L^3$ points on
the fully occupied integer-indexed sites of the $L \times L \times L$ cubic
\plainidx{lattice}.  This model is examined simulationally in \cite{bib:gru}
and in this dissertation.  We often write $H(\pi)$ in place of $H(\vecX,\pi)$
since we either work on a lattice where the $\vecx_i$'s are held fixed, or on
the continuum where the $\vecx_i$'s are integrated out.  Thus, the system
energy $H$ (as well as all other random variables we consider) is a function of
the permutation $\pi$.

%\textbf{Partition functions:}
We consider two \index{partition function}partition functions, for a fixed
point configuration $\vecX$ and for an average over point configurations,
respectively:
$$
	Y(\Lambda,\vecX) = \sum_{\sigma\in\SN} e^{-H(\vecX,\sigma)}
	\qand
	Z(\Lambda,N) = \frac{1}{N!} \int_{\Lambda^N} Y(\Lambda,\vecX)\,d\vecX.
$$
%\textbf{Probability measures:}
Fixing point positions $\vecX$, we have a \plainidx{discrete distribution} on
$\pi$:
\begin{align}
\label{eqn:RCM_Gibbs_P}
	Y(\Lambda,\vecX) &= {\sum_{\sigma\in\SN} e^{-H(\vecX,\sigma)}}, &
	P(\pi) = P_{\Lambda,\vecX}(\pi)
	&= \frac{e^{-H(\vecX,\pi)}} {Y(\Lambda,\vecX)}.
\end{align}
For varying point positions (e.g. for considerations of the Bose gas), we have
a \plainidx{joint distribution} which is continuous in $\vecX$ and discrete in
$\pi$:
\begin{align*}
	P_{\Lambda,N}(\vecX,\pi)\,d\vecX &= \frac{e^{-H(\vecX,\pi)} d\vecX}
		{Z(\Lambda,N)}.
\end{align*}
From this we obtain two \plainidx{marginal distributions}.  If we integrate
over point configurations $\vecX$, then we obtain a discrete distribution on
$\SN$:
\begin{align*}
	P_{\Lambda,N}(\pi) &=
		\frac{1}{N!} \int_{\Lambda^N} d\vecX\, P_{\Lambda,N}(\vecX,\pi)
	= \frac{
			\frac{1}{N!} \int_{\Lambda^N} d\vecX\, e^{-H(\vecX,\pi)}
		}{
			\frac{1}{N!} \int_{\Lambda^N} d\vecX\,
				\sum_{\sigma\in\SN} e^{-H(\vecX,\sigma)}
		}
	= \frac{
			\int_{\Lambda^N} d\vecX\, e^{-H(\vecX,\pi)}
		}{
			Z(\Lambda,N)\,N!
		}.
\end{align*}
If, on the other hand, we sum over permutations, then we obtain a
\plainidx{continuous distribution} for point configurations:
\begin{align}
\label{eqn:true_dist}
	P_{\Lambda,N}(\vecX)\,d\vecX
	&= \sum_{\pi\in\SN} P_{\Lambda,N}(\vecX,\pi)\,d\vecX
	= \frac{Y(\Lambda,\vecX)\,d\vecX}{Z(\Lambda,N)}.
\end{align}
This continuous distribution is certainly of interest:  it is the point
distribution for the Bose gas, when the Hamiltonian is appropriately chosen.
However, it is very difficult to compute:  this is but one of several results
in \cite{bib:lls}.  From here on, we consider the two discrete
distributions\index{discrete distribution} on $\SN$, namely,
$P_{\Lambda,\vecX}(\pi)$ and $P_{\Lambda,N}(\pi)$.

%\textbf{Expectations:}
For\index{expectation} a random variable $X(\pi)$, we have
$$
	\bbE_{\Lambda,\vecX}[X] =
	\frac{
		\sum_{\pi\in\SN} X(\pi) e^{-H(\vecX,\pi)}
	}{Y(\Lambda,\vecX)}
	\qand
	\bbE_{\Lambda,N}[X] =
	\frac{
		\int_{\Lambda^N} d\vecX \sum_{\pi\in\SN} X(\pi) e^{-H(\vecX,\pi)}
	}{Z(\Lambda,N) N!}.
$$
In either case, we also write the probability $P(\pi)$ and the expectation as
\begin{align}
\label{eqn:E_pi}
	\bbE[X] &= \sum_{\pi\in\SN} P(\pi) X(\pi).
\end{align}

%% ----------------------------------------------------------------
\section{Model variants by choice of cycle weights}
\label{sec:choices_of_cycle_weights}

The model of random spatial permutations is in fact a family of models.  As
described in the previous section, point positions may be annealed or quenched,
the latter being the case for this dissertation.  Likewise, various constraints
may be placed on the cycle weights.  Recall from equation
\eqref{eqn:RCM_H_rell_V} that
\begin{align}
	H(\vecX,\pi) &=
	\frac{T}{4} \sum_{i=1}^N \|\vecx_i-\vecxpii\|_\Lambda^2
	+ \sum_{\ell=1}^N \alpha_\ell r_\ell(\pi).
\end{align}
There are $N$ free parameters $\alpha_\ell$, and thus many models of spatial
permutations.  (See also figure \ref{fig:model_hierarchy}.)

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.72]{figures/model-hierarchy.eps}
\caption
	[Model variants by choice of point positions and cycle weights.]
	{Model variants by choice of point positions and choice of cycle weights.
	\label{fig:model_hierarchy}}
\end{center}
\end{figure}

If $\alpha_\ell=0$ for all $\ell$, one obtains the \emphidx{non-interacting
case}.
%
When $\alpha_2=\alpha$ and $\alpha_\ell=0$ for $\ell \ne 2$, we have the
\emphidx{two-cycle model} \cite{bib:bu07,bib:qmath}.  As $\alpha$ is increased,
two-cycles are discouraged.
%
Otherwise, we have the \emphidx{general-cycle model}.  This splits into (at
least) three submodels:
%
Betz and Ueltschi, in \cite{bib:bu08}, consider the case where $\alpha_\ell$
tend toward zero faster than $1/\log(\ell)$.  (Note that this includes the
two-cycle model as a special case.)
%
Ideally, one would have $\alpha_\ell$'s which match the Brownian-bridge
interactions
% xxxx write and xref
for the Bose gas.  Work in this direction has recently been done
by Betz and Ueltschi \cite{bib:bu10}, but is beyond the scope of this
dissertation.

For this dissertation, we consider the case where $\alpha_\ell=\alpha$ is
constant in $\ell$.  We call this the is the \emphidx{spatial Ewens
distribution}\index{Ewens distribution} \cite{bib:ewens}.  In summary, the
model considered in this dissertation uses point positions held fixed on the
fully occupied cubic unit lattice, with small non-negative Ewens cycle weights.

%% ----------------------------------------------------------------
\section{Qualitative characterization of long cycles}
\label{sec:qual_long_cycles}

Having seen definitions for the probability model, one next asks what
a\index{typical permutation} typical random spatial permutation looks like.  In
this section we develop intuition; in section \ref{sec:ordps}, we construct
quantitative descriptions of the ideas presented here.

\begin{figure}[!htb]
\psfragscanon
\begin{center}
\includegraphics[scale=0.6]{figures/dis_dot_plot_high_T.eps}
\qquad
\includegraphics[scale=0.6]{figures/dis_dot_plot_medium_T.eps}
\qquad
\includegraphics[scale=0.6]{figures/dis_dot_plot_low_T.eps}
\caption
	[Some typical permutations for varying $T$.]
	{Points and permutation jumps, for a typical permutation at
	high $T$ (short cycles of short jumps), medium but subcritical $T$ (all
	jump lengths are short, with occasional long cycles thereof), and low $T$
	(jump lengths are arbitrary).
	\label{fig:dot_plots}}
\end{center}
\end{figure}

As $T \to \infty$, the probability measure becomes supported only on the
identity permutation:  the \plainidx{distance-dependent terms} in equation
\eqref{eqn:RCM_H_rell_V} are large whenever any jump has non-zero length.  For
large but finite $T$, the length-dependent terms penalize permutation jumps
from a site to any site other than itself.  Thus, for large $T$ we expect the
\plainidx{identity permutation} to be the most likely, with occasional
2-cycles, 3-cycles, etc. which involve nearby points.  On the other extreme, as
$T \to 0$, length-dependent terms go to zero and the probability measure
approaches the \plainidx{uniform distribution} on $\SN$:  the
distance-dependent terms all go to zero.  For intermediate $T$, one observes
that the length $\|\pi(\vecx)-\vecx\|_\Lambda$ of each permutation jump remains
small, increasing smoothly as $T$ drops.  See figure
\ref{fig:mean_max_jump_len_LTa} on page \pageref{fig:mean_max_jump_len_LTa} for
more precise information.

The intermediate-temperature regime is the one of interest.  As is found in
theoretical and simulational work, as detailed through the rest of this
dissertation, this regime has the following properties.  There is a
\plainidx{phase transition}: for $T$ below a critical temperature $T_c$, while
individual jump lengths remain short (i.e. we work in the
\plainidx{short-jump-length regime}), \emph{arbitrarily long cycles form}.  See
figure \ref{fig:dot_plots} for depictions of typical permutations at high $T$,
subcritical $T$, and low $T$.  In the non-interacting case, $T_c(0)$ is
approximately 6.87; interactions in the form of positive $\alpha$ terms
interactions increase $T_c(\alpha)$.  Quantifying that dependence, i.e.
\begin{align}
\label{eqn:Delta_Tc}
	\Delta T_c(\alpha) &= \frac{T_c(\alpha)-T_c(0)}{T_c(0)},
\end{align}
as a function of $\alpha$ for small positive $\alpha$, is the central goal of
this dissertation.

From figures such as \ref{fig:dot_plots}, one can detect long cycles visually.
How do we measure them numerically?  Let $\ellmax(\pi)$ be the length of the
longest cycle in $\pi$, with $\bbE[\ellmax]$ its mean over all permutations.
We take $N=L^3$ points on the $L \times L \times L$ unit lattice with
periodic boundary conditions.
We observe that for $T$ above $T_c$, $\bbE[\ellmax]$ is constant as
$L\to\infty$: the mean length of the longest cycle increases only perhaps as
fast as $\log L$ as $L$ increases.  That is to say, $\bbE[\ellmax]/N$ goes to
zero as $L\to\infty$.  For $T$ below $T_c$, the length of the longest cycle
does increase as $L$ increases.  We find that $\bbE[\ellmax]$ scales with $N$.
(This is one of the results of \cite{bib:suto1}; it is perhaps surprising
that the scaling is by $N=L^3$ rather than, say, $L^2$.)
That is to say, $\bbE[\ellmax]/N$ approaches a temperature-dependent constant
as $L\to\infty$: there are arbitrarily long cycles, or infinite cycles, in the
infinite-volume limit.  See figure \ref{fig:E_ellmax_N} for plots of
$\bbE[\ellmax]/N$ as a function of $T$ for various system sizes with $N=L^3$.
See also figure \ref{fig:r_small_and_lmax} of section
\ref{sec:comput_lmax_GRU_quot}.  Precise information about $\bbE[\ellmax]/N$
and other quantities is found in section \ref{sec:ordps}.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/resultsfigs/graph_rell_alpha0_0.000_E_ellmax_N.eps}
\includegraphics[scale=0.6]{../tests/fss3a/resultsfigs/graph_rell_alpha0_0.001_E_ellmax_N.eps}
\caption
	[Order parameter $\fM = \bbE\ellmax/N$.]
	{Order parameter $\fM = \bbE[\ellmax]/N$ for finite systems, with
	$\alpha=0,0.001$.  Interactions increase the critical temperature.
	\label{fig:E_ellmax_N}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Known results}
\label{sec:known_results}

In this dissertation we study chiefly the $\alpha$-dependent shift in critical
temperature for Ewens cycle weights and cubic-lattice point positions.  We will
also consider an $\alpha$-dependent macroscopic-cycle quotient, to be defined
below.  Here we survey known results for related models --- namely, other cycle
weights as described in section \ref{sec:choices_of_cycle_weights}, and point
positions integrated over the continuum  --- before stating our conjectures for
our model in section \ref{sec:conj}.

Known results for point locations averaged over the continuum (as discussed in
section \ref{sec:prb_model}) are obtained largely using \plainidx{Fourier
methods} \cite{bib:bu08} which are unavailable for point positions held fixed
on the lattice.  Betz and Ueltschi have determined $\Delta T_c(\alpha)$, to
first order in $\alpha$, for two-cycle interactions \cite{bib:bu07} and
\plainidx{decaying cycle weights} \cite{bib:bu08}.  The critical
$(\rho,T,\alpha)$ manifold\index{critical manifold} relates $\rho_c$ to $T_c$.
Specifically, they obtain the following, with the decaying-cycle-weight
constraint on the cycle weights $\{\alpha_\ell\}$:
\begin{align}
\label{eqn:rho_c_decaying_alpha_ell}
	\rho_c(\alpha_1, \alpha_2, \ldots)
	&= \frac{1}{(4\pi\beta)^{3/2}}
		\sum_{\ell \ge 1} e^{-\alpha_\ell} \ell^{-3/2}.
\end{align}
In the non-interacting special case, all cycle weights are zero, and we have
\begin{align}
	\rho_c(0)
	&= \frac{1}{(4\pi\beta)^{3/2}}
		\sum_{\ell \ge 1} \ell^{-3/2}
	= \frac{\zeta(3/2)}{(4\pi\beta)^{3/2}}
\end{align}
where $\zeta$ is the Riemann zeta function.  For the two-cycle special case
\cite{bib:bu07}, $\alpha_2$ is non-zero, and the other cycle weights are zero.
We have
\begin{align*}
	\rho_c(\alpha)
	&= \frac{1}{(4\pi\beta)^{3/2}}
		\left(
		e^{-\alpha} 2^{-3/2} +
		\sum_{\ell \ne 2} e^{-\alpha_\ell} \ell^{-3/2} \right)
	= \rho_c(0) - \frac{(1-e^{-\alpha})}{(8\pi\beta)^{3/2}}.
\end{align*}

In addition to our main interest on the shift in critical temperature (here,
phrased in terms of critical density), we also examine the fraction of sites in
macroscopic cycles.  As will be discussed in more detail in sections
\ref{sec:theory_fI} and \ref{sec:theory_lmax_GRU_quot}, $\ellmax$ is the length
of the longest cycle of a permutation; $f_I$ will quantify the fraction of
sites participating in long cycles.  For $\alpha_\ell \equiv 0$ (the
non-interacting model), one observes empirically that the
\emphidx{macroscopic-cycle quotient} $\bbE[\ellmax] / N f_I$ is constant for
$T$ below but near $T_c$.  (That is, the two order parameters $f_I$ and
$\bbE[\ellmax]/N$ have the same critical exponent.)  For
uniform-random\index{uniform permutations} (non-spatial) permutations, Shepp
and Lloyd 1966 \cite{bib:shepplloyd} solved Golomb's 1964 question
\cite{bib:golomb}: $\bbE[\ellmax]/N \approx 0.6243$.  Unpublished work of Betz
and Ueltschi has found $\bbE[\ellmax]/N f_I$ holds that same value for random
spatial permutations in the non-interacting case $\alpha_\ell \equiv 0$.  The
intuition is that long cycles are uniformly distributed within the zero Fourier
mode.

%% ----------------------------------------------------------------
\section{Conjectures}
\label{sec:conj}

Equation \eqref{eqn:rho_c_decaying_alpha_ell} gives $\rho_c$ as a function of
$\beta=1/T$.  For the cubic unit lattice, we fix $\rho \equiv 1$ and thus
obtain $\beta_c$, or equivalently $T_c$:
\begin{align}
\label{eqn:T_c_decaying_alpha_ell}
	T_c(\alpha_1, \alpha_2, \ldots) &=
	\frac{4 \pi}
		{\left(\sum_{\ell \ge 1} e^{-\alpha_\ell}\ell^{-3/2}\right)^{2/3}}.
\end{align}
For the non-interacting special case, this is
\begin{align}
\label{eqn:theo_Tc}
	T_c(0) &= \frac{4 \pi}{\zeta(3/2)^{2/3}} \approx 6.625.
\end{align}
%For the two-cycle special case, one has
%\begin{align*}
%	T_c(\alpha) &= \frac{4 \pi}
%		{\left[\zeta(3/2) - 2^{3/2}(1-e^{-\alpha}) \right]^{2/3}}.
%\end{align*}
The Ewens-cycle-weight case does not satisfy the decaying-cycle-weight
constraint where the $\alpha_\ell$'s must go to zero in $\ell$ faster than
$1/\log(\ell)$; all the $\alpha_\ell$'s are the same.  Nonetheless, using
equation \eqref{eqn:T_c_decaying_alpha_ell}, we obtain
\begin{align*}
	T_c(\alpha) &= \frac{4 \pi}
		{\left[e^{-\alpha} \zeta(3/2)\right]^{2/3}}
		\approx 6.625 e^{2\alpha/3}.
\end{align*}
Taylor-expanding in the small parameter $\alpha$, the shift in critical
temperature is then
\begin{equation}
\label{eqn:rho_c}
	\Delta T_c(\alpha)
	= \frac{T_c(\alpha)-T_c(0)}{T_c(0)}
	= e^{2\alpha/3} - 1 \approx \frac{2\alpha}{3} 
	\qand
	c \approx 0.667.
\end{equation}
(Note that this is not in conflict with the constant $c$ in section
\ref{sec:context}, which through abuse of notation we also called $c$.  There,
one examines $\Delta T_c(a)$ where $a$ is the scattering length of the
interacting Bose gas; here, one has $\Delta T_c(\alpha)$ for free parameter
$\alpha$.)

As the primary goal of this dissertation, we inquire whether this result,
obtained for decaying cycle weights with point positions varying on the
continuum, holds for Ewens weights with point positions held fixed on the
lattice.  We suspect that the fine details of point positions are unimportant
for the shift in critical temperature.  For Ewens interactions, though, $\Delta
T_c(\alpha)$ is theoretically unknown for Ewens interactions with points either
on the continuum or on the lattice.  The simulational treatment in this
dissertation is the only known attack on this question.

Secondarily, we conjecture that $\bbE[\ellmax] / N f_I$, as discussed in
section \ref{sec:known_results}, is $\alpha$-dependent but constant in $T$ (for
$T$ below but near $T_c$) for our model of lattice point positions and Ewens
cycle weights.

%% ================================================================
\chapter{Random variables}
\label{chap:RV_theory}

Given the definition of the probability model from chapter
\ref{chap:model_defns}, the next logical step is to define random variables.
In particular, we seek \emphidx{order parameters} --- random variables which
allow us to identify the phase transition to long cycles.  Specific random
variables used in this dissertation are as follows.  For each, the relevant
theory sections (in this chapter) and experiment sections (in chapter
\ref{chap:sw}) are pointed to.

\begin{itemize}

\item System energy and energy density:  these are as discussed in section
\ref{sec:prb_model}; explicit computation is discussed in section
\ref{sec:comput_HDV}.

\item The number of $\ell$-cycles in the permutation for $\ell=1, 2, \ldots,
N$:  the definitions are familiar from elementary algebra; computation is
discussed in section \ref{sec:comput_rell}.

\item Cycle length, spatial cycle length, and correlation length:  sections
\ref{sec:theory_cyclen_corrlen} and \ref{sec:comput_cyclen_corrlen}.

\item Mean jump length and maximum jump length: sections \ref{sec:theory_mjl}
and \ref{sec:comput_mjl}.  These are used to confirm the hypothesis of short
jump lengths\index{short-jump-length regime} as mentioned in section
\ref{sec:theory_wno}.

\item Fraction of sites in cycles of specified lengths, and fraction of sites in
long cycles: section \ref{sec:theory_fI} and (theory) and \ref{sec:comput_fI}
(experiment).

\item Longest cycle length macroscopic-cycle quotient:  sections
\ref{sec:theory_lmax_GRU_quot} and \ref{sec:comput_lmax_GRU_quot}.

\item Winding numbers scaled winding number, and fraction of sites in winding
cycles:  sections \ref{sec:theory_wno} and \ref{sec:comput_wno}.

\end{itemize}

A word on notation: given a random variable $X$, let $Q = \bbE[X]$.  For each
quantity $Q$, one should distinguish between the\index{finite volume}
finite-volume value $Q_L(T)$ and the \plainidx{infinite-volume limit}
$Q_\infty(T) = \lim_{L\to\infty} Q_L(T)$.  For this chapter, omitted subscripts
are disambiguated by context.  The difference becomes significant in chapter
\ref{chap:sw}; at that point, I will carefully distinguish between $Q_L(T)$ and
$Q_\infty(T)$.

%% ----------------------------------------------------------------
\section{Differences and distances on the torus}
\label{sec:torus_diff_and_dist}

We first define the natural difference-vectors and distances on the 3-torus.
Namely, for $\vecz \in \Lambda$, we define a \plainidx{zero-centered modulus}
vector $\vecm_L(\vecz)$.  For $\vecx,\vecy\in\Lambda$, this gives rise to a
\plainidx{difference vector} $\torusdiff(\vecx,\vecy)$ and a
\plainidx{distance} $\|\vecx-\vecy\|_\Lambda$.  The former are needed for
winding numbers (section \ref{sec:theory_wno}); the latter are needed for the
Hamiltonian (section \ref{sec:prb_model}), spatial cycle length and correlation
length (section \ref{sec:theory_cyclen_corrlen}), and jump length (section
\ref{sec:theory_mjl}).  Specifically, we have the following:
\begin{align}
\label{eqn:vecm_L}
	\vecm_L(\vecz) &= \colvecthree{m_L(z_1)}{m_L(z_2)}{m_L(z_3)} \\
\label{eqn:n_L}
	n_L(z) &= n \in \Z \textrm{ which minimizes } |z+nL| \\
\label{eqn:m_L}
	m_L(z) &= z + n_L(z) L \\
\label{eqn:torusdiff}
	\torusdiff(\vecx,\vecy) &= \vecm_\Lambda(\vecx-\vecy) \\
\label{eqn:torusdist}
	\|\vecz\|_\Lambda &= \|\vecm_\Lambda(\vecz)\|.
\end{align}
For example, suppose $L=20$, $\vecx=(0,0,18)$, and $\vecy=(0,0,1)$.  Then
$\torusdiff(\vecx,\vecy) = (0,0,-3)$ and $\|\vecx-\vecy\|_\Lambda = 3$.  This
is called a zero-centered modulus since $m_L(z)$ takes values from $-L/2$ to
$L/2$.  There is an \plainidx{antipodal  problem} when $L$ is even:  the
distance is well-defined on the torus, but differences are not always.  For
example, if $L=20$, $\vecx=(0,0,18)$, and $\vecy=(0,0,8)$, then
$\|\vecx-\vecy\|_\Lambda=10$ but $\torusdiff(\vecx,\vecy) = (0,0,10)$ or
$(0,0,-10)$.  However, as mentioned in sections \ref{sec:qual_long_cycles},
\ref{sec:theory_wno}, \ref{sec:acceptance_rate}, and \ref{sec:comput_mjl}, we
work in the \plainidx{short-jump-length regime}.  Specifically, in section
\ref{sec:comput_mjl} we find that for $T$ near $T_c$, jump length remains below
5, with probability very near 1, regardless of how big $L$ is.

We now show that equation \eqref{eqn:torusdist} is compatible with the
definition of $\|\cdot\|_\Lambda$ from equation
\eqref{eqn:prb_model_torus_diff} on page \pageref{eqn:prb_model_torus_diff}.
namely,
\begin{align*}
	\|\vecx - \vecy\|_\Lambda &=
		\min_{\vecn\in \Z^3} \{\|\vecx - \vecy + L \vecn\|\}.
\end{align*}

\begin{prop}
We have
\begin{align}
	\|\vecx - \vecy\|_\Lambda &= \|\torusdiff(\vecx,\vecy)\|.
\end{align}
\begin{proof}
For brevity, let $\vecz=\vecx-\vecy$.  Since the square-root function is
one-to-one and increasing on non-negative reals, it suffices to show
\begin{align*}
	\|\vecm_\Lambda(\vecz)\|^2 &= \min_{\vecn\in\Z^3} \{\|\vecz+\vecn L\|^2\}.
\end{align*}
Starting with the right-hand side, we have
\begin{align*}
	\min_{\vecn\in\Z^3} \{ \|\vecz+\vecn L\|^2 \}
	&=
		\min_{n_1 \in \Z}
		\min_{n_2 \in \Z}
		\min_{n_3 \in \Z}
		\left\{ (z_1 + n_1 L)^2 + (z_2 + n_2 L)^2 + (z_3 + n_3 L)^2 \right\} \\
	&=
		\min_{n_1 \in \Z} \left\{ (z_1 + n_1 L)^2 \right\} +
		\min_{n_2 \in \Z} \left\{ (z_2 + n_2 L)^2 \right\} +
		\min_{n_3 \in \Z} \left\{ (z_3 + n_3 L)^2 \right\} \\
	&= m_L(z_1)^2 + m_L(z_2)^2 + m_L(z_3)^2 \\
	&= \|\vecm_\Lambda(\vecz)\|^2.
\end{align*}
\end{proof}
\end{prop}

%% ----------------------------------------------------------------
\section{Cycle lengths and correlation length $\xi$}
\label{sec:theory_cyclen_corrlen}

\begin{defn}
\label{def:ell}
Fixing\index{$\ell$}\index{$s$} $\pi\in\SN$ and $\vecx \in \Lambda$, the
\plainidx{cycle length} $\ellxpi$ is the smallest positive integer $a$ such that
$\pi^a(\vecx) = \vecx$.  This is nothing more than the length of the cycle
containing $\vecx$: if $\vecx$ is in a 3-cycle, then $\ellxpi = 3$.  We define
the \plainidx{spatial cycle length}
$$
	\essx(\pi) = \sum_{j=1}^{\ellxpi} \|\pi^j(\vecx)-\pi^{j-1}(\vecx)\|_\Lambda.
$$
This is simply the sum of Euclidean jump distances for all permutation jumps in
the cycle containing $\vecx$.  We may at times instead write, respectively,
$$
	\ell_i(\pi) = \ell_{\vecx_i}(\pi)
	\qqor
	s_i(\pi) = s_{\vecx_i}(\pi).
$$
\end{defn}

For example, for the point configuration $\vecX$ and the permutation $\pi$
in figure \ref{fig:pi8}, we have
$$
	\ell_1(\pi) =
	\ell_2(\pi) =
	\ell_3(\pi) =
	\ell_4(\pi) = 4,
	\quad
	\ell_5(\pi) =
	\ell_6(\pi) =
	\ell_7(\pi) = 3,
	\qand
	\ell_8(\pi) = 1.
$$

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics{figures/pi8.eps}
\caption{A configuration of $\vecX$ and $\pi$ with $N=8$.
	\label{fig:pi8}}
\end{center}
\end{figure}

\begin{defn}
\label{def:ellxy}
If $\vecx$ and $\vecy$ are in a \plainidx{common cycle} of $\pi$, we say that
$\vecx$ is \plainidx{connected to} $\vecy$; otherwise we say that $\vecx$ is
not connected to $\vecy$.  These are
written\index{$\ctdto$}\index{$\vecx\ctdto\vecy$}
$$
	\vecx \ctdto \vecy \qqand
	\vecx \notctdto \vecy.
$$
In the former case, we write
$$
	\ellxypi
$$
for the smallest positive integer $a$ such that $\pi^a(\vecx) = \vecy$.  This
is the number of permutation jumps from $\vecx$ to $\vecy$.
\end{defn}

\begin{defn}
We may average cycle lengths and spatial cycle lengths (definition
\ref{def:ell}) over all points $\vecx$:
\begin{align*}
	\ellbar(\pi) &=
		\frac{1}{N} \sum_{\vecx \in \Lambda} \ellx(\pi) &
	\essbar(\pi) &=
		\frac{1}{N} \sum_{\vecx \in \Lambda} \essx(\pi).
\end{align*}
\end{defn}

Now, $\bbE[\ellx] = \bbE[\elly]$ for all $\vecx,\vecy\in\Lambda$, and both are
the same as $\bbE[\ellbar]$ as shown in the lemma below.  Experimentally,
however, as discussed at the beginning of chapter \ref{chap:MCMC}, we cannot
compute expectations over all $\pi\in\SN$.  We must content ourselves with
sample means over some sequence of $M$ permutations $\pi_1$, $\ldots$, $\pi_M$,
obtained in an MCMC simulation.  We may increase the sample size by a factor
$N$ (thereby decreasing the sample variance by a factor of $N$, by the central
limit theorem) if we average over all points $\vecx$.  For each permutation, we
may compute $\ellbar(\pi)$ by averaging $\ellx(\pi)$ over all $N$ point
positions, and likewise for $\essx(\pi)$ and $\essbar$.

\begin{lem}
For all $\vecx \in \Lambda$, $\bbE[\ellbar] = \bbE[\ellx]$.
\begin{proof}
The left-hand side is
\begin{align*}
	\bbE[\ellbar] &= \sum_{\pi\in\SN} P(\pi) \ellbar(\pi).
\end{align*}
Since both sums are finite, we have
\begin{equation}
\label{eqn:ellbar_sums_commute}
\begin{aligned}
	\bbE[\ellbar]
	&= \sum_{\pi\in\SN} P(\pi) \ellbar(\pi)
	= \sum_{\pi\in\SN}
		P(\pi)
		\frac{1}{N}
		\sum_{\vecx \in \Lambda}
		\ellx(\pi) \\
	&=
		\frac{1}{N}
		\sum_{\vecx \in \Lambda}
		\sum_{\pi\in\SN}
		P(\pi)
		\ellx(\pi)
	= \overline{\bbE[\ellx]}.
\end{aligned}
\end{equation}
The equality $\overline{\bbE[\ellx]} = \bbE[\ellx]$ follows from translation
invariance on the 3-torus.
\end{proof}
\end{lem}

In summary, we have
\begin{align*}
	\ellxpi &= \min\{a > 0: \pi^a(\vecx) = \vecx\} &
	\essxpi &= \sum_{j=1}^{\ellxpi} \|\pi^j(\vecx)-\pi^{j-1}(\vecx)\|_\Lambda \\
%
	\bbE[\ellx] &= \sum_{\pi\in\SN} P(\pi) \ellx(\pi) &
	\bbE[\essx] &= \sum_{\pi\in\SN} P(\pi) \essx(\pi) \\
%
	\ellbar(\pi) &= \frac{1}{N} \sum_{\vecx\in\Lambda} \ellx(\pi) &
	\essbar(\pi) &= \frac{1}{N} \sum_{\vecx\in\Lambda} \essx(\pi) \\
%
	\bbE[\ellbar] &= \sum_{\pi\in\SN} P(\pi) \ellbar(\pi) &
	\bbE[\essbar] &= \sum_{\pi\in\SN} P(\pi) \essbar(\pi).
\end{align*}
The quantities on the second line are convenient for theoretical use; the
quantities on the fourth line (due to the larger sample size) are preferable
for experimental use.

We define\index{$\xi$} a \plainidx{correlation length} $\xi$ to be
\begin{align}
	\xi &= \bbE[\essbar].
\end{align}
Computational details are in section \ref{sec:comput_cyclen_corrlen}.

%% ----------------------------------------------------------------
\section{Mean and maximum jump length}
\label{sec:theory_mjl}

\begin{defn}
Let\index{$j$}\index{$j_\vecx$}
\begin{align*}
	j_\vecx(\pi) &= \|\pi(\vecx)-\vecx\|_\Lambda
\end{align*}
be the length of the permutation jump starting at site $\vecx$; let
\begin{align*}
	j(\pi) &= \frac{1}{N} \sum_{i=1}^N j_{\vecx_i}(\pi).
\end{align*}
The \plainidx{mean jump length} at site $\vecx$ is simply
\begin{align*}
	\bbE[j_\vecx] &= \sum_{\pi\in\SN} P(\pi) \|\pi(\vecx)-\vecx\|_\Lambda.
\end{align*}
\end{defn}
By linearity of expectation, this is the same as the average over
all sites:
\begin{align*}
	\bbE[j(\pi)] &= \bbE[j_{\vecx_1}(\pi)].
\end{align*}
As was the case for $\ellbar$ and $\essbar$ in section
\ref{sec:theory_cyclen_corrlen}, we approximate the uncomputably large sum over
all $N!$ permutations by a random sequence of $M$ permutations, and the sample
mean is random.  By the central-limit theorem argument in section
\ref{sec:theory_cyclen_corrlen}, the variance of the sample mean of $j$ is a
factor of $N$ smaller than the variance of the sample mean of $j_\vecx$, since
the sample size is $MN$ instead of $M$.  Additional computational details
are discussed in section \ref{sec:comput_mjl}.

%% ----------------------------------------------------------------
\section{Fraction of sites in infinite cycles $f_I$}
\label{sec:theory_fI}

If\index{$f_I$} one wants to quantify the temperature-dependent onset of long
cycles (section \ref{sec:qual_long_cycles}), then one can define a random
variable which counts the fraction of sites in long cycles.  In the infinite
limit, one looks for infinite cycles.  One could define
\begin{align}
\label{eqn:f_I_infty}
	f_I(\infty) &= 1 - \sum_{k \ge 1} P(\ell_0 = k)
\end{align}
where $\ell_0(\pi)$ is as defined in section \ref{sec:theory_cyclen_corrlen}.
For finite volume, where simulations are done, the right-hand side of
\eqref{eqn:f_I_infty} is always 0:  every site is in a cycle of some finite
length.  One might then define
\begin{align}
\label{eqn:f_I_N}
	f_I(N) &= 1 - \sum_{k < \veps(N)} P(\ell_0 = k)
\end{align}
where $\veps(N)$ is such that $\veps(N) \to \infty$ as $N \to \infty$ but
$\veps(N)/N \to 0$.  For example, one may take $\veps(N) = \sqrt{N}$.  This is
chosen so that as $N\to\infty$, one obtains $f_I(\infty)$.  In \cite{bib:bu07}
it is found, among other results, that mesoscopic cycles are unimportant:  for
$T>T_c$, there are only microscopic cycles; for $T<T_c$, there are only
microscopic and macroscopic cycles.  The $\veps(N)$ cutoff is designed to
separate the former from the latter.

For practical computation, \cite{bib:gru} begin by defining
$$
	\rho = \frac{N}{V},
$$
where $V=L^3$ is the volume, i.e. $\rho$ is the \plainidx{particle density}.
For $1 \le m \le n \le N$, define
$$
	\varrho_{m,n}(\pi)
	= \frac{1}{V} \;
	\# \left\{ i=1, \ldots, N: m \le \ell_i(\pi) \le n \right\}
$$
This random variable, taking values between 0 and $\rho$, is the
\plainidx{density of sites} in cycles of specified length.  One may also
consider the related random variable
$$
	f_{m,n}(\pi)
	= \frac{1}{N} \;
	\# \left\{ i=1, \ldots, N: m \le \ell_i(\pi) \le n \right\}
$$
which is $\varrho_{m,n}/\rho$.  (Of course, on the unit lattice where $N=L^3$
and $\rho=1$, the two random variables $f_{m,n}(\pi)$ and $\varrho_{m,n}(\pi)$
are identical.)  This runs from 0 to 1 and is the \plainidx{fraction of sites}
in cycles of specified length.  For figure \ref{fig:pi8} on page
\pageref{fig:pi8}, we have $f_{2,3}(\pi) = 3/8$.  Then $\bbE[f_{\veps(N), N}]$
matches equation \eqref{eqn:f_I_N} as follows:
\begin{align*}
	\bbE[f_{\veps(N),N}(\pi)] &= \frac{1}{N}
		\bbE\left[ \#\{i=1, \ldots, N : \ell_i(\pi) \ge \veps(N)\} \right] \\
	&= \frac{1}{N} \bbE\left[
		\sum_{i=1}^N 1_{\ell_i(\pi) \ge \veps(N)}(\pi)\} \right]
	= \frac{1}{N} P(\ell_i(\pi) \ge \veps(N)).
\end{align*}
This is the same as $P(\ell_0(\pi) \ge \veps(N))$ by translation invariance.
Then
\begin{align*}
	P(\ell_0(\pi) \ge \veps(N))
	&= \sum_{k \ge \veps(N)} P(\ell_0=k)
	= 1 - \sum_{k<\veps(N)} P(\ell_0=k) = f_I(N).
\end{align*}

In practice, a single cutoff of the form $\veps(N)$ is not used; one estimates
the infinite-limit behavior in a different way.  To see how to do this, we next
invoke results of \cite{bib:suto2} and \cite{bib:buv09} regarding the behavior
of $\bbE[f_{1,k}]$ as a function of $k/N$ in the infinite limit.  The former,
\cite{bib:suto2}, applies in the non-interacting case; the latter,
\cite{bib:buv09}, applies in the Ewens case but with non-spatial permutations,
which are equivalent to random spatial permutations with $T=0$.  For the
non-interacting case, $\bbE[f_{1,k}]$ is a straight line of slope 1 as shown in
the upper left of figure \ref{fig:f_I_why}.  At $T=0$, it fills the full
diagonal; cycle lengths have uniform distribution.  At $T>T_c$, the diagonal
vanishes into the upper-left corner; there are no long cycles.  The transition
to criticality occurs at $T$ such that the diagonal becomes visible.  See also
\cite{bib:lugo}.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics{figures/f_I_why.eps}
\caption[Expectation of $f_{1,k}$ as a function of $k/N$.]
	{Qualitative behavior of $\lim_{N\to\infty} \bbE[f_{1,k}]$ as a function of
	$k/N$ in the non-interacting (upper left) and non-spatial large-$\alpha$
	Ewens-interacting (upper right) cases.  Lower left and lower right show the
	behavior for finite $N$.
	\label{fig:f_I_why}}
\end{center}
\end{figure}

In finite volume, $\bbE[f_{1,k}]$ is rounded as shown in the bottom left of
figure \ref{fig:f_I_why}.  Thus, one wishes to draw a tangent-line
approximation for the infinite-volume behavior, and take $f_I$ to be one minus
the vertical intercept.  This avoids use of a specific, arbitrary cutoff
$\veps(N)$, replacing it instead with a graphical estimator which makes use of
all available data.  See also section \ref{sec:comput_fI} for computational
details, including the handling of sampling variability.

For Ewens interactions, the diagonals are curved as shown in the upper right of
figure \ref{fig:f_I_why}.  For the small $\alpha$ values considered in this
dissertation, however, this Betz-Ueltschi-Velenik sag in the curve is less than
the sampling variability in the data itself (see the plots in section
\ref{sec:comput_fI}).  Thus, the sag is not relevant to our discussion.  It
should also be remarked that the author has performed larger-$\alpha$
simulations for which the $\bbE[f_{1,k}]$ sag is indeed observed
simulationally.

%% ----------------------------------------------------------------
\section{Macroscopic-cycle quotient $\fM/f_I$}
\label{sec:theory_lmax_GRU_quot}

\begin{defn}
For\index{$\ellmax$} a permutation $\pi$ in $\SN$, define
\begin{align}
	\ellmax(\pi) &= \max_{1 \le i \le N} \ell_i(\pi).
\end{align}
For a spatial permutation, this is precisely the same as
\begin{align}
	\ellmax(\pi) &= \max_{\vecx \in \Lambda} \ell_\vecx(\pi).
\end{align}
We write\index{$\ellmax$}
We write\index{$\fM$}
\begin{align}
	\fM &= \bbE[\ellmax]/N.
\end{align}
\end{defn}

\begin{defn}
The \emphidx{macroscopic cycle quotient}, written $\fM/f_I$ for brevity,
is given by
\begin{align}
	\textrm{macroscopic cycle quotient}
	&= \begin{cases}
		\frac{\bbE[\ellmax]}{N f_I}, &\quad f_I \ne 0 \\
		0,                           &\quad f_I  =  0.
	\end{cases}
\end{align}
\end{defn}
Intuition was discussed in sections \ref{sec:known_results} and \ref{sec:conj};
computational details are discussed in section \ref{sec:comput_lmax_GRU_quot}.

% %% ----------------------------------------------------------------
% \section{Existence of infinite cycles}
% \label{sec:inf_cyc_existence}
%
% Here\index{infinite cycles} we describe theorem 1 of \cite{bib:qmath}, which
% is proved in section 1 of \cite{bib:bu07}.  This applies to the $U\equiv 0$
% case.
%
% %Here we describe theorem 1 of \cite{bib:qmath}, deferring [yyy?] a sketch
% %of the proof to section [yyy].
%
% \textbf{Thermodynamic limit:}  We\index{thermodynamic limit} inquire about
% the fraction of sites participating in short and long cycles (as quantified
% below) in the \plainidx{infinite-volume limit}.  Namely, we let $V,N \to
% \infty$ with fixed ratio $\rho = N/V$, and we ask about the\index{density}
% cycle-length distribution as a function of $\rho$.
%
% One does not need to construct an infinite-volume model, although this is
% done in section 3, for pure interest:  We will examine limits of expectations
% of random variables, where the limit is taken as the number of points $N$ of
% the model goes to infinity.  The limits then are in $\R$.
%
% \textbf{Critical density:}
% We define the \plainidx{critical density}, $\rhocz$, by the following
% formula.  Here, this is simply an \plainidx{ansatz}.
% \begin{equation}
% \label{eqn:ideal_rho_c}
% 	\rhocz = \int_{\R^d} \frac{d\veck}{e^{4\beta\pi^2\|\veck\|^2}-1}.
% \end{equation}
%
% \begin{rem}
% One may compute
% \begin{align}
% \label{eqn:ideal_rho_c_zeta}
% 	\rhocz &= \int_{\R^d} \frac{d\veck}{e^{4\beta\pi^2\|\veck\|^2}-1}
% 	= \frac{\zeta(3/2)}{(4\pi\beta)^{3/2}}
% \end{align}
% where $\zeta(z)$ is the \plainidx{Riemann zeta function}.
% \end{rem}
%
% % yyy Note that $\exp(-4\beta\pi^2|\veck|^2)$ is the \plainidx{Fourier %
% transform} of $\exp(\beta|\vecx|^2/4)$.
%
% % yyy wik bec article:
% % N = V int d3k/(2pi)^3 p(k)/(1-p(k))
% %   = V int d3k/(2pi)^3 1 / (exp(k^2/2mT) - 1)
% % w/ p(k) = exp(-k^2/2mT).
% % "maximum number of excited particles p/(1-p)".
%
% \textbf{Statement of the theorem:}
% For any $0<a<b<1$ (nominally, $a$ is just above 0 and $b$ is just below 1)
% and any $s \ge 0$,
% \begin{equation}
% \label{eqn:thm_1_rho}
% \begin{aligned}
% %
% 	\lim_{V \to \infty} \bbE_{\Lambda,N}(\varrho_{1,N^a}) &=
% 		\begin{cases}
% 		\rho,   & \rho \le \rhocz \\
% 		\rhocz, & \rhocz \le \rho
% 		\end{cases} \\
% %
% 	\lim_{V \to \infty} \bbE_{\Lambda,N}(\varrho_{N^a,N^b}) &=
% 		0 \\
% %
% 	\lim_{V \to \infty} \bbE_{\Lambda,N}(\varrho_{N^b,sN}) &=
% 		\begin{cases}
% 		0,           & \rho \le \rhocz \\
% 		\rho-\rhocz, & \rhocz \le \rho \le s+\rhocz \\
% 		s,           & s+\rhocz \le \rho.
% 		\end{cases}
% \end{aligned}
% \end{equation}
% (See figure \ref{fig:limErho}.)
%
% \begin{figure}[!htb]
% \begin{center}
% \psfragscanon
% \includegraphics{figures/limErho.eps}
% \caption[Distribution of cycle lengths as function of density.]
% 	{Distribution of cycle lengths as function of density in the
% 	infinite-volume limit.
% 	\label{fig:limErho}}
% \end{center}
% \end{figure}
%
% This statement, in terms of the density of sites in cycles of specified
% lengths, may be more intuitively rephrased in terms of the fraction of sites
% in
% cycles of specified length:
% \begin{align*}
% %
% 	\lim_{V \to \infty} \bbE_{\Lambda,N}(f_{1,N^a}) &=
% 		\begin{cases}
% 		1,   & \rho \le \rhocz\\
% 		\rhocz/\rho, & \rhocz \le \rho
% 		\end{cases} \\
% %
% 	\lim_{V \to \infty} \bbE_{\Lambda,N}(f_{N^a,N^b}) &=
% 		0 \\
% %
% 	\lim_{V \to \infty} \bbE_{\Lambda,N}(f_{N^b,sN}) &=
% 		\begin{cases}
% 		0,             & \rho \le \rhocz \\
% 		1-\rhocz/\rho, & \rhocz \le \rho \le s+\rhocz \\
% 		s/\rho,        & s+\rhocz \le \rho.
% 		\end{cases}
% \end{align*}
%
% The theorem has the following interpretation:
% \begin{itemize}
% \item At density below $\rhocz$, all sites are in \plainidx{short cycles} and
% no sites are in \plainidx{long cycles}.
% \item As density increases past $\rhocz$ and $\rhocz+s$, fewer sites are in
% short cycles and more sites are in long cycles.  In particular, a strictly
% positive fraction of sites are in long cycles.
% \item Asymptotically, all sites are in long cycles.
% \end{itemize}

%% ----------------------------------------------------------------
\section{Winding numbers, $f_S$, and $f_W$}
\label{sec:theory_wno}

The box $\Lambda=[0,L]^3$ with \plainidx{periodic boundary conditions} is
topologically equivalent to the 3-\plainidx{torus}.  Permutation cycles wind
around the 3-torus some number of times in the $x$, $y$, and/or $z$ directions.
The sub-$T_c$ onset of long cycles corresponds to the appearance of cycles
which wrap around the torus in one or more of the three axes.  If a cycle goes
around once in the clockwise direction, we want to say it has sign $+1$;
likewise, we want sign $-1$ for the counterclockwise direction.  The following
definition formalizes this intuition.

\begin{defn}
\label{def:wno}
The \emphidx{winding number} (really a 3-tuple of numbers) of a permutation
$\pi$ is
\begin{align}
\label{eqn:def_wno}
	\vecW(\pi) &= (W_x(\pi), W_y(\pi), W_z(\pi))
	= \frac{1}{L} \sum_{i=1}^N \torusdiff(\pi(\vecx_i), \vecx_i)
\end{align}
where $\torusdiff$ is as defined in equation \eqref{eqn:torusdiff}.  This
simply counts the integer number of wraps of $\pi$'s cycles around the 3-torus
in each of the three directions.  We also write
\begin{align}
\label{eqn:def_W2}
	\vecW^2(\pi) &= \vecW(\pi) \cdot \vecW(\pi)
	= W_x(\pi)^2 + W_y(\pi)^2 + W_z(\pi)^2.
\end{align}
\end{defn}

%(See also table \ref{table:jump_len_distro} on page
%\pageref{table:jump_len_distro}.)

\begin{defn}
The\index{$f_S$} \emphidx{scaled winding number} is
\begin{align*}
	f_S &= \frac{\bbE[\vecW^2] L^2}{3 \beta N}
	= \frac{\bbE[\vecW^2] T}{3 L}.
\end{align*}
See \cite{bib:pc87} for the physical derivation.  For us, it simply needs to be
scaled by $L^2/N = 1/L$ in order to be an intensive parameter.
\end{defn}

\begin{defn}
Let $c_\vecx(\pi)$ consist of all sites in the same cycle as $\vecx$:
\begin{align*}
	c_\vecx(\pi) &= \{\vecy \in \Lambda:
		\vecy = \pi^a(\vecx), a = 0, 1, 2, \ldots, N-1\}.
\end{align*}
Let $\vecw_\vecx(\pi)$ be the \emphidx{winding vector} for $\vecx$ (which is
clearly the same for all sites in the same cycle as $\vecx$):
\begin{align*}
	\vecw_\vecx(\pi) &=
	\frac{1}{L} \sum_{\vecy \in c_\vecx(\pi)} \torusdiff(\pi(\vecy), \vecy),
\end{align*}
where the difference vectors are again interpreted as in section
\ref{sec:torus_diff_and_dist}.  Note that all three slots of $\vecw_\vecx(\pi)$
are necessarily integer-valued.  We say that $\pi$ \emphidx{winds through}
$\vecx$ if $\vecx$ has a non-zero winding vector:
\begin{align*}
	t_\vecx(\pi) &= \begin{cases}
		1, &\quad \vecw_\vecx(\pi) \ne (0,0,0); \\
		0, &\quad \vecw_\vecx(\pi)  =  (0,0,0).
	\end{cases}
\end{align*}
We use these to define the \emphidx{fraction of sites in winding cycles}:
\begin{align*}
	f_W(\pi) &= \bbE\left[
		\frac{1}{N} \sum_{\vecx \in \Lambda} t_\vecx(\pi)
	\right].
\end{align*}
Computational details are discussed in section \ref{sec:comput_wno}.
\end{defn}

%% ----------------------------------------------------------------
\section{Order parameters: quantifying long cycles}
\label{sec:ordps}

Of the random variables presented in this chapter, the following, referred to
as \emphidx{order parameters}, may be used to locate the critical temperature
$T_c(\alpha)$ below which long cycles begin to appear.  The first four are
non-zero for $T<T_c$ and zero for $T>T_c$.  Since $\xi$ blows up below $T_c$,
$1/\xi$ goes to zero below $T_c$.  See also figure
\ref{fig:intuit_order_params}.
\begin{itemize}
\item Reciprocal correlation length $1/\xi$.
\item $\fM := \bbE[\ellmax]/N$.
\item Fraction of sites in long (``infinite'') cycles $f_I$.
\item Scaled winding number $f_S$.
\item Fraction $f_W$ of sites in cycles which wind.
\end{itemize}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_overview_alpha0_0.000_recip_xi.eps}

\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_overview_alpha0_0.000_fmax.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_overview_alpha0_0.000_fI.eps}

\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_overview_alpha0_0.000_fS.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_overview_alpha0_0.000_fW.eps}

\caption[Behavior of order parameters as functions of $L$ and $T$.]
	{Behavior of order parameters as functions of $L$ and $T$, for the
	non-interacting model.  Each of the following occurs at a critical
	temperature $T_c$, in the limit $L \to \infty$:
	%
	blow-up of correlation length (vanishing of $1/\xi$),
	%
	onset of $N$-scaling of the length of the longest cycle ($\fM$),
	%
	onset of long cycles ($f_I$),
	%
	and onset of winding cycles ($f_S$ and $f_W$).
	%
	For finite $L$, the transitions are smooth.
	Interactions increase the critical temperature, shifting these graphs to
	the right.
	\label{fig:intuit_order_params}}
\end{center}
\end{figure}

%% ================================================================
\chapter{Markov chain Monte Carlo methods}
\label{chap:MCMC}

In this chapter we discuss the need for random-sampling methods, and justify
their use rigorously.  Given a \plainidx{random variable} $X(\pi)$, such as any
of those presented in chapter \ref{chap:RV_theory}, the
\plainidx{expectation} of $X$ is (equation \eqref{eqn:E_pi})
\begin{align*}
	\bbE[X] &= \sum_{\pi\in\SN} P(\pi) X(\pi).
\end{align*}
This is a real number, with no uncertainty.  The problem is that the number of
permutations, $N!$, grows intractably in $N$:  even for $L=10$ (and we consider
$L$ up to $80$), $N=1000$ and $N!$ is a number with over 5,000 digits.  The
true expectation is effectively incomputable.  Expectations are instead
\emph{estimated}\index{estimator} by summing over some number $M$ (in the
current work, $10^5$ or $10^6$) of typical permutations.  The sample mean
\begin{align}
\label{eqn:pigmX}
	\pigm X &= \frac{1}{M} \sum_{i=1}^M X(\pi_i)
\end{align}
depends on the random sequence $\pi_1, \ldots, \pi_M$.  It is now a random
variable with its own variance.  The two main sources of error in MCMC
simulations are \emphidx{initialization bias} and \emphidx{sampling
variability}.  The former involves \emphidx{thermalization} (section
\ref{sec:thermalization}) and \emph{multimodality of
distributions}\index{multimodal distribution} (sections
\ref{sec:wno_SAR} and \ref{sec:worm_stopping_time}); the latter involves
\emphidx{autocorrelation} (section \ref{sec:comput_tauint} and appendix
\ref{appx:eta}).

To create such a sequence of system states (for us, permutations), the method
used throughout the computational physics community
\cite{bib:berg,bib:landaubinder} is Markov chain Monte Carlo.  Namely, given a
permutation $\pi_i$, one selects a successor permutation $\pi_{i+1}$ in some
random way.  This is the Monte Carlo part.  Moreover, the transition
probabilities from $\pi_i$ to each candidate $\pi_{i+1}$ depend only on
$\pi_i$, and not on any previous choices.  This is the Markov chain part.

In the next sections we show (1) we can construct \plainidx{Markov chains}
which sample from the \plainidx{Gibbs distribution} $P(\pi)$ (equation
\eqref{eqn:RCM_Gibbs_P}); (2) other distributions (induced by the selection of
initial state) converge to the Gibbs distribution; (3) the sample mean $\pigm
X$ converges almost surely to the true expectation $\bbE[X]$; and (4) the
variance of $\pigm X$ can be estimated, allowing us to place error bars on our
estimates of $\bbE[X]$.  Most of the material in this chapter is familiar: see
\cite{bib:berg,bib:landaubinder,bib:cb,bib:fg,bib:gs} to name only a few.
Results are restated here for self-containment of presentation, and they are
phrased in the language of random permutations for convenience.

%% ----------------------------------------------------------------
\section{Invariant and limiting distributions}
\label{sec:invt}

The only probability distribution for random permutations considered thus far
is the Gibbs distribution of equation \eqref{eqn:RCM_Gibbs_P} on page
\pageref{eqn:RCM_Gibbs_P}.  However, others exist.  If one is asked for a
permutation $\pi$ and one always replies with the identity, then the
distribution of that answer is the singleton measure on the identity.  This is
not the Gibbs measure (unless $\alpha = 0$ and $\beta = 0$).  A third
distribution is the uniform distribution, where each permutation has
probability $1/N!$.  (This is the same as the Gibbs measure only for $\alpha =
0$ and $T=0$.) We will continue to write the Gibbs measure as $P(\pi)$; we will
use Greek letters such as $\lambda(\pi)$ or $\theta(\pi)$ for other
distributions.

\begin{defn}
Let $\Omega$ be a finite set with a sequence of probability measures
$\lambda_1$, $\lambda_2, \lambda_3, \ldots$.  (Since $\Omega$ is finite, the
$\sigma$-fields may be taken to be all of the\index{power set} power set
$2^\Omega$.)  Let $S_1, S_2, S_3, \ldots$ be a random sequence of states where
each $S_i \in \Omega$ is distributed according to $\lambda_i$.  Let $\Lambda_k$
be the \plainidx{joint probability distribution} on $\Omega^k$.  That is, the
$S_i$'s are not necessarily either independent or identically distributed; the
$\lambda_i$'s are the \plainidx{marginals} of $\Lambda_k$ on the $i$th slot.
We say the sequence $S_1, S_2, S_3, \ldots$ is a \emphidx{Markov chain} if, for
all $i=1,2,3,\ldots$ and all $\omega_i \in \Omega$,
\begin{align*}
	\Lambda_{i+1}(S_{i+1}=\omega_{i+1} \mid S_1=\omega_1, \ldots, S_i=\omega_i)
	&=
	\Lambda_{i+1}(S_{i+1}=\omega_{i+1} \mid S_i=\omega_i).
\end{align*}
That is, in a Markov chain, the transition probabilities from the current state
to the next depend only on the current state and not on any deeper history.
Furthermore, if for all $i \ge 1$,
\begin{align*}
	\Lambda_{i+1}(S_{i+1} = \omega_{i+1} \mid S_{i} = \omega_i)
	&=
	\Lambda_{2}(S_2 = \omega_{i+1} \mid S_1 = \omega_i),
\end{align*}
then we say the Markov chain is \emphidx{homogeneous}.  (All Markov chains
considered in this dissertation are homogeneous.  For us, of course, $\Omega$
is $\SN$ and the states $S_i$ are permutations $\pi_i$.) \end{defn}

\begin{defn}
The \emphidx{Markov matrix} associated with a homogeneous $K$-state Markov
chain is
\begin{align*}
	M &= (M_{ij})_{1 \le i,j \le K}
	= \Lambda_2(S_2 = \omega_j \mid S_1 = \omega_i).
\end{align*}
We also write
\begin{align*}
	M(S_2 = \omega_j \mid S_1 = \omega_i)
	&= \Lambda_2(S_2 = \omega_j \mid S_1 = \omega_i).
\end{align*}
For us, of course, $K=N!$.
\end{defn}

Note that a Markov chain is determined by the probability distribution
$\lambda_1$ for its \plainidx{initial state}, along with the Markov transition
matrix $M$.  To see this, use the definition of  \plainidx{conditional
probability} to split the joint distribution into a sequencing of states:
\begin{align*}
	\Lambda_k&(S_1 = \omega_1,S_2 = \omega_2, \ldots, S_k = \omega_k)
	= \Lambda_k(S_1=\omega_1)
	\cdot \Lambda_k(S_2 = \omega_2 \mid S_1 = \omega_1) \\
	&\cdots
	\Lambda_k(S_k = \omega_k \mid S_1 = \omega_1, \cdots, S_{k-1}=\omega_{k-1}) \\
	=& \Lambda_k(S_1=\omega_1)
	\cdot \Lambda_k(S_2 = \omega_2 \mid S_1 = \omega_1)
	\cdots \Lambda_k(S_k = \omega_k \mid S_{k-1}=\omega_{k-1}) \\
	=& \lambda_1(S_1=\omega_1)
	\cdot M(S_2 = \omega_2 \mid S_1 = \omega_1)
	\cdots M(S_k = \omega_k \mid S_{k-1}=\omega_{k-1}).
\end{align*}

\begin{defn}
A probability distribution $\theta(S)$ is \emphidx{invariant} for a Markov
transition matrix $M$ if $\theta = \theta M$, that is, if for all $j=1,
\ldots, K$,
\begin{align*}
	\theta(S_2 = \omega_j) &= \sum_{i=1}^K
		M(S_2 = \omega_j \mid S_1 = \omega_i)
		\theta(S_1 = \omega_i).
\end{align*}
In other words, $\theta$ is invariant for $M$ if $M$-transitions
preserve the distribution $\theta$.  If the distribution of $S_1$ is $\theta$,
then $S_2$ will also be distributed according to $\theta$, and so on.  Such a
sequence of states $S_1, S_2, \ldots$, while not in general independent, is
identically distributed.
\end{defn}

\begin{rem}
A \plainidx{homogeneous chain} is not the same as a \plainidx{stationary
sequence}.  In the former cases, the transition matrix is the same at each time
step; in the latter case, the probability distributions are the same at each
time step.
\end{rem}

\beginex An illustrative example uses \plainidx{die-tipping}.  Recall that an
ordinary six-sided die has pips on opposite faces summing to seven.  There are
six states, which we assume to be uniformly distributed if the die is rolled.
Given that the die has $n$ pips facing up, we may \emph{tip} the die by picking
one of the four sides at uniform random and putting that side up.  E.g. if 1 is
up, then after the tip, 2, 3, 4, or 5 will appear each with probability $1/4$;
1 or 6 will appear with probability $0$.

The \plainidx{transition matrix}, with rows indexing the current state and
columns indicating the successor state, is
\begin{align*}
	M = \prmatrix{
	0   & 1/4 & 1/4 & 1/4 & 1/4 & 0   \\
	1/4 & 0   & 1/4 & 1/4 & 0   & 1/4 \\
	1/4 & 1/4 & 0   & 0   & 1/4 & 1/4 \\
	1/4 & 1/4 & 0   & 0   & 1/4 & 1/4 \\
	1/4 & 0   & 1/4 & 1/4 & 0   & 1/4 \\
	0   & 1/4 & 1/4 & 1/4 & 1/4 & 0
	}.
\end{align*}
Suppose the die is initially set on table with $1$ up, i.e. $\lambda_1$ is the
singleton distribution with $\lambda_1(1)=1$.  Then
\begin{align*}
	\lambda_2 &= \prmatrix{
		0   & 1/4 & 1/4 & 1/4 & 1/4 & 0
	}
\end{align*}
If, instead, the die is initially rolled, then $\lambda_1$ is uniform.  One
computes $\lambda_2$ to be uniform as well.  The 1-up distribution is not
invariant for the die-tipping transition rule, but the die-roll distribution
is.
\mendex

Given a Markov matrix $M$, one may wish to find an invariant distribution
$\theta$.  Going the other way, given a distribution $\theta$, one may wish to
construct a Markov matrix $M$ such that $\theta$ is invariant with respect to
$M$.  The latter is our main goal here:  the distribution of interest is the
Gibbs distribution $P$.  The following theorem is key.  First, we define the
terminology necessary to state it.

\begin{defn}
A Markov chain $(M, \lambda_1)$ on a state space $\Omega$ is
\emphidx{irreducible} if for all $S, S' \in \Omega$ there exists an $n$ such
that $M^n(S,S') > 0$.
\end{defn}

\begin{defn}
\label{defn:period}
In a Markov chain $(M,\lambda_1)$ on a state space $\Omega$, a state
$\omega\in\Omega$ has \emphidx{period} $p$ if any return to $S$ must occur at
multiples of $p$ steps.  A state is \emphidx{aperiodic} if $p=1$.  Precisely,
\begin{align*}
	p = \gcd\{n : \lambda(S_n = \omega \mid S_0 = \omega) > 0\}.
\end{align*}
Furthermore, the chain is said to be aperiodic if all states are aperiodic.
\end{defn}

\begin{defn}
A Markov matrix $M$ on a state space $\Omega$ (with $\#\Omega=K$) and a
distribution $\theta$ on $\Omega$ are \emphidx{reversible}, or satisfy
\emphidx{detailed balance}, if for all $1 \le i, j \le K$,
\begin{align*}
	M_{ij} \theta(\omega_i) &= M_{ji} \theta(\omega_j).
\end{align*}
\end{defn}

\begin{rem*}
An irreducible, aperiodic chain on a finite state space is sometimes called
\emphidx{ergodic}.
\end{rem*}

\begin{thm}[Invariant-distribution theorem]
\label{thm:irr_aper_DB_invt}
Fix\index{invariant-distribution theorem} a finite set $\Omega$.  Let $M$
be a Markov transition matrix on $\Omega$, as above, and let $\theta$ be a
probability distribution on $\Omega$.  If the Markov chain $(M, \theta)$ is
\plainidx{irreducible}, \plainidx{aperiodic}, and satisfies \plainidx{detailed
balance}, then $\theta$ is invariant\index{invariant distribution} for $M$.
That is, the Markov chain $(M,\theta)$ is invariant.  Furthermore, if the
Markov chain $(M, \lambda_1)$ is irreducible, aperiodic, and satisfies
detailed balance, then for all $S \in \Omega$, $\lambda_n(S) \to \theta(S)$ as
$n \to \infty$.
\begin{rem*}
Some authors call this the \emphidx{ergodic theorem}; yet, others call our
theorem \ref{thm:ergodic_sampling} the ergodic theorem.  It also may be thought
of as a special case of the Perron-Frobenius theorem, applied to the Markov
transition matrix.
\end{rem*}
\begin{proof}
See \cite{bib:lawler}, sections 1.2 and 1.3.
\end{proof}
\end{thm}

We say $\theta$ ($P$ in the context of random permutations) is the
\emphidx{stationary distribution} or \emphidx{invariant distribution} for $M$.
We say that it is also a \emphidx{limiting distribution} for any initial
distribution $\lambda_1$ satisfying the above hypotheses.  Importantly, for
simulations, we need not know \emph{a priori} what a typical permutation looks
like.  We may start always with the identity permutation, i.e. $\lambda_1$ is
the singleton distribution supported on the identity permutation.  We may then
run the Markov chain, producing a sequence of permutations.  As the number of
iterations goes to infinity, the distribution of permutations approaches $P$.

The specific number $M$ of iterations needed for \plainidx{convergence} of
$\lambda_M$ to $P$ is another matter entirely.  The theory exposited by
\cite{bib:lawler}, as noted above, guarantees that a Markov matrix $M$ with $P$
as its invariant distribution has no other invariant distribution:  $M$ has a
single \plainidx{eigenvalue} 1 with \plainidx{eigenvector} $P$.  The rate of
convergence of $\lambda_n$ to $P$ depends on the second-largest eigenvalue for
$M$, which one in general does not know how to compute.  In practice, this
\emphidx{mixing time} (or \emphidx{burn-in time} or \emphidx{thermalization
time}) is estimated using techniques such as those in section
\ref{sec:thermalization}.

The theory above also does not tell us how to construct a Markov matrix $M$
having a desired distribution $P$ as its invariant distribution --- it simply
tells us what we can do once we have constructed such a matrix.  A specific
construction is due to N. \plainidx{Metropolis}
\cite{bib:berg,bib:landaubinder,bib:cb}.  The essence is that if the invariant
probability distribution $P$ is defined as a Gibbs measure via an energy
function $H$ on $\Omega$, then proposed successor states $S_{i+1}$ are
accepted\index{propose}\index{accept}\index{reject} with probability $\min\{1,
e^{-\Delta H}\}$ where $\Delta H$ is the energy difference for the state
change.  In this dissertation, I directly prove that such methods result in
detailed balance.  Thus, the reader is referred to propositions
\ref{prop:SO_DB} and \ref{prop:worm_DB} for details.

%% ----------------------------------------------------------------
\section{The ergodic theorem}
\label{sec:ergodic_sampling_thm}

Here we show that the sample mean $\pigm X$ (equation \eqref{eqn:pigmX} on page
\pageref{eqn:pigmX}) converges to the true mean $\bbE[X]$ (equation
\eqref{eqn:E_pi} on page \pageref{eqn:E_pi}).

\begin{thm}[Ergodic sampling theorem]
\label{thm:ergodic_sampling}
Let\index{ergodic sampling theorem} $X$ be a random variable on the finite
probability space $(\Omega,2^\Omega, \theta)$.  If the stationary Markov chain
$(M,\theta)$ satisfies the hypotheses of theorem \ref{thm:irr_aper_DB_invt},
then
\begin{align*}
	\frac{1}{M} \sum_{i=1}^M X(S_i) &\to \bbE[X]
	\quad\textrm{as}\quad
	M \to \infty.
\end{align*}
\begin{rem*}
Some authors call this this \emphidx{ergodic theorem}; yet, others call our
theorem \ref{thm:irr_aper_DB_invt} the ergodic theorem.
\end{rem*}
\begin{proof}
This follows from theorem \ref{thm:irr_aper_DB_invt} using the central-limit
theorem for identically distributed but non-independent $S_i$'s.
\end{proof}
\end{thm}

%% ----------------------------------------------------------------
\section{Sample means and their variances}
\label{sec:body_tauint}

There is one caveat to replacing the true mean $\bbE[X]$ with the MCMC sample
mean $\pigm X$:  the naive computation of the standard deviation of the sample
mean, which is correct for independent identically distributed states, is a
wildly incorrect underestimate for the standard deviation of the sample mean in
the case of identically distributed but correlated states.  This issue is so
important that appendix \ref{appx:eta} is devoted to it.  The key result of the
appendix is that the standard deviation (error bar) of the sample mean $\pigm
X$ is off by a factor of the square root of the \emphidx{integrated
autocorrelation time}, $\sqrt{\hattauint(X)}$, which is computed as described
in section \ref{sec:estimate_meanvar}.

%% ----------------------------------------------------------------
\section{Simple example: 1D Ising}
\label{sec:1D_Ising_metro}

For an example which is more complex than die-tipping but less complex than
random spatial permutations, consider the 1D $N$-point \plainidx{Ising model}.
Namely, the configuration space is $\Omega=\{\pm 1\}^N$, i.e. $N$ particles
which may be in either an up (filled) or a down (hollow) state:
\begin{center}
\psfragscanon
\includegraphics[scale=1.0]{figures/ising1.eps}
\end{center}
A state is described by
$
	\vecomega = (\omega_1, \ldots, \omega_n).
$
The \plainidx{configuration space} $\Omega$ has $2^N$ possible configurations.
The system is endowed with an \plainidx{energy function}.  For the 1D Ising
model, one has
$$
	H(\vecomega) = \sum_{i=1}^n \sum_{j=1}^n S_{ij} \omega_i \omega_j
		+ \sum_{i=1}^n h_i \omega_i.
$$
where the $S_{ij}$'s are interaction terms (non-interacting, nearest neighbor,
mean-field, etc.) and the $h_i$'s are magnetization terms.  Given a
\plainidx{temperature}-related parameter $\beta$, one sets the (Gibbs)
probability of each configuration to be proportional to $e^{-\beta H}$.

One picks an \plainidx{initial configuration}.  There are three obvious
choices: (1) Start with all spins down, i.e. $\vecomega = (-1, \ldots, -1)$.
(2) Start with all spins up, i.e. $\vecomega = (+1, \ldots, +1)$.  (3) Start
with $\vecomega$ selected from a \plainidx{uniform probability distribution} on
$\Omega$.  Then, one selects a \plainidx{site} $i$ and decides whether to flip
$\omega_i$ to $-\omega_i$.

\begin{center}
\psfragscanon
\includegraphics[scale=1.0]{figures/ising2.eps}
\end{center}

This decision is made using the \plainidx{Metropolis} prescription, namely:
\begin{itemize}
\item One computes the change in energy $\Delta H = H(\vecomega')
	- H(\vecomega)$ which would be obtained if $\vecomega$ were
	sent to $\vecomega'$ by flipping $\omega_i$.
\item One may compute $\Delta H$ by separately computing
	$H(\vecomega')$ and $H(\vecomega)$ and subtracting the two.
	However, since the only change is at the site $i$, one may do some
	ad-hoc algebra to derive an expression for $\Delta H$ which is less
	computationally expensive.
\item One accepts the change with probability $\min\{1, e^{-\Delta H}\}$.
\end{itemize}
This is called a \emphidx{Metropolis step}\index{step}.

Looping through all $n$ sites from $i=1$ to $i=n$, performing a Metropolis step
at each site $i$, is called a \emphidx{Metropolis sweep}\index{sweep}.  If one
realizes a random variable $X(\vecomega)$ at each of $M$ sweeps, averaging $X$
over the $M$ sweeps, one obtains an approximation $\pig{X}_M$ for the
expectation $\bbE[X]$.  One should first run $B$ Metropolis sweeps of the
system, discarding the realizations of the random variable $X$, before running
the $M$ sweeps in which data are accumulated.  The $B$ sweeps are called the
\plainidx{thermalization phase}; the $M$ sweeps are called the
\plainidx{accumulation phase}.

%% ----------------------------------------------------------------
\section{Recipe for MCMC algorithms}
\label{sec:MCMC_recipe}

The naive outline of an MCMC run is simple:
\begin{itemize}
\item Use a Markov chain, discussed at the end of this section,
to generate a sequence $\pi_1, \pi_1, \ldots, \pi_M$ of permutations.
\item For each permutation $\pi_i$, for each random variable $X$ of interest,
remember the value $X_i = X(\pi_i)$.
\item Compute the sample mean $\Xbar = \frac{1}{M}\sum_{i=1}^M X_i$.
Also compute the sample standard deviation, and any other desired
statistics.
\item Display the statistics.
\end{itemize}
Since the initial permutation $\pi_1$ is the identity, the \plainidx{initial
distribution} is the singleton supported at the identity, which is not the
Gibbs distribution $P$.  Furthermore, as a very low-energy state, the identity
is highly non-typical with respect to the \plainidx{Gibbs distribution}
(equation \eqref{eqn:RCM_Gibbs_P}) for the model of spatial permutations.  As
discussed at the end of section \ref{sec:invt}, one runs the chain until it is
\plainidx{thermalized}, i.e. until the Gibbs distribution has been approached.
(The number of steps $\tau$ required for this is random, but it turns out to
fall within a narrow range.) Renumbering $\pi_\tau$ to $\pi_0$, one then
accumulates statistics over the $M$ permutations $\pi_1, \ldots, \pi_M$.  See
section \ref{sec:thermalization} for the thermalization-detection algorithm
used in this dissertation.

Thus the computational recipe is as follows:

\begin{itemize}
\item Start with the initial permutation being the identity permutation.

\item Run the Markov chain, generating a sequence of permutations until
thermalization has been detected.  At that point, call the current permutation
$\pi_0$.

\item Continue generating a sequence $\pi_1, \ldots, \pi_M$ of permutations.
The mechanics of transitioning from $\pi_i$ to $\pi_{i+1}$ comprises a series
of \emph{steps}\index{step}, which collectively form the $i$th \emphidx{sweep}.
Various types of sweep --- swap-only, swap-and-reverse, swaps with band
updates, and worm --- are presented in chapters \ref{chap:SO_SAR},
\ref{chap:band_updates}, and \ref{chap:worm}.

\item For each permutation $\pi_i$, for each random variable $X$ of interest,
remember the value $X_i = X(\pi_i)$.

\item After all $M$ permutations have been generated, compute the sample mean
$\Xbar = \frac{1}{M}\sum_{i=1}^M X_i$.  Also compute the sample standard
deviation and its error bar (using estimated integrated autocorrelation time),
and any other desired statistics, such as histograms.

\item Display the statistics.
\end{itemize}

Given the framework established by previous sections of this chapter, the
recipe to prove correctness of this algorithm reduces to the following: define
a Markov chain, then prove irreducibility, aperiodicity, and detailed balance.
We devote the next chapters to present three Markov chains:  the swap-only
algorithm, the swap-and-reverse algorithms, and the worm algorithm.

%% ================================================================
\chapter{The swap-only and swap-and-reverse algorithms}
\label{chap:SO_SAR}

This chapter (along with chapter \ref{chap:worm}) presents Markov chains for
MCMC sampling of the model of random spatial permutations (chapter
\ref{chap:model_defns}) within the MCMC-recipe framework of chapter
\ref{chap:MCMC}.  The algorithms are proved correct, then compared and
contrasted.  Computational results using the swap-and-reverse algorithm are
given in chapter \ref{chap:results}.

%% ----------------------------------------------------------------
\section{The swap-only algorithm}
\label{sec:SO_algorithm}

The \plainidx{swap-only algorithm} for transitioning from $\pi$ to $\pi'$,
within the context of the recipe in section \ref{sec:MCMC_recipe}, is as
follows.  One sweeps through sites $\vecx$ of the lattice in either sequential
or uniform-random order.  In either case, one obtains a lattice site $\vecx$.
One then does a \emphidx{Metropolis step} at site $\vecx$:
\begin{itemize}

\item Choose a site $\pi(\vecy)$ from among the six nearest
neighbors of $\pi(\vecx)$.

\item Propose to change $\pi$ to the permutation $\pi'$ which
	has $\pi'(\vecz)=\pi(\vecz)$ for all $\vecz \ne \vecx, \vecy$
	but $\pi'(\vecx) = \pi(\vecy)$ and $\pi'(\vecy) = \pi(\vecx)$.
	(See figure \ref{fig:soswap}.)
%		\begin{align*}
%		\pi: &
%		\pcmatrix{
%			\ldots & \vecx      & \ldots & \vecy      & \ldots \\
%			       & \downarrow &        & \downarrow &        \\
%			\ldots & \pi(\vecx) & \ldots & \pi(\vecy) & \ldots \\
%		} &
%		\pi': &
%		\pcmatrix{
%			\ldots & \vecx      & \ldots & \vecy      & \ldots \\
%			       & \downarrow &        & \downarrow &        \\
%			\ldots & \pi(\vecy) & \ldots & \pi(\vecx) & \ldots \\
%		} \\
%		\end{align*}

\item With probability $\min\{1, \edh\}$ where $\Delta H = H(\pi') -
H(\pi)$, accept the change.  (If the change is rejected, set $\pi'=\pi$.)
\end{itemize}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.7]{figures/gkswap.eps}
\caption{Metropolis moves for the swap-only algorithm.
	\label{fig:soswap}}
\end{center}
\end{figure}

\begin{defn}
\label{defn:SO_trivial}
A swap is \emphidx{trivial} if $\vecx = \vecy$.
\end{defn}

%% ----------------------------------------------------------------
\section{Explicit construction of the Markov matrix}
\label{sec:SO_Markov_matrix}

For section \ref{sec:SO_correctness} we will need an explicit construction of
the \plainidx{Markov matrix} corresponding to the swap-only algorithm as
described in section \ref{sec:SO_algorithm}.

The Markov perspective on the algorithm is that, given a probability
distribution $\lambda_i(\pi)$, the distribution for the subsequent permutation
is
\begin{align*}
	\lambda_{i+1}(\pi') &= \sum_{\pi \in \SN} \lambda_{i}(\pi) M(\pi, \pi')
\end{align*}
or, in matrix/vector notation, $\lambda_{i+1} = \lambda_{i} M$.
In this section we precisely describe the matrix $M$; in section
\ref{sec:SO_correctness} we show that $\lambda_i$ approaches the Gibbs
distribution (equation \eqref{eqn:RCM_Gibbs_P}).

The matrix $M$ is $N! \times N!$: rows are indexed by $\pi_1, \ldots,
\pi_{N!}$ and columns are indexed by $\pi'_1, \ldots, \pi'_{N!}$.  Most of the
entries of $M$ are zero:  Metropolis steps change only two permutation
sites whereas most $\pi,\pi'$ differ at more than two sites.

\begin{defn}
For $\pi,\pi'\in\SN$, define
\begin{align*}
	d(\pi,\pi') &= \#\{i=1,2,\ldots,N : \pi(i) \ne \pi'(i)\}.
\end{align*}
\end{defn}

\begin{rem*}
Note that $d(\pi,\pi') \ne 1$ since if two permutations agree on $N-1$
sites, they must agree on the remaining site.
\end{rem*}

\begin{lem}
\label{lem:d_metric}
The function $d(\pi,\pi')$ is a \plainidx{metric} on $\SN$.
\begin{proof}
Symmetry is obvious, as is non-negativity.  For positive definiteness, note
that $d(\pi,\pi')=0$ iff $\pi=\pi'$.  For the triangle inequality, let
$\pi,\pi',\pi'' \in \SN$.  Partition the set $\{1, 2, \ldots, N\}$ into the
four disjoint sets
\begin{align*}
	A &= \{i = 1,2,\ldots,N : \pi(i) =   \pi'(i), \pi'(i) =   \pi''(i)\}, \\
	B &= \{i = 1,2,\ldots,N : \pi(i) =   \pi'(i), \pi'(i) \ne \pi''(i)\}, \\
	C &= \{i = 1,2,\ldots,N : \pi(i) \ne \pi'(i), \pi'(i) =   \pi''(i)\}, \\
	D &= \{i = 1,2,\ldots,N : \pi(i) \ne \pi'(i), \pi'(i) \ne \pi''(i)\}.
\end{align*}
Then $\pi=\pi''$ on all of $A$;
$\pi\ne \pi''$ on all of $B$ and $C$;
and $\pi,\pi''$ may or may not agree on various elements of $D$:
$$
\begin{tabular}{|c||c||c||c|}
\hline $A$ & $B$ & $C$ & $D$ \\
\hline $\pi  = \pi' $ & $\pi  = \pi' $ & $\pi  \ne \pi' $ & $\pi  \ne \pi'$ \\
\hline $\pi' = \pi''$ & $\pi' \ne \pi''$ & $\pi' = \pi''$ & $\pi' \ne \pi''$ \\
\hline $\pi  = \pi''$ & $\pi \ne \pi''$ & $\pi  \ne \pi''$ & Varies \\
\hline
\end{tabular}
$$
That is,
\begin{align*}
	d(\pi, \pi')  &=   \#C + \#D, \\
	d(\pi',\pi'') &=   \#B + \#D, \\
	\#B + \#C &\le d(\pi, \pi'') \le \#B + \#C + \#D.
\end{align*}
Then
\begin{align*}
	d(\pi,\pi'') &\le \#B + \#C + \#D \le \#B + \#C + 2\#D
	= d(\pi,\pi') + d(\pi',\pi'').
\end{align*}
\end{proof}
\end{lem}

\begin{defn}
Lattice sites $\vecx$ and $\vecy$ are \emphidx{nearest-neighbor} if
$\|\vecx-\vecy\|_\Lambda = 1$.
\end{defn}

\begin{defn}
\label{defn:R_pi_and_ctdto}
For $\pi\in\SN$, define
\begin{align*}
	R(\pi) &= \{\pi'\in\SN: d(\pi,\pi')=2 \textrm{ and }
		\|\pi(\vecx)-\pi(\vecy)\|_\Lambda = 1\}
\end{align*}
where the $\vecx$ and $\vecy$ are taken to be the two points at which
$\pi,\pi'$ differ.  Then $R(\pi)$ is the set of permutations $\pi'$ reachable
from $\pi$ on a swap.
We also write\index{$\ctdto$}\index{connected to}\index{$\pi'\ctdto\pi$}
$$
	\pi' \ctdto \pi
$$
if $\pi' \in R(\pi)$ or $\pi'=\pi$.
\end{defn}

The Metropolis steps are then described as follows.  For each $\pi\in\SN$,
\begin{align*}
	M(\pi,\pi') &= \begin{cases}
		C\left(1 \wedge e^{-H(\pi')+H(\pi)}\right),
		& \pi' \in R(\pi), \\
		%
		\displaystyle
		1 - \sum_{\pi'' \in R(\pi)}
		C\left(1 \wedge e^{-H(\pi'')+H(\pi)}\right),
		& \pi=\pi'; \\
		%
		0,
		& \textrm{ otherwise}.
	\end{cases}
\end{align*}

To find out what $C$ is:
\begin{itemize}
\item There are $N$ choices of lattice points $\vecx$.
\item For each $\vecx$, there are 6 choices of $\piy$ which are
nearest neighbors to $\pix$.
\item This double-counts the $3N$ distinct choices of $\pi'$ reachable from
$\pi$ in a single Metropolis step, since choosing $\vecx$ and then $\vecy$
results in the same Metropolis step as choosing $\vecy$ and then $\vecx$.
\end{itemize}

% yyy To do: prove $3N$ distinct.

We require row sums to be 1 for stochastic matrices, so we may take
\begin{align*}
	C &= \frac{1}{3N}.
\end{align*}
This prefactor of $1/3N$ is the same for all non-zero entries of $M$
for swap-only Metropolis.  Then
\begin{align}
\label{eqn:SO_M}
	M(\pi,\pi') &= \begin{cases}
		\frac{1}{3N}\left(1 \wedge e^{-H(\pi')+H(\pi)}\right),
		& \pi' \in R(\pi), \\
		%
		\displaystyle
		1 - \sum_{\pi'' \in R(\pi)}
		C\left(1 \wedge e^{-H(\pi'')+H(\pi)}\right),
		& \pi=\pi'; \\
		%
		0,
		& \textrm{ otherwise}.
	\end{cases}
\end{align}

%% ----------------------------------------------------------------
\section{Correctness of the swap-only algorithm}
\label{sec:SO_correctness}

It is clear that the swap-only algorithm produces a sequence of permutations,
but with what distribution?  From the Markov-chain theory in section
\ref{sec:invt}, we know that if the chain is irreducible, aperiodic,
and satisfies detailed balance, then the chain has the Gibbs distribution
(equation \eqref{eqn:RCM_Gibbs_P}) as its unique invariant distribution.

Also note from Markov-chain theory \cite{bib:lawler} that all states in a
\plainidx{recurrence class} have the same \plainidx{period}.  Thus, if we can
show that the chain is irreducible (i.e. the entire state space is a single
recurrence class), then for aperiodicity of the chain it suffices to show that
a single state (e.g. the identity permutation) has period 1.

\begin{prop}[Irreducibility]
\label{prop:SO_irreducible}
For\index{irreducible} all $\pi,\pi'$, there is an $n$ such that $M^n(\pi,\pi')
> 0$.  That is, any permutation is reachable from any other.
\begin{proof}
Transpositions\index{transpositions}\index{composition of permutations}
generate $\SN$ \cite{bib:df}.  Thus, for all $\pi\in\SN$, there exist
transpositions $\sigma_1$, $\ldots$, $\sigma_m$ such that
%\begin{align*}
$	\pi = \prod_{j=1}^m \sigma_j$.
%\end{align*}
Thus, it suffices to show that given any permutation $\pi$ and any two points
$\vecx$ and $\vecz$, so $\pi: \vecx \mapsto \pi(\vecx)$ and $\pi: \vecz \mapsto
\pi(\vecz)$, we can construct a sequence of swaps sending $\pi$ to $\pi'$ so
that $\pi': \vecx \mapsto \pi(\vecz)$, $\pi': \vecz \mapsto \pi(\vecx)$, and
$\pi'(\vecy) = \pi(\vecy)$ for all $\vecy \ne \vecx,\vecz$.  (If $\pi(\vecx)$
and $\pi(\vecz)$ are nearest-neighbor lattice sites, of course, then a single
swap does the job.)

Define $G_{\veca,\vecb}:\SN\to\SN$ to be the swap operator for nearest-neighbor
lattice sites $\pi(\veca)$ and $\pi(\vecb)$, i.e. $\pi'=G_{\veca,\vecb} \pi$.
Given $\vecx$ and $\vecz$, there is a (non-unique) sequence of lattice sites
$\vecy_0, \vecy_1, \vecy_2, \ldots, \vecy_n$ such that $\vecy_0=\vecx$,
$\vecy_n=\vecz$, and $\|\pi(\vecy_{i+1})-\pi(\vecy_i)\|_\Lambda = 1$ for $i=0,
1, \ldots, n-1$.  (See figure \ref{fig:irrprop}.)  We will construct a sequence
of swaps along this nearest-neighbor path whose end result is to swap the
permutation arrows starting at $\vecx$ and $\vecz$, leaving all other arrows
unchanged.  We first need a lemma about compositions of swaps.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{figures/irrprop.eps}
\caption[Sequence of local swaps resulting in a non-local swap.]
	{A sequence of (nearest-neighbor) swaps which results in a
	non-nearest-neighbor swap.
	\label{fig:irrprop}}
\end{center}
\end{figure}

\begin{notn}
Given $\vecx_1, \ldots, \vecx_N$ and a permutation $\pi$, we may write
$\pi$ as an \emphidx{image map} with the $\vecx_i$'s along the top row and
their images along the bottom row:
\begin{align*}
	\pcmatrix{\vecx_1 & \ldots & \vecx_N \\
	\pi(\vecx_1) & \ldots & \pi(\vecx_N)}
\end{align*}
\end{notn}

\begin{lem}
The composition $G_{\veca,\vecc} \circ G_{\veca,\vecb}$ behaves as follows:
\begin{align*}
	\pi =
	\pcmatrix{
		\ldots &     \veca  &     \vecb &      \vecc & \ldots\\
		\ldots & \pi(\veca) & \pi(\vecb) & \pi(\vecc)& \ldots
	}
	\mapsto
	\pi' =
	\pcmatrix{
		\ldots &     \veca  &     \vecb &      \vecc & \ldots\\
		\ldots & \pi(\vecc) & \pi(\veca) & \pi(\vecb)& \ldots
	}
\end{align*}
\begin{proof}
The first map, $G_{\veca,\vecb}$, does
\begin{align*}
	\pcmatrix{
		\ldots &     \veca  &     \vecb &      \vecc & \ldots\\
		\ldots & \pi(\veca) & \pi(\vecb) & \pi(\vecc)& \ldots
	}
	\mapsto
	\pcmatrix{
		\ldots &     \veca  &     \vecb &      \vecc & \ldots\\
		\ldots & \pi(\vecb) & \pi(\veca) & \pi(\vecc)& \ldots
	};
\end{align*}
$G_{\veca,\vecc}$ sends this to
\begin{align*}
	\pcmatrix{
		\ldots &     \veca  &     \vecb &      \vecc & \ldots\\
		\ldots & \pi(\vecc) & \pi(\veca) & \pi(\vecb)& \ldots
	}.
\end{align*}
\end{proof}
\end{lem}

\begin{cor}
The composition
$
	G_{\vecy_0,\vecy_n} \circ
	G_{\vecy_0,\vecy_{n-1}} \circ \ldots \circ
	G_{\vecy_0,\vecy_2} \circ
	G_{\vecy_0,\vecy_1}
$, sending $\pi\mapsto\pi'$, performs the right cyclic shift on images of
$\vecy_0, \ldots, \vecy_n$ given by
\begin{align*}
	%\pi =
	\pcmatrix{
	    \vecy_0 &    \vecy_1 &\ldots&    \vecy_{n-1}&     \vecy_n & \\
	\pi(\vecy_0)&\pi(\vecy_1)&\ldots&\pi(\vecy_{n-1})&\pi(\vecy_n)&
	}
	\mapsto
	%\pi' =
	\pcmatrix{
	    \vecy_0 &    \vecy_1 &\ldots&    \vecy_{n-1}&      \vecy_n \\
	\pi(\vecy_n)&\pi(\vecy_0)&\ldots&\pi(\vecy_{n-2})&\pi(\vecy_{n-1})
	}.
\end{align*}
Likewise,
$
	G_{\vecy_n,\vecy_1} \circ
	G_{\vecy_n,\vecy_2} \circ \ldots \circ
	G_{\vecy_n,\vecy_{n-2}} \circ
	G_{\vecy_n,\vecy_{n-1}}
$
leaves the image of $\vecy_0$ unchanged and performs the left cyclic shift on
images of $\vecy_1, \ldots, \vecy_n$ given by
\begin{align*}
	\pcmatrix{
	    \vecy_0 &    \vecy_1 &\ldots&    \vecy_{n-1} &    \vecy_n  \\
	\pi(\vecy_0)&\pi(\vecy_1)&\ldots&\pi(\vecy_{n-1})&\pi(\vecy_n)
	}
	\mapsto
	\pcmatrix{
	    \vecy_0 &    \vecy_1 &\ldots&    \vecy_{n-1} &    \vecy_n \\
	\pi(\vecy_0)&\pi(\vecy_2)&\ldots&\pi(\vecy_{n})  &\pi(\vecy_{1})
	}.
\end{align*}
\begin{proof}
These follow from the lemma by induction on $n$.
\end{proof}
\end{cor}

Composing these two maps, we find that
\begin{align*}
	(
	G_{\vecy_n,\vecy_1} \circ
	G_{\vecy_n,\vecy_2} \circ \ldots \circ
	G_{\vecy_n,\vecy_{n-2}} \circ
	G_{\vecy_n,\vecy_{n-1}}
	)\circ(
	G_{\vecy_0,\vecy_n} \circ
	G_{\vecy_0,\vecy_{n-1}} \circ \ldots \circ
	G_{\vecy_0,\vecy_2} \circ
	G_{\vecy_0,\vecy_1}
	)
\end{align*}
swaps the images of $\vecx=\vecy_0$ and $\vecz=\vecy_n$ while leaving
all other images unchanged, that is,
\begin{align*}
	\pcmatrix{
	    \vecy_0  &     \vecy_1  & \ldots&     \vecy_{n-1}  &     \vecy_n \\
	\pi(\vecy_0) & \pi(\vecy_1) & \ldots& \pi(\vecy_{n-1}) & \pi(\vecy_n)
	}
	\mapsto
	\pcmatrix{
	    \vecy_0  &     \vecy_1  & \ldots&     \vecy_{n-1}  &     \vecy_n \\
	\pi(\vecy_n) & \pi(\vecy_1) & \ldots& \pi(\vecy_{n-1}) & \pi(\vecy_0)
	}.
\end{align*}
This ends the proof of propostion \ref{prop:SO_irreducible}.
\end{proof}
\end{prop}

\begin{rem*}
Below we will discuss winding cycles, and the empirical fact that the swap-only
algorithm reaches them only rarely.  The chain is irreducible but the non-zero
transition probabilities can still be very small.
\end{rem*}

\begin{prop}[Aperiodicity]
\label{prop:SO_aperiodic}
The swap-only algorithm's Markov chain is \plainidx{aperiodic}.
\begin{proof}
From Markov-chain theory \cite{bib:lawler}, we know that all states in a
recurrence class have the same period (see definition \ref{defn:period} on page
\pageref{defn:period}). Thus, it suffices to show that one state, e.g. the
identity, is aperiodic.  If there is non-zero probability of transitioning from
the identity to itself, the identity is an aperiodic state.  But this is in
fact the case:  The identity has zero energy (equation
\eqref{eqn:RCM_H_rell_V}).  Any state proposed as a transition from the
identity is necessarily a two-cycle, for which the distance terms in equation
\eqref{eqn:RCM_H_rell_V} are positive.  The cycle-weight terms or interaction
terms are non-negative.  Thus $\Delta H > 0$, and the swap-only Metropolis
transition probability is strictly less than 1.  Therefore there is a non-zero
probability of staying at the identity permutation.
\end{proof}
\end{prop}

\begin{prop}[Detailed balance]
\label{prop:SO_DB}
For all $\pi,\pi' \in \SN$,
\begin{align}
\label{eqn:SO_DB}
	P(\pi) M(\pi, \pi') &= P(\pi') M(\pi', \pi).
\end{align}
\begin{proof}
The detailed-balance\index{detailed balance} statement in terms of the Gibbs
distribution (equation \eqref{eqn:RCM_Gibbs_P}) and the swap-only Metropolis
transition matrix (equation \eqref{eqn:SO_M}) is
\begin{align*}
	\frac{e^{-H(\pi)}}{Z}
	\left(1 \wedge e^{-H(\pi')} e^{H(\pi)}\right)
	&\maybeeq
	\frac{e^{-H(\pi')}}{Z}
	\left(1 \wedge e^{-H(\pi)} e^{H(\pi')}\right).
\end{align*}
The $Z$'s cancel.
The lemma below shows that $M(\pi,\pi') \ne 0$ iff $M(\pi',\pi) \ne 0$.
If $M(\pi,\pi') = 0$, then detailed balance holds.
If $M(\pi,\pi') \ne 0$, then there are two cases.
If $H(\pi') \le H(\pi)$, then
\begin{align*}
 	e^{-H(\pi)} \left(1\right)
	&=
	e^{-H(\pi')} \left(e^{-H(\pi)} e^{H(\pi')}\right).
\end{align*}
If $H(\pi') > H(\pi)$,
\begin{align*}
	e^{-H(\pi)} \left(e^{-H(\pi')} e^{H(\pi)}\right)
	&=
 	e^{-H(\pi')} \left(1\right).
\end{align*}
In all cases, detailed balance holds.
\end{proof}
\end{prop}

\begin{lem}
\label{lem:nzdb1}
For all $\pi,\pi' \in \SN$,
\begin{align*}
	M(\pi,\pi') \ne 0 \iff M(\pi', \pi) \ne 0.
\end{align*}
\begin{proof}
Either $d(\pi,\pi') > 2$, $d(\pi,\pi') = 2$, or $\pi=\pi'$.
If $d(\pi,\pi') > 2$, then $M(\pi,\pi') = 0$ and $M(\pi',\pi) = 0$;
if $\pi=\pi'$, then $M(\pi,\pi') = M(\pi',\pi)$.
Now we consider $d(\pi,\pi') = 2$.  Then $\pi$ and $\pi'$ differ at two sites
$\vecx$ and $\vecy$.  Put
\begin{align*}
	\pi (\vecx) &= \vecu, &
	\pi'(\vecx) &= \vecv, \\
	\pi (\vecy) &= \vecv, &
	\pi'(\vecy) &= \vecu.
\end{align*}
If $\|\vecu-\vecv\|_\Lambda = 1$ then $M(\pi,\pi') \ne 0$ and $M(\pi',\pi) \ne
0$ since $\vecu$ and $\vecv$ are nearest-neighbor lattice sites.  If
$\|\vecu-\vecv\|_\Lambda > 1$ then $M(\pi,\pi') = 0$ and $M(\pi',\pi) = 0$
since $\vecu$ and $\vecv$ are not nearest-neighbor lattice sites.
\end{proof}
\end{lem}

This lemma completes the proof that the swap-only algorithm satisfies detailed
balance and thus has the Gibbs distribution as its invariant distribution.

The following proposition is not a correctness result, but rather a sanity
check.  It shows that cycles may grow or shrink upon swaps.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.7]{figures/gkcycles.eps}
\caption[Swaps merge disjoint cycles and split single cycles.]
	{Swaps merge disjoint cycles and split single cycles.
	The left-hand permutation can be reached from the right-hand permutation
	via a swap, and vice versa.
	\label{fig:socycles}}
\end{center}
\end{figure}

\begin{prop}
\label{prop:SO_merge_or_split}
If $\vecx$ and $\vecy$ are\index{split}\index{merge}\index{cycle
split}\index{cycle merge} in disjoint cycles before a non-trivial swap at
$\vecx$ and $\vecy$, then they are in the same cycle afterward and vice versa
(see figure \ref{fig:socycles}).
\begin{proof}
First suppose that $\vecx$ and $\vecy$ are in disjoint cycles.  Let the
respective cycle lengths be $\ell(\vecx) = a$ and $\ell(\vecy)=b$.
Recall that $1 \le a,b \le N$.
Those cycles are
$$
	\vecx        \mapsto
	\pi(\vecx)   \mapsto
	\pi^2(\vecx) \mapsto
	\ldots       \mapsto
	\pi^{a-1}(\vecx) \mapsto
	\vecx
$$
and
$$
	\vecy        \mapsto
	\pi(\vecy)   \mapsto
	\pi^2(\vecy) \mapsto
	\ldots       \mapsto
	\pi^{b-1}(\vecy) \mapsto
	\vecy.
$$
Since these are disjoint cycles, all elements listed are distinct
lattice sites.  After the swap, we have
$$
	\vecy        \mapsto
	\pi(\vecx)   \mapsto
	\pi^2(\vecx) \mapsto
	\ldots       \mapsto
	\pi^{a-1}(\vecx) \mapsto
	\vecx
$$
and
$$
	\vecx        \mapsto
	\pi(\vecy)   \mapsto
	\pi^2(\vecy) \mapsto
	\ldots       \mapsto
	\pi^{b-1}(\vecy) \mapsto
	\vecy.
$$
This is a single cycle of length $a+b$, starting with $\vecy$, including
$\vecx$, and returning to $\vecy$.

Second, suppose that $\vecx$ and $\vecy$ are in the same cycle.  Let
$a=\ellxypi$ and $b=\ellxypi$ (see definition
\ref{def:ellxy}).  (These numbers are both positive since the swap is
non-trivial, i.e.  $\vecx \ne \vecy$.) Then we have
$$
	\vecx        \mapsto
	\pi(\vecx)   \mapsto
	\pi^2(\vecx) \mapsto
	\pi^{a-1}(\vecx) \mapsto
	\vecy        \mapsto
	\pi(\vecy)   \mapsto
	\pi^2(\vecy) \mapsto
	\ldots       \mapsto
	\pi^{b-1}(\vecy) \mapsto
	\vecx.
$$
This is a single cycle of length $a+b$; all lattice sites listed are
distinct.  After the swap, we have
$$
	\vecy        \mapsto
	\pi(\vecx)   \mapsto
	\pi^2(\vecx) \mapsto
	\pi^{a-1}(\vecx) \mapsto
	\vecy
\qand
	\vecx        \mapsto
	\pi(\vecy)   \mapsto
	\pi^2(\vecy) \mapsto
	\ldots       \mapsto
	\pi^{b-1}(\vecy) \mapsto
	\vecx.
$$
These are disjoint cycles of length $a$ and $b$, respectively; the first
contains $\vecx$ and the second contains $\vecy$.
\end{proof}
\end{prop}

\begin{rem}
\label{rem:SO_merge_or_split_cyclens}
If $\vecx \ctdto \vecy$, i.e. the swap splits\index{split} their common cycle,
the old cycle lengths $\ellxpi$ and $\ellypi$ are equal, and the new cycle
lengths after the swap are
\begin{align*}
	\ellxpiprime &= \ellyxpi \qqand
	\ellypiprime = \ellxypi.
\end{align*}
Otherwise, i.e. the swap merges\index{merge} the disjoint cycles, we have
\begin{align*}
	\ellxpiprime &= \ellypiprime = \ellxpi + \ellypi.
\end{align*}
\end{rem}

%% ----------------------------------------------------------------
\section{Winding numbers and the swap-and-reverse algorithm}
\label{sec:wno_SAR}

The\index{conservation of winding number}\index{winding number} propositions of
section \ref{sec:SO_correctness} showed that the swap-only algorithm is
correct, asymptotically in the number of Metropolis sweeps --- in particular,
any permutation is reachable from any other with non-zero probability.
However, in practice some of these transition probabilities can be quite small.
In particular, we observe empirically that the swap-only algorithm always
generates permutations with zero winding number.  This is readily proved.

\begin{prop}
In the \plainidx{short-jump-length regime}, the swap step of the swap-only
algorithm preserves winding number.
\begin{rem*}
This means that a single jump of length on the order of $L/2$ --- which happens
with non-zero but very small probability --- is required for the SO algorithm
to change a winding number.
\end{rem*}
\begin{proof}
The permutations before and after the swap have winding numbers
\begin{align*}
	\vecW(\pi) &= \colvecthree{W_x(\pi)}{W_y(\pi)}{W_z(\pi)}
		= \sum_{i=1}^N \torusdiff(\pi(\vecx_i),\vecx_i),
	&
	\vecW(\pi') &= \colvecthree{W_x(\pi')}{W_y(\pi')}{W_z(\pi')}
		= \sum_{i=1}^N \torusdiff(\pi'(\vecx_i),\vecx_i)
\end{align*}
where the \plainidx{difference vector} $\torusdiff$ is as defined in equation
\eqref{eqn:torusdiff}.  Since we work in the regime of short jumps, and since
$\pi'(\vecx_i)$ is a nearest neighbor of $\pi(\vecx_i)$, the Euclidean charts
overlap and the $\vecx_i$'s cancel when we subtract $\vecW(\pi)$ from
$\vecW(\pi')$.  Also, $\pi$ agrees with $\pi'$ except at the two swap points
$\vecx$ and $\vecy$; we have $\pi'(\vecx)=\pi(\vecy)$ and vice versa.  Thus the
change in winding number is computed entirely in the same chart and we have
\begin{align*}
	\vecW'-\vecW
	%
	&= \frac{1}{L} \sum_{i=1}^N \torusdiff(\pi'(\vecx_i), \pi(\vecx_i)) %\\
	%
	= \frac{1}{L} \left[ \torusdiff(\pi'(\vecx), \pi(\vecx))
	+ \torusdiff(\pi'(\vecy), \pi(\vecy)) \right] \\
	%
	&= \frac{1}{L} \left[ \pi'(\vecx) - \pi(\vecx)
	+ \pi'(\vecy) - \pi(\vecy) \right] %\\
	%
	= \frac{1}{L} \left[ \pi(\vecy) - \pi(\vecx)
	+ \pi(\vecx) - \pi(\vecy) \right] = 0.
\end{align*}
\end{proof}
\end{prop}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics{figures/wno_zero_pf.eps}
\caption
	[Illustration of winding-number conservation.]
	{Example permutations $\pi$ (left) and $\pi'$ (right)
	illustrating winding-number conservation.
	\label{fig:wno_zero_pf}}
\end{center}
\end{figure}

An example is shown in figure \ref{fig:wno_zero_pf} in dimension $d=2$
with $N=8$ points on a lattice of width $L=4$.  The sites
affected by the permutation swap are $\vecx=\vecx_3$ and $\vecy=\vecx_7$.  The
change in winding numbers is
\begin{align*}
	\vecW(\pi') - \vecW(\pi)
	&= \frac{1}{4}\left[ \torusdiff(\pi'(\vecx_3),\vecx_3)
	+  \torusdiff(\pi'(\vecx_7),\vecx_7)
	-  \torusdiff(\pi (\vecx_3),\vecx_3)
	-  \torusdiff(\pi (\vecx_7),\vecx_7) \right] \\
	&= \frac{1}{4}\left[
			\colvectwo{1}{0} +
			\colvectwo{-1}{0}
		\right]
	- \frac{1}{4}\left[
			\colvectwo{0}{-1} +
			\colvectwo{0}{1}
		\right]
		= \colvectwo{0}{0} \\
	&= \frac{1}{4}\left[ \torusdiff(\pi'(\vecx),\pi(\vecx)) \right]
	+  \frac{1}{4}\left[ \torusdiff(\pi'(\vecy),\pi(\vecx)) \right] \\
	&= \frac{1}{4}\left[
			\colvectwo{1}{1} +
			\colvectwo{-1}{-1}
		\right].
\end{align*}

A partial solution is explained intuitively by figure \ref{fig:sowinding}.
Part 1 of the figure shows a permutation $\pi$ with a long cycle on the torus
which almost meets itself in the $x$ direction.  In part 2, after a Metropolis
step sending $\pi$ to $\pi'$, one cycle winds by $+1$ and the other by $-1$.
Metropolis steps create winding cycles only in opposite-direction pairs; the
total $W_x(\pi)$ is still zero.  Part 3 of the figure shows that if we reverse
one cycle (which is a zero-energy move), $W_x(\pi)$ is now 2.  In general,
winding numbers of even parity can be generated.  We are sampling from several,
but not all, modes in a multimodal probability distribution\index{multimodal
distribution} on permutations which is indexed by the winding numbers $W_x$,
$W_y$, and $W_z$.

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.8]{figures/gkwinding.eps}
\caption[Conservation of winding number in the SO algorithm.]
	{Conservation of winding number in the swap-only algorithm, and a
	partial solution provided by the swap-and-reverse algorithm.
	\label{fig:sowinding}}
\end{center}
\end{figure}

The \emphidx{swap-and-reverse} algorithm adds a second type of sweep to the
swap-only algorithm.  Namely:  (1) In a swap-only sweep, for each lattice site
one does a Metropolis step as above.  (2) In a cycle-reversing sweep, for each
cycle in the permutation, one reverses the direction of the cycle with
probability $1/2$.  This permits winding numbers of even parity in each of the
three axes.  The correctness proof is unaffected, since cycle reversal is a
zero-energy change.  The time required to reach permutations with non-zero
winding numbers, which the asymptotic correctness proof does not address, is
reduced.  The additional penalty in terms of CPU time consumed by cycle
reversal is found to be negligible.

Other solutions exist to generate winding numbers of arbitrary parity: the
\plainidx{band-update} method of chapter \ref{chap:band_updates} and the worm
algorithm of chapter \ref{chap:worm}.  As will be shown, they suffer from
too-low acceptance rate and too-long stopping time, respectively.  Therefore,
the swap-and-reverse algorithm is our current best algorithm; it is used to
generate all the results discussed in chapter \ref{chap:results}.  The order
parameters $f_S$ and $f_W$ depend on winding phenomena, but the other three,
$1/\xi$, $f_I$, and $\fM$, do not; furthermore, results obtained in chapter
\ref{chap:results} using each of the five order parameters are, for the most
part, compatible.  Yet, as we will see in chapter \ref{chap:results}, $f_S$ and
$f_W$ do not permit successful finite-size scaling.

%% ================================================================
\chapter{Band updates}
\label{chap:band_updates}

Winding cycles are a \plainidx{global phenomenon}, while the SO swaps of
section \ref{sec:SO_algorithm} are local\index{local changes}.  The
\plainidx{Swendsen-Wang} algorithm for the planar \plainidx{Ising model}
addresses a global/local problem not unlike our winding-number problem, which
was presented in detail in section \ref{sec:wno_SAR}.  Motivated by
Swendsen-Wang for the Ising model, we attempt to define a Metropolis step for
our random-cycle model which changes one of the winding-number components
$W_x$, $W_y$, or $W_z$ by $\pm 1$.  This attempt at non-local updates has an
unreasonably low acceptance rate, namely, on the order of $e^{-L}$ where $L$ is
the box length.  Nonetheless, this concept may provide fodder for better,
future ideas.

%% ----------------------------------------------------------------
\section{The algorithm}

As discussed in section \ref{sec:SO_correctness}, a Metropolis transition from
$\pi$ to $\pi'$ may be thought of as composition\index{composition of
permutations} with another permutation $\tau$, i.e. $\pi' = \tau \pi$.  We
replace the swap operator $\tau=G_{\veca,\vecb}$ of section
\ref{sec:SO_correctness}, which was a two-cycle, with a permutation $\tau$
which has a winding $L$-cycle.  Without loss of generality, it suffices to
discuss a permutation $\tau$ which sends every lattice point to itself except
for one line of points with $y$ and $z$ coordinates equal to zero (figure
\ref{fig:band_updates_tau}).  This $\tau$ will have winding number
$(W_x,W_y,W_z)=(+1,0,0)$.  If we can do that, then by reflection and rotation
symmetries we can construct similar $\tau$'s with $W_x$, $W_y$, or $W_z$ equal
to $\pm 1$.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{figures/band_updates.eps}
\caption
	[Band update as composition with an $L$-cycle.]
	{Example of band update as composition with an $L$-cycle: $\pi' = \tau\pi$.
	The winding number $W_x$ increases by $+1$.
	\label{fig:band_updates_tau}}
\end{center}
\end{figure}

Figure \ref{fig:band_updates_tau} displays the idea.  The permutation $\tau$ is
an $L$-cycle; we put $\pi' = \tau\pi$.  It seems clear from the picture that
the winding number is modified in the desired manner, and moreover it seems
plausible to conjecture that winding numbers are additive with respect to
permutation composition, i.e. that $\vecW(\pi') = \vecW(\tau) + \vecW(\pi)$.
Proving either of these statements rigorously would be worthwhile if band
updates were worth pursuing.  However, as shown in the next section, they are
not.

%% ----------------------------------------------------------------
\section{Acceptance rate}
\label{sec:acceptance_rate}

We examine the acceptance rate of the band-update algorithm using a
semi-empirical method.  Recall from section \ref{sec:theory_mjl} that we define
the random variable $j_\vecx(\pi)$ to be $\|\pi(\vecx)-\vecx\|_\Lambda$.  By
examination of histograms acquired over MCMC simulations, we see that this
parameter is noncritical; its values change smoothly with $T$ near $T_c$.  For
$T=6$ and $7$, respectively, we find\footnote{We use the statistics convention
wherein $\hat{P}$ is an experimental estimator for the exact (but unknown)
value $P$.} distributions for $j_\vecx$, as shown in table
\ref{table:jump_len_distro}.
\begin{table}[!htb]
$$
\begin{tabular}{|c|c|c|c|}
\hline $j$ & $\hat{P}(J = j), T=6$ & $j$ & $\hat{P}(J=j), T=7$ \\
\hline
\hline $0$       & 0.4801 & 0.0000000 & 0.7745 \\
\hline $1$       & 0.3361 & 1.0000000 & 0.1822 \\
\hline $\sqrt 2$ & 0.1545 & 1.4142136 & 0.0378 \\
\hline $\sqrt 3$ & 0.0216 & 1.7320508 & 0.0042 \\
\hline $4$       & 0.0036 & 2.0000000 & 0.0012 \\
\hline $\sqrt 5$ & 0.0032 & 2.2360680 & 0.0001 \\
\hline $\sqrt 6$ & 0.0009 &           &        \\
\hline
\end{tabular}
$$
\caption{Empirical jump-length distribution, with $T=6,7$.
	\label{table:jump_len_distro}}
\end{table}
Thus for $T=6,7$, respectively, mean jump lengths are $0.608$ and $0.245$,
while mean squared jump lengths are $0.746$ and $0.276$.  Roughly, the latter
is of order $0.5$.  Recall in particular that it is the squared jump
length which provides the main contribution to the system energy (equation
\eqref{eqn:RCM_H_rell_V}).

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.7]{figures/band_updates_2.eps}
\caption
	[Change in jump lengths on a band update.]
	{Change in jump lengths for a point affected by a band update.
	\label{fig:band_updates_delta}}
\end{center}
\end{figure}

The left-hand side of figure \ref{fig:band_updates_delta} shows (in two
dimensions only) various possibilities for a permutation arrow from a point
$\vecx$.  The right-hand side of the figure shows what happens to the jump
lengths at $\vecx$ on a right shift.  (All $L$ points in the $L$-cycle will be
affected similarly.) An up arrow of length 1 becomes a diagonal up-left arrow
of length $\sqrt 2$, a right arrow of length 1 becomes a right arrow of length
$2$, and so on.  Given an attempted band update $\pi \to \pi'$, the typical
value of the energy change $\Delta H$ at a single point (remembering that
cycle-weight corrections are low-order perturbations, since $\alpha$ is small)
is
\begin{align*}
	\frac{T}{4} \left( \bbE[j_\vecx(\pi')^2] - \bbE[j_\vecx(\pi)^2] \right).
\end{align*}
From the table just above, we can compute the expected values of
$j_\vecx(\pi)^2$ and $j_\vecx(\pi')^2$.  We find the energy difference per
point to be on the order of $+0.8 \cdot T/4 \approx +1.2$.  Since $L$ points
are involved in a band update, this means $\bbE[\Delta H] \approx 1.2 L \approx
L$.  Transitions are accepted with probability $\min\{1,e^{-\Delta H}\}$
(section \ref{sec:MCMC_recipe}) which is approximately $e^{-L}$.  We need to
consider $L$ from approximately $30$ and upward to get past the most severe
finite-size effects; $e^{-30} \approx 10^{-14}$ is effectively zero, and thus
proposed band updates are effectively never accepted.  This calculation matches
with simulation tests performed in software.

%% ----------------------------------------------------------------
\section{Band udpate with compensation}

At the 2010 Workshop of David Landau's Center for Simulational Physics at the
University of Georgia, Friederike Schmid of the University of Mainz suggested a
solution to the acceptance-rate problem with the band-update algorithm.  This
idea comes too late to include in the large-scale computational runs done for
this dissertation; however, it should work, and might be used in subsequent
computational work on this problem.

Specifically, the problem with the band update is that the change in energy is
of order $L$.  To counteract this, in the same Metropolis step in which one
proposes a band update as described above, one should also find another cycle
of $\pi$, not intersecting the band, with cycle length approximately $L$.  The
proposed change will do the band shift, while also replacing this second cycle
with one-cycles at each of its points --- the latter reducing the energy by $L$
or so.  The total energy change will be approximately zero, and thus the
acceptance rate should be usably high.

%% ================================================================
\chapter{The worm algorithm}
\label{chap:worm}

This\index{worm algorithm} chapter, like chapter \ref{chap:SO_SAR}, presents a
Markov chain for MCMC sampling of the model of random spatial permutations
(chapter \ref{chap:model_defns}) within the framework of chapter
\ref{chap:MCMC}.  The worm algorithm solves the problem of
winding-number-parity conservation within the SAR algorithm (section
\ref{sec:wno_SAR}).  However, a stopping time which is poorly bounded in the
lattice size prevents the worm algorithm from being our algorithm of choice.

%% ----------------------------------------------------------------
\section{The idea of the worm algorithm}

Worm algorithms have been used heavily in path-integral Monte Carlo (PIMC)
simulations:  see \cite{bib:bps06, bib:pst98, bib:gcl97, bib:kps, bib:nl04,
bib:pc87}.  The context is that interparticle interactions are modeled using
\plainidx{Brownian bridges} in the \plainidx{Feynman-Kac} approach.  A naive,
pre-PIMC sampling approach involves generating separate Brownian bridges from
point A to point B.  The PIMC idea is to generate a single Brownian bridge,
then modify a bit at a time using MCMC methods.

For the random-cycle model with true Bose interactions, the Brownian bridges
implicit in the $V$ terms of equation \eqref{eqn:RCM_H_gen_V} have been
integrated out in equation \eqref{eqn:RCM_H_rell_V}.  In fact, this is the key
selling point of the random-cycle model in the larger context of the Bose gas
(larger meaning beyond the scope of this dissertation).  Most of the complexity
of PIMC simulations, which are an efficient approach to Brownian bridges, goes
away.  If one were to adapt a PIMC worm algorithm to the RCM, one would need to
spend significant time learning about PIMC.  Yet it is likely that most of the
complexity will also go away.  Instead, it is simpler to ask:  If one were to
have a worm algorithm for the random-cycle model, what properties would it
have?  We require the following:
\begin{itemize}
\item We have a lattice with a fixed number $N$ of points.  There is no
desire to work in the \plainidx{grand-canonical ensemble}.
\item We want the ability to open and close permutation cycles.
(An open cycle is a ``worm''.)
\item Given that, tips of open cycles may wander around the 3-torus before
closing, permitting arbitrary winding numbers.
\end{itemize}
Thus, we want to sometimes open a cycle, then modify it with SO-like steps,
then close it again.  Following \plainidx{PIMC} worm algorithms, all our Metropolis steps
will involve the worm.  This does touch all lattice points:  a worm is opened
at a site, then modified, then closed.  Then, a worm is opened somewhere else,
and so on.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{figures/worm1.eps}
\caption{Open cycles as permutations on $N+1$ points.
	\label{fig:worm1}}
\end{center}
\end{figure}

Question:  Can we leverage our knowledge of permutations?  To see how, consider
a closed cycle and an open cycle on $N=3$ points (see also figure
\ref{fig:worm1}):
\begin{equation*}
	\pcmatrix{
		1 & 2 & 3 \\
		2 & 3 & 1 \\
	},
	\qquad
	\pcmatrix{
		1 & 2 & 3 & {}\\
		2 & 3 & {} & 1 \\
	}
\end{equation*}
In the open cycle, $1\mapsto 2$, $2\mapsto 3$, $3 \mapsto$ nothing, and nothing
$\to 1$.  Call that nothing \emph{something} --- the \emphidx{wormhole point}.
It is an $(N+1)$st point, $w$:
$$
	\pcmatrix{
		1 & 2 & 3 & w \\
		2 & 3 & w & 1 \\
	}
$$
Henceforth, the wormhole point will be written as $w$ or $N+1$.  In diagrams,
it will be an open dot while the other $N$ points will be written with filled
dots (as in figure \ref{fig:worm1}).
Now we have permutations on $\SNp$.  Given $\pi\in\SN$, \plainidx{inject} $\pi$
into $\SNp$ via $\pi(w)=w$.

\begin{defn}
For $\pi\in\SNp$, we say $\pi$ is a \emphidx{closed permutation}
if $\pi(w)=w$.
We say $\pi$ is an \emphidx{open permutation}
if $\pi(w) \ne w$.
Likewise, a cycle of $\pi$ is said to be open or closed, respectively, if it
does or does not contain $w$.
\end{defn}

\begin{rem*}
The PIMC jargon is that closed permutations are in the \emphidx{$Z$ sector}
(for partition function), while open permutations are in the \emphidx{$G$
sector} (for Matsubara Green's function).
\end{rem*}

The goal is to invent an \plainidx{energy function}, \plainidx{Gibbs
distribution}, and \plainidx{Metropolis algorithm} for these extended
permutations in $\SNp$ such that the \plainidx{marginal distribution} on
$\SNp$, conditioned on closed permutations, matches the RCM Gibbs distribution
(equation \eqref{eqn:RCM_Gibbs_P}).  Then, random variables will be sampled only
at closed permutations.

%% ----------------------------------------------------------------
\section{Extended random-cycle model}

Recall\index{ERCM} that we inject $\pi\in\SN$ into $\SNp$ via $\pi(w)=w$.  The
$(N+1)$st point $w$ is \emphidx{non-spatial}:  it has no distance associated
with it.

\begin{defn}
The \emphidx{extended lattice} is\index{$\Lambda'$}
$$
	\Lambda' := \Lambda \cup \{w\}
$$
\end{defn}

\begin{defn}
For $\pi\in\SNp$, define
\begin{align}
\label{eqn:ERCM_H_rell_V}
	H'(\pi) &= \frac{T}{4} \sum_{\stackrel{i=1}{\pi(\vecxi) \ne w}}^N
		\|\vecxi - \vecxpii\|_\Lambda^2
		+ \sum_{\ell=1}^N \alpha_\ell r_\ell(\pi)
		+ \gamma \; 1_{\SNpc}(\pi).
\end{align}
\end{defn}
That is, we add $\gamma$ to the energy if the permutation is open.  Note that
this \emphidx{extended energy} agrees with the RCM energy (equation
\eqref{eqn:RCM_H_rell_V}) on closed permutations.  (The  $\gamma$ term is only
one particular choice; one might develop a better choice.) This is used to
prove the marginality condition below.  A small positive $\gamma$ factor is
sufficient to establish aperiodicity of the Markov chain (proposition
\ref{prop:worm_aperiodic}).  The \emphidx{extended Gibbs distribution} and
\emphidx{extended partition function} are defined in the obvious way, as
follows.
\begin{defn}
Let
\begin{align}
\label{eqn:ERCM_Gibbs_P}
	P'(\pi) = \frac{e^{-H'(\pi)}}{Z'}
\end{align}
where the \plainidx{partition function} is
\begin{align}
\label{eqn:ERCM_Gibbs_Z}
	Z' &= \sum_{\pi\in\SNp} e^{-H'(\pi)}.
\end{align}
\end{defn}

%% ----------------------------------------------------------------
\section{Proof of marginality}

As long as the energy function for the ERCM and the RCM agree on closed
permutations, the following desired marginality condition holds.  This means
that the interaction in section \ref{sec:prb_model} --- or any other
to-be-invented interaction model --- may use the worm algorithm as long as it
agrees on closed permutations\index{marginality condition}.

\begin{prop}[Marginality condition]
\label{prop:marginality}
Let $\SN \into \SNp$ by taking $\pi(w)=w$.
Let $H,H'$ be energy functions on $\SN$ and $\SNp$, respectively,
such that for all $\pi\in\SN$,
\begin{align}
	H(\pi) = H'(\pi).
\end{align}
Let $P,P',Z,Z'$ be as above.  Then for $\pi\in\SN$,
\begin{align}
\label{eqn:marg_P}
	P'(\pi \mid \pi\in\SN) = P(\pi).
\end{align}
\begin{proof}
Let $\pi\in\SN$.  The left-hand side of equation \eqref{eqn:marg_P} is, by
definition of conditional expectation,
\begin{align*}
	P'(\pi \mid \pi\in\SN)
	&= \frac{P'(\pi) \;1_{\SN}(\pi)}{P'(\SN)}.
\end{align*}
The numerator is the Gibbs probability for closed permutations, or zero for
open ones:
\begin{align*}
	P'(\pi) \;1_{\SN}(\pi)
	&= \frac{1}{Z'}e^{-H'(\pi)} \;1_{\SN}(\pi)
	= \frac{1}{Z'}e^{-H (\pi)} \;1_{\SN}(\pi)
\end{align*}
since $H$ and $H'$ agree on closed permutations.  The denominator is the total
probability of closed permutations:
\begin{align*}
	P'(\SN)
	&= \frac{1}{Z'} \sum_{\pi \in\SN} e^{-H'(\pi)}
	= \frac{1}{Z'} \sum_{\pi \in\SN} e^{-H(\pi)}.
\end{align*}
Since $\pi\in\SN$, the ratio is
\begin{align*}
	\frac{
		\frac{1}{Z'}e^{-H (\pi)} \;1_{\SN}(\pi)
	}{
		\frac{1}{Z'} \sum_{\pi \in\SN} e^{-H(\pi)}
	}
	&= \frac{
		e^{-H (\pi)} \;1_{\SN}(\pi)
	}{
		\sum_{\pi \in \SN} e^{-H(\pi)}
	}
	%
	= \frac{
		e^{-H (\pi)} \;1_{\SN}(\pi)
	}{
		Z
	}
	%
	= P(\pi).
\end{align*}
\end{proof}
\end{prop}

%As a sanity check, we see whether the marginal density for the $\beta=0$
%case recovers uniform permutations on $\SN$, and whether the marginal density
%for the $\beta=\infty$ case recovers the singleton density on $\SN$ supported
%at the identity permutation.
%
%[Needs to be typed up.]

%% ----------------------------------------------------------------
\section{The worm algorithm}
\label{sec:worm_algo}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.7]{figures/wormmoves.eps}
\caption{Metropolis moves for the worm algorithm.
	\label{fig:wormmoves}}
\end{center}
\end{figure}

Now that we have the correct Gibbs distribution for the ERCM, the next step is
to devise a \plainidx{Metropolis algorithm} to sample from it.  Below, we will
prove correctness.  The \emphidx{worm algorithm}, within the context of the
recipe in section \ref{sec:MCMC_recipe}, is as follows:
\begin{itemize}

\item A \plainidx{sweep} begins with a closed permutation $\pi$.

\item The permutation is now closed, so $\pi(w)=w$.  Select a lattice site
$\vecx$ at uniform random.  With probability proportional to $1 \wedge \edh$,
open the permutation by swapping the arrows of $\vecx$ and $w$.  This is called
an \emphidx{open} move.  (See figure \ref{fig:wormmoves}.)

%	\begin{align*}
%	\pi: &
%	\pcmatrix{
%		\ldots & \vecx      & \ldots &     w      & \ldots \\
%		       & \downarrow &        & \downarrow &        \\
%		\ldots & \pi(\vecx) & \ldots & \pi(w)=w   & \ldots \\
%	} &
%	\pi': &
%	\pcmatrix{
%		\ldots & \vecx      & \ldots & \vecy      & \ldots \\
%		       & \downarrow &        & \downarrow &        \\
%		\ldots &     w & \ldots & \pi(\vecx) & \ldots \\
%	} \\
%	\end{align*}

\item Now that the permutation is open, do a \emphidx{head swap}, \emphidx{tail
swap}, or \emphidx{close}.

\item Head swap:  Pick a lattice site $\vecx$ nearest-neighbor to the lattice
site $\piiw$.  With probability proportional to $1 \wedge \edh$, swap arrows as
in figure \ref{fig:wormmoves}.  The head swap is trivial if $\vecx = \piiw$,
which happens only if the head swap is rejected.  The head swap would be a
close if $\vecx = w$, but we choose $\vecx$ to be a lattice site.  Thus, the
permutation remains open on a head swap.

% * A trivial head swap is a stay:  if x == piiw.
% * A head swap is a close if x == w.

\item Tail swap:  Pick a lattice site $\pix$ nearest-neighbor to the lattice
site $\piw$.  With probability proportional to $1 \wedge \edh$, swap arrows as
in figure \ref{fig:wormmoves}.  The tail swap is trivial if $\pix = \piw$,
which happens only if the tail swap is rejected.  The tail swap would be a
close if $\pix = w$, but we choose $\pix$ to be a lattice site.  Thus, the
permutation remains open on a tail swap.

% * A trivial tail swap is a say:  if x == w.
% * A tail swap is a close if pi(x) == w.

\item Close: with probability proportional to $1 \wedge \edh$, swap arrows as
in figure \ref{fig:wormmoves}.  The permutation is now closed.

\item Once the permutation is closed --- after an open, some number of
head/tail swaps, and a close, or after a rejected open --- a \emphidx{worm
sweep} has been completed.  At every sweep, one may obtain a value of any
desired random variables for inclusion in computation of their sample means.

\end{itemize}

\begin{defn}
\label{defn:worm_trivial}
A head swap at $\vecx$ is \emphidx{trivial} if $\vecx = \piiw$;
a tail swap at $\vecx$ is trivial if $\pix = \piw$.
\end{defn}

%% ----------------------------------------------------------------
\section{Fibration of $\SNp$ over $\SN$}

The definitions and lemmas in this section facilitate explicit construction of
the Markov matrix, and are necessary for proving correctness of the worm
algorithm.  As suggested by figure \ref{fig:fiber4}, we may separate all of
$\SNp$ into the closed permutations $\SN$ and the open permutations $\SNpc$.
Furthermore, for each of the $N!$ closed permutations $\pi$, we may open $\pi$
at any of the $N$ sites $\vecx_1$, \ldots, $\vecx_N$.  Collecting each of the
$N$ open permutations obtained from each closed permutation creates a
\emphidx{fibration} of $\SNp$.  The key points about the structure of this
\plainidx{fibration}, formalized by the lemmas below, are as follows.
\begin{itemize}

\item Each open permutation is one opener move away from a \plainidx{base}
closed permutation.  The $N$ open permutations above a base closed permutation
$\pi$ are the \plainidx{fiber} over $\pi$.

\item This induces a \plainidx{disjoint partition} of the open permutations
$\SNpc$.

\item Opens and closes, as defined in section \ref{sec:worm_algo}, stay within
fibers; non-trivial head swaps and tail swaps \plainidx{cross fibers}.

\item For each open permutation, the six non-trivial head swaps and six tail
swaps result in twelve distinct permutations.

\item Head swaps and tail swaps are \plainidx{transitive on fibers}.
\end{itemize}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.9]{figures/fiber4.eps}
\caption[Fibration of $\mcS_4$ over $\mcS_3$.]
	{Fibration of $\mcS_4$ over $\mcS_3$.  Closed permutations (i.e. $\mcS_3$)
	are along the bottom row; open permutations (i.e. $\mcS_4 \setminus
	\mcS_3$) are above the bottom row.  The column, or fiber, above each closed
	permutation $\pi$ contains the open permutations obtained from $\pi$ by an
	opener move.  Arrows modified by opener moves are shown in black.
	\label{fig:fiber4}}
\end{center}
\end{figure}

We first define maps corresponding to worm Metropolis moves.

\begin{defn} The four worm Metropolis moves of figure \ref{fig:wormmoves} may
be viewed in terms of maps.  Throughout, $\vecz \in \Lambda \cup \{w\}$.

Let $O: \;\SN\times\Lambda \to \SNpc$ send $O(\pi,\vecx) = \pi'$ such that
\begin{align*}
	\pi'(\vecx) &= w, \\
	\pi'(w)     &= \pix, \\
	\pi'(\vecz) &= \pi(\vecz), \quad \vecz \ne \vecx, w.
\end{align*}
Let $C: \;\SNpc \to \SN$ send $C(\pi) = \pi'$ such that
\begin{align*}
	\pi'(\piiw) &= \piw, \\
	\pi'(w)     &= w, \\
	\pi'(\vecz) &= \pi(\vecz), \quad \vecz \ne \piiw, w.
\end{align*}
Let $S: \;\SNpc\times\Lambda \to \SNpc$ send $S(\pi,\vecx) = \pi'$ such that
\begin{align*}
	\pi'(\vecx) &= w, \\
	\pi'(\piiw) &= \pix, \\
	\pi'(\vecz) &= \pi(\vecz), \quad \vecz \ne \vecx, \piiw.
\end{align*}
Let $T: \;\SNpc\times\Lambda \to \SNpc$ send $T(\pi,\vecx) = \pi'$ such that
\begin{align*}
	\pi'(\vecx) &= \piw, \\
	\pi'(w)     &= \pix, \\
	\pi'(\vecz) &= \pi(\vecz), \quad \vecz \ne \vecx, w.
\end{align*}

\end{defn}

Throughout the proofs of the fibration-structure lemmas, we will use the
following fact.
\begin{lem}
\label{lem:pineq}
If $\vecx \ne \vecy$, then $\pix \ne \piy$ and $\piix \ne \piiy$.
\begin{proof}
%By contrapositive:  if $\pix = \piy$ then $\pii(\pi(\vecx)) = \pii(\pi(\vecy))$
%and so $\vecx = \vecy$.
If $\vecx \ne \vecy$ and $\pix = \piy$, then $\pi$ is not 1-1 which is
a contradiction since $\pi$ is a permutation.
This applies to $\pii$ as well, since $\pii$ is also a
permutation.
\end{proof}
\end{lem}

Now we may prove the fibration-structure lemmas.

\begin{lem}
Each open permutation $\pi$ is one opener move away from a base closed
permutation $\pi'$.  That is,  for all $\pi \in \SNpc$, there exists $\pi' \in
\SN$ such that $C(\pi) = \pi'$.
\begin{proof}
Let $\pi\in\SNp$.  Since $\pi$ is open, $\piw \ne w$ and $\piiw \ne w$.
Let $\veca = \piiw$ and $\vecb = \piw$.  Both are lattice points.
Applying $C$, we have $C(\pi)=\pi'$ where $\pi'(\veca)=\vecb$, $\pi'(w)=w$,
and $\pi'(\vecz)=\pi(\vecz)$ for all remaining lattice points $\vecz \ne
\veca, \vecb$.  Since $\pi'(w)=w$, $\pi'$ is closed.
\end{proof}
\end{lem}

\begin{defn}
For $\pi\in\SN$, $C^{-1}(\pi) \subset \SNpc$ is the \textbf{fiber} of open
permutations over $\pi$.
\end{defn}

\begin{lem}
\label{lem:worm_opens_and_closes}
Opens and closes stay within fibers, and each fiber has $N$ elements.
\begin{proof}
Closes stay within fibers by definition of fiber.  Next, fix $\pi\in\SN$ and
let $\vecx_1, \vecx_2 \in \Lambda$.  (These are two different ways to open the
same closed permutation.) Let
$$
	\pi'_1 = O(\pi,\vecx_1), \quad
	\pi'_2 = O(\pi,\vecx_2).
$$
Then $\pi'_1$ and $\pi'_2$ have
$$
	\vecx_1 \mapsto w \mapsto \pi(\vecx_1), \qquad
	\vecx_2 \mapsto w \mapsto \pi(\vecx_2),
$$
respectively, agreeing with $\pi$ at all other lattice points $\vecz$.
Now, $C(\pi'_1)$ and $C(\pi'_2)$ have
$$
	\vecx_1 \mapsto \pi(\vecx_1), w \mapsto w, \qquad
	\vecx_2 \mapsto \pi(\vecx_2), w \mapsto w
$$
respectively, agreeing with $\pi$ at all other lattice points $\vecz$.  But
this means $C(\pi'_1)$ agrees with $C(\pi'_2)$ agree at all points of
$\Lambda'$, so $C(\pi'_1) = C(\pi'_2)$.  Thus, $\pi'_1$ and $\pi'_2$ are in the
same fiber.

For the last claim, fix $\pi\in\SN$ and enumerate the $N$ lattice points of
$\Lambda$ as $\vecx_1, \ldots, \vecx_N$.  We claim that the $N$ permutations
$$
	\pi'_1 = O(\pi,\vecx_1), \ldots, \pi'_N = O(\pi,\vecx_N),
$$
which are all now known to be in the same fiber, are all distinct.  To see
this, fix $i \ne j$ from out of $\{1, 2, \ldots, N\}$.  Then $\pi'_i$ and
$\pi'_j$ have
$$
	\vecx_i \mapsto w \mapsto \pi(\vecx_i), \qquad
	\vecx_j \mapsto w \mapsto \pi(\vecx_j).
$$
Since $\vecx_i \ne \vecx_j$, by lemma \ref{lem:pineq} $\pi(\vecx_i) \ne
\pi(\vecx_j)$.  Since
$$
	\pi'_i(w) = \pi(\vecx_i) \ne \pi(\vecx_j) = \pi'_j(w),
$$
$\pi'_i$ and $\pi'_j$ send $w$ to different points.  Therefore, the
permutations $\pi'_i$ and $\pi'_j$ are distinct.
\end{proof}
\end{lem}

\begin{lem}
The above fibration induces a disjoint partition of the open permutations
$\SNpc$.  That is, for $\pi'_1, \pi'_2 \in \SN$,
\begin{align*}
	\pi'_1 \ne \pi'_2 \implies
	C^{-1}(\pi'_1) \cap C^{-1}(\pi'_2) &= \emptyset
	\qqand
	\bigcup_{\pi\in\SN} C^{-1}(\pi) = \SNpc.
\end{align*}
\begin{proof}
For the first claim, suppose the intersection is non-empty.  Let $\pi \in\SNpc$
be such that $\pi \in C^{-1}(\pi'_1)$ and $\pi \in C^{-1}(\pi'_2)$.  This means
$C(\pi) = \pi'_1$ and $C(\pi) = \pi'_2$ with $\pi'_1 \ne \pi'_2$, which is a
contradiction since the map $C$ is uniquely defined for all $\pi \in \SNpc$.

For the second claim: there are $N!$ closed permutations.  We know from the
first claim that the $N!$ fibers, one above each closed permutation, are all
disjoint.  From lemma \ref{lem:worm_opens_and_closes}, we know that each fiber
has $N$ elements.  We have accounted for all $N\cdot N! = (N+1)!-N!$ open
permutations, so we must have all of $\SNpc$.
\end{proof}
\end{lem}

%           * * * * * * * * each of height N
%           * * * * * * * *
%           * * * * * * * *
% N! fibers * * * * * * * *
% N! closed . . . . . . . .

\begin{lem}
Non-trivial head swaps and tail swaps (definition \ref{defn:worm_trivial})
cross fibers.
\begin{proof}
First consider head swaps.
Let $\pi,\pi' \in \SNpc$ differ by a non-trivial head swap, namely, there is
$\vecx \ne \piiw$ such that $\pi' = S(\pi, \vecx)$.
Then $\pi$ and $\pi'$ have
$$
	\begin{array}{lccccc}
	\pi:  & \vecx &\mapsto& \pix &\mapsto& \pi^2(\vecx), \\
	\pi': & \piiw &\mapsto& \pix &\mapsto& \pi^2(\vecx), \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\piiw &\mapsto&    w &\mapsto& \piw, \\
	\vecx &\mapsto&    w &\mapsto& \piw,
	\end{array}
$$
respectively.  Now apply $C$ to each: $C(\pi)$ and $C(\pi')$ have
$$
	\begin{array}{lccccc}
	C(\pi):  & \vecx &\mapsto& \pix &\mapsto& \pi^2(\vecx), \\
	C(\pi'): & \piiw &\mapsto& \pix &\mapsto& \pi^2(\vecx), \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\piiw &\mapsto&    \piw, \\
	\vecx &\mapsto&    \piw,
	\end{array}
\qquad
	\begin{array}{lccccc}
	w &\mapsto&    w, \\
	w &\mapsto&    w,
	\end{array}
$$
respectively.  Since $\vecx \ne \piiw$, $C(\pi) \ne C(\pi')$.

Next, consider tail swaps.
Let $\pi,\pi' \in \SNpc$ differ by a non-trivial tail swap, namely, there is
$\pix \ne \piw$ such that $\pi' = T(\pi, \vecx)$.
Then $\pi$ and $\pi'$ have
$$
	\begin{array}{lccccc}
	\pi:  & \piix &\mapsto& \vecx &\mapsto& \pix, \\
	\pi': & \piix &\mapsto& \vecx &\mapsto& \piw, \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\piiw &\mapsto&    w &\mapsto& \piw, \\
	\piiw &\mapsto&    w &\mapsto& \pix, \\
	\end{array}
$$
respectively.  Now apply $C$ to each: $C(\pi)$ and $C(\pi')$ have
$$
	\begin{array}{lccccc}
	C(\pi):  & \piix &\mapsto& \vecx &\mapsto& \pix, \\
	C(\pi'): & \piiw &\mapsto& \vecx &\mapsto& \piw, \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\piiw &\mapsto&    \piw, \\
	\piiw &\mapsto&    \pix,
	\end{array}
\qquad
	\begin{array}{lccccc}
	w &\mapsto&    w, \\
	w &\mapsto&    w,
	\end{array}
$$
respectively.  Since $\pix \ne \piw$, $C(\pi) \ne C(\pi')$.
\end{proof}
\end{lem}

\begin{lem}
\label{lem:worm_distinct_dozen}
For each open permutation, the six non-trivial head swaps and six non-trivial
tail swaps result in twelve distinct permutations.
\begin{proof}
Fix $\pi\in\SNpc$.
Let $\vecx_1, \ldots, \vecx_6$ be the six nearest-neighbor lattice sites to the
lattice site $\piiw$;
let $\vecy_1, \ldots, \vecy_6$ be the six lattice sites
such that $\pi(\vecy_1), \ldots, \pi(\vecy_6)$ are nearest-neighbor lattices
site to the
lattice site $\piw$.  (See figure \ref{fig:wormmoves}.)

First, we show that the six permutations $S(\pi,\vecx_1), \ldots,
S(\pi,\vecx_6)$ are distinct.  Let $i \ne j$ for $i,j=1, \ldots, 6$; let $\pi_i
= S(\pi,\vecx_i)$ and $\pi_j = S(\pi,\vecx_j)$.  Then $\pi$ has
$$
	\begin{array}{lccccc}
	\pi:   & \vecx_i &\mapsto& \pi(\vecx_i), \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\vecx_j &\mapsto& \pi(\vecx_j), \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\piiw &\mapsto& w; \\
	\end{array}
$$
$\pi_i$, and $\pi_j$ have
$$
	\begin{array}{lccccc}
	\pi_i: & \vecx_i &\mapsto& w, \\
	\pi_j: & \vecx_j &\mapsto& w, \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\piiw &\mapsto& \pi(\vecx_i), \\
	\piiw &\mapsto& \pi(\vecx_j), \\
	\end{array}
$$
respectively.
Since $\vecx_i \ne \vecx_j$, $\pi_i \ne \pi_j$.


Second, we show that the six permutations
$T(\pi,\vecy_1), \ldots, T(\pi,\vecy_6)$ are distinct.
Let $i \ne j$ for $i,j=1, \ldots, 6$; let $\pi_i
= T(\pi,\vecy_i)$ and $\pi_j = T(\pi,\vecy_j)$.  Then $\pi$ has
$$
	\begin{array}{lccccc}
	\pi:   & \vecy_i &\mapsto& \pi(\vecy_i), \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\vecy_j &\mapsto& \pi(\vecy_j), \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	w &\mapsto& \piw; \\
	\end{array}
$$
$\pi_i$, and $\pi_j$ have
$$
	\begin{array}{lccccc}
	\pi_i: & \vecy_i &\mapsto& \piw, \\
	\pi_j: & \vecy_j &\mapsto& \piw, \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	w &\mapsto& \pi(\vecy_i), \\
	w &\mapsto& \pi(\vecy_j), \\
	\end{array}
$$
respectively.  Since $\vecy_i \ne \vecy_j$, by lemma \ref{lem:pineq}
$\pi(\vecy_i) \ne \pi(\vecy_j)$.  Since $\pi_i,\pi_j$ send $w$ to to different
sites, $\pi_i \ne \pi_j$.

Third, we show that the head-swaps of $\pi$ are distinct from the tail-swaps
of $\pi$.  Fix $\pi\in\SNpc$ and let $i,j \in \{1, \ldots, 6\}$.  Then $\pi$
has
$$
	\begin{array}{lccccc}
	\pi:   & \vecx_i &\mapsto& \pi(\vecx_i), \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\vecy_j &\mapsto& \pi(\vecy_j), \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\piiw &\mapsto& w &\mapsto& \piw; \\
	\end{array}
$$
$S(\pi,\vecx_i)$ and $T(\pi,\vecy_j)$ have
$$
	\begin{array}{rccccc}
	S(\pi,\vecx_i): & \piiw &\mapsto& \pi(\vecx_i), \\
	T(\pi,\vecy_j): & \vecy_j &\mapsto& \piw, \\
	\end{array}
\qquad
	\begin{array}{rccccc}
	\vecx_i &\mapsto& w &\mapsto& \piw; \\
	\piiw   &\mapsto& w &\mapsto& \vecy_j; \\
	\end{array}
$$
respectively.  Under these two permutations, $w$ has images $\piw$ and
$\vecy_j$, respectively, and preimages $\vecx_i$ and $\piiw$.  By definition
\ref{defn:worm_trivial}, the non-trivial head swap $S(\pi,\vecx_i)$ has
$\vecx_i \ne \piiw$ and the non-trivial tail swap $T(\pi,\vecy_j)$ has $\piw
\ne \vecy_j$.  Thus, $S(\pi,\vecx_i)$ and $T(\pi,\vecy_j)$ are distinct
permutations.
\end{proof}
\end{lem}

%\begin{lem}
%Head swaps and tail swaps are transitive on fibers.
%\begin{proof}
%This needs to be proved.  This key result will establish irreducibility of the
%chain.
%
%%% This was proved different, using SO irr along with SO irr => worm irr.
%\end{proof}
%\end{lem}

%% ----------------------------------------------------------------
\section{Explicit construction of the Markov matrix}

Transition probabilities were described as being proportional to $1 \wedge
\edh$.  We put the constants of proportionality to be:
\begin{itemize}
\item $a$ for head swaps and tail swaps;
\item $b$ for closer moves;
\item $c$ for opener moves.
\end{itemize}
For SO/SAR, we chose the normalizing factor $C$ solely by the row-normalization
condition.  Here, with a more complicated algorithm, we will choose the
normalizing factors to satisfy detailed balance.

The Markov matrix is now $(N+1)! \times (N+1)!$:
\begin{itemize}

\item A closed permutation transitions only to itself, or to any of the $N$
open permutations in the fiber above it.  Thus, there are $N+1$ non-zero
entries in $\pi$'s row of $M$.

\item An open permutation transitions to any of the 12 open permutations
available by head-swapping or tail-swapping, or to itself, or to the closed
permutation at the base of its fiber.  Thus, there are 14 non-zero entries in
$\pi$'s row of $M$.

\end{itemize}

\begin{defn}
For open $\pi$, let
$$
	\{\vecx_1, \ldots, \vecx_6\} =
	\{\vecx \in \Lambda: \|\vecx,\piiw\|_\Lambda = 1\}
$$
and
$$
	\{\vecy_1, \ldots, \vecy_6\} =
	\{\vecy \in \Lambda: \|\piy,\piw\|_\Lambda = 1\}.
$$
Then define
\begin{align*}
	R_S(\pi) &= \{S(\pi,\vecx_1), \ldots, S(\pi,\vecx_6)\}, \\
	R_T(\pi) &= \{T(\pi,\vecy_1), \ldots, T(\pi,\vecy_6)\}.
\end{align*}
These are the twelve open permutations reachable from $\pi$ via head swaps and
tail swaps, respectively (lemma \ref{lem:worm_distinct_dozen}).
For closed $\pi$, define
\begin{align*}
	R_O(\pi) &= \{O(\pi,\vecx_1), \ldots, O(\pi,\vecx_N)\}.
\end{align*}
These are the $N$ open permutations reachable from $\pi$ via opener moves.
\end{defn}

With these definitions, the entries of the transition matrix are as follows.

If $\pi$ is closed:
\begin{align*}
	M(\pi,\pi') &= \begin{cases}
		\displaystyle
		c\left(1 \wedge e^{-H(\pi')+H(\pi)}\right), &
			\pi' \in R_O(\pi);
			\\
		\displaystyle
		1 - \sum_{\pi' \in R_O(\pi)}
			c\left(1 \wedge e^{-H(\pi')+H(\pi)}\right),
			& \pi'=\pi; \\
		0, & \textrm{ otherwise}.
	\end{cases}
\end{align*}

If $\pi$ is open:
\begin{displaymath}
	M(\pi,\pi') = \begin{cases}
		\displaystyle
		a\left(1 \wedge e^{-H(\pi')+H(\pi)}\right),
			& \pi' \in R_S(\pi); \\
	%
		\displaystyle
		a\left(1 \wedge e^{-H(\pi')+H(\pi)}\right),
			& \pi' \in R_T(\pi); \\
	%
		\displaystyle
		b\left(1 \wedge e^{-H(\pi')+H(\pi)}\right),
			& \pi' = C(\pi); \\
	%
		\displaystyle
		1 - t(\pi), & \pi'=\pi; \\
	%
		0, & \textrm{ otherwise}
	\end{cases}
\end{displaymath}
where
\begin{align*}
	t(\pi) =
		\sum_{\pi''\in R_S(\pi) \cup R_T(\pi)}
			a\left(1 \wedge e^{-H(\pi'')+H(\pi)}\right)
		- b\left(1 \wedge e^{-H(C(\pi))+H(\pi)}\right)
\end{align*}

Row normalization for closed $\pi$: $c(1 \wedge \edh)$ is between 0 and $c$ so
$\sum\textrm{rest}$ is between 0 and $cN$.  Take
\begin{align}
	c &= 1/N.
\end{align}
Row normalization for open $\pi$ then gives
\begin{align}
	12a + b \le 1.
\end{align}

% xxxx ... note what we actually use, with xref fwd:
% c = b and 12a+b = 1.

%% ----------------------------------------------------------------
\section{Correctness}
\label{sec:worm_correctness}

As discussed in sections \ref{sec:MCMC_recipe} and \ref{sec:SO_correctness}, we
need to prove irreducibility, aperiodicity, and detailed balance for the worm
Markov chain.

\begin{prop}[Irreducibility]
\label{prop:worm_irreducible}
The worm algorithm's Markov chain is irreducible.
\begin{proof}
This follows immediately from propositions \ref{prop:SO_irreducible}
and \ref{prop:worm_irr_if_SO_irr}:  namely, the worm's chain is irreducibility
if the SO's chain is, and moreover the SO's chain is irreducible.
\end{proof}
\end{prop}

\begin{prop}
\label{prop:worm_irr_if_SO_irr}
The worm algorithm's Markov chain is irreducible if the SO algorithm's Markov
chain is irreducible.
\begin{proof}
The key point is that the composition\index{composition of permutations} of an
open, head swap, and close are precisely an SO swap.  Let $\vecx$ and $\vecy$
be lattice points such that $\pix$ and $\piy$ are nearest neighbors.  Starting
with $\pi$, then applying an open at $\vecx$, a head swap at $\vecy$, and a
close, we have
$$
	\begin{array}{lccccc}
	\pi:                     & \vecx &\mapsto& \pix, \\
	\pi'   = O(\pi,  \vecx): & \vecx &\mapsto& w, \\
	\pi''  = S(\pi', \vecy): & \vecx &\mapsto& \piy, \\
	\pi''' = C(\pi''):       & \vecx &\mapsto& \piy, \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\vecy &\mapsto& \piy, \\
	\vecy &\mapsto& \piy, \\
	\vecy &\mapsto& w, \\
	\vecy &\mapsto& \pix, \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	w &\mapsto& w;    \\
	w &\mapsto& \pix; \\
	w &\mapsto& \pix; \\
	w &\mapsto& w.
	\end{array}
$$

This shows that, if the SO algorithm is irreducible on $\SN$, the worm
algorithm is irreducible on $\SN$.  But then the worm algorithm is also
irreducible on $\SNp$:  fix an initial and final permutation; close the initial
permutation, if it is open, to obtain a closed permutation; use the preceding
argument to reach the closed permutation which lies under the fiber of the
desired final open permutation; do an open move (see lemma
\ref{lem:worm_opens_and_closes}) if the final permutation is open.
\end{proof}
\end{prop}

\begin{rem}
The worm algorithm has an additional degree of freedom.  If $\vecx$ and $\vecy$
are nearest-neighbor lattice sites, then the composition of an open at $\vecx$,
a tail swap at $\vecy$, and a close results in a similar swap of the jump
targets of $\vecx$ and $\vecy$:
$$
	\begin{array}{lccccc}
	\pi:                     & \vecx &\mapsto& \pix, \\
	\pi'   = O(\pi,  \vecx): & \vecx &\mapsto& w, \\
	\pi''  = T(\pi', \vecy): & \vecx &\mapsto& w, \\
	\pi''' = C(\pi''):       & \vecx &\mapsto& \piy, \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\vecy &\mapsto& \piy, \\
	\vecy &\mapsto& \piy, \\
	\vecy &\mapsto& \pix \\
	\vecy &\mapsto& \pix, \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	w &\mapsto& w;    \\
	w &\mapsto& \pix; \\
	w &\mapsto& \piy; \\
	w &\mapsto& w.
	\end{array}
$$
\end{rem}

\begin{prop}[Aperiodicity]
The worm algorithm's Markov chain is \plainidx{aperiodic}.
\begin{proof}
\label{prop:worm_aperiodic}
This is essentially the same as in the SO algorithm (proposition
\ref{prop:SO_aperiodic}):  given the small positive $\gamma$ in equation
\eqref{eqn:ERCM_H_rell_V}, an opener move from the identity entails an increase
in energy, and thus a reject of such an opener move occurs with a non-zero
probability.  (This argument applies in the non-interacting case.  For $r_2$
and $r_\ell$, it also applies.  For $V_{ij}$, which is not used for the
computational results of this dissertation, we would need to check that an
opener move from the identity doesn't decrease energy.)
\end{proof}
\end{prop}

\begin{prop}[Detailed balance]
\label{prop:worm_DB}
The Markov chain of the worm algorithm satisfies \plainidx{detailed balance}
with $b=c$.
\begin{proof}
We need
\begin{align*}
\label{eqn:worm_DB}
	P'(\pi) M(\pi, \pi') &= P'(\pi') M(\pi', \pi).
\end{align*}

For closed $\pi$ to closed $\pi'$: If $\pi=\pi'$ then we have detailed balance
trivially.  If $\pi\ne\pi'$ then $M(\pi,\pi')=M(\pi',\pi)=0$ since there are no
transitions between distinct closed permutations.

For closed $\pi$ to open $\pi'$: If $\pi'$ is not in the fiber above $\pi$,
then $M(\pi,\pi')=M(\pi',\pi)=0$ since opens and closes respect fibers (lemma
\ref{lem:worm_opens_and_closes}).  Now suppose $\pi'$ is in the fiber above
$\pi$.  As in the SO algorithm (proposition \ref{prop:SO_DB}), do cases on
$\Delta H$ positive or negative.  If $H'(\pi') \le H'(\pi)$, then
\begin{align*}
	e^{-H'(\pi)} c &= e^{-H'(\pi')} b e^{-H'(\pi)} e^{H'(\pi')}.
\end{align*}
Choose
\begin{align}
	b&=c
\end{align}
to satisfy detailed balance.
The case $H'(\pi') > H'(\pi)$ results in the same $b=c$ condition.

For open $\pi$ to closed $\pi'$: If $\pi$ is not in the fiber above $\pi'$,
then $M(\pi,\pi')=M(\pi',\pi)=0$ (lemma \ref{lem:worm_opens_and_closes}).  If
$\pi$ is in the fiber above $\pi'$, then we recover the $b=c$ condition.

It now remains to consider open $\pi$ transitioning to open $\pi'$.
We assume this to be the case for the rest of the proof.

If $M(\pi,\pi') = 0$ then we claim $M(\pi',\pi)=0$, as in lemma
\ref{lem:nzdb1}.
We have $\pi' \ne \pi$, $\pi' \notin R_S(\pi)$, and $\pi' \notin R_T(\pi)$.
We need to show $\pi \ne \pi'$ (which is obvious), $\pi \notin R_S(\pi')$, and
$\pi \notin R_T(\pi')$.
We prove the contrapositive:
$$
	\pi  \in \{\pi'\} \cup R_S(\pi') \cup R_T(\pi')
	\quad \implies \quad
	\pi' \in \{\pi\} \cup R_S(\pi) \cup R_T(\pi).
$$
If $\pi=\pi'$ then detailed balance is trivially satisfied.
Suppose $\pi\in R_S(\pi')$.
Then for some $\vecx_i$, $i=1,\ldots, 6$,
$\pi'$ and $\pi$ have
$$
	\begin{array}{lccccc}
	\pi':  & \vecx_i &\mapsto& \pi'(\vecx_i), \\
	\pi:   & \vecx_i &\mapsto& w,             \\
	\end{array}
\qquad
	\begin{array}{lccccc}
	\piiw &\mapsto& w &\mapsto& w, \\
	\piiw &\mapsto& w &\mapsto& \pi'(\vecx_i). \\
	\end{array}
$$
The lattice sites $\vecx_i$ and $w$ are nearest neighbors and $\pi',\pi$ agree
at all other sites, so there is a head swap sending $\pi$ to $\pi'$.
The case $\pi\in\R_T(\pi')$ is completely analogous.  This completes the
proof of the claim that $M(\pi,\pi') = 0 \implies M(\pi',\pi)=0$.

If $M(\pi,\pi') \ne 0$ then we claim $M(\pi',\pi) \ne 0$, again as in lemma
\ref{lem:nzdb1}.  The logic is the same as in the contrapositive argument which
was just completed.

The last step is to show detailed balance for open $\pi,\pi'$ where
$M(\pi,\pi') \ne 0$.  Again we do cases on whether the energy decreases
or increases.  If $H'(\pi') \le H'(\pi)$, then equation \eqref{eqn:worm_DB}
is
\begin{align*}
 	a e^{-H'(\pi)} \left(1\right)
	&=
	a e^{-H'(\pi')} \left(e^{-H'(\pi)} e^{H'(\pi')}\right).
\end{align*}
If $H'(\pi') > H'(\pi)$, then we have
\begin{align*}
	a e^{-H'(\pi)} \left(e^{-H'(\pi')} e^{H'(\pi)}\right)
	&=
 	a e^{-H'(\pi')} \left(1\right).
\end{align*}
In either case, detailed balance holds.
\end{proof}
\end{prop}

\begin{rem*}
Note that for closed $\pi$, there are $N$ choices of open $\pi'$; for open
$\pi$, there is one choice of closed $\pi'$.  In the software implementation,
the $1/N$ for opens comes in through uniform-random choice of $\vecx\in\Lambda$.
The result is that, for closed $\pi$, one may only attempt an open.  For open
$\pi$, one attempts a close $1/N$ of the time, and head or tail swaps each half
the rest of the time, respectively.
\end{rem*}

As a sanity check, we point out that cycles may grow or shrink upon worm moves.

\begin{prop}
\label{prop:worm_merge_or_split}
Non-trivial worm head swaps and tail swaps either split one cycle into two, or
join two cycles into one.
\begin{proof}
This is the same as for the SO case (proposition
\ref{prop:worm_merge_or_split}), which is strictly an algebraic result
involving permutations: the non-spatiality of the $w$ point plays no role.
\end{proof}
\end{prop}

%% ----------------------------------------------------------------
\section{Stopping time and modification ideas}
\label{sec:worm_stopping_time}

The essence of the winding-number problem, as discussed in section
\ref{sec:wno_SAR}, is that the configuration space has multiple
\plainidx{energy minima} (which are equivalent to \plainidx{probability
maxima}), indexed by winding numbers $W_x$, $W_y$, and $W_z$.  One might also
say that the probability distribution for random spatial permutations is
\emph{multimodal}\index{multimodal distribution}.  The swap-only algorithm
creates only permutations with winding numbers equal to 0.  The
swap-and-reverse algorithm creates permutations with \plainidx{even winding
numbers}:  the cycle-reversal move has \plainidx{zero energy change} and allows
subsequent permutations to \plainidx{hop across} a low double-winding-number
barrier.

The worm algorithm was designed to permit cycles with winding numbers of both
parities to be created: a cycle is opened, its tips wander around (perhaps
around the \plainidx{torus}), and then it recloses --- all of these steps
happening with low-energy changes afforded by worm \plainidx{tunneling} through
the energy barrier.  The only problem is that the open worm tips wander around
randomly within the $L$ box, and fail to reconnect as $L$ increases.  This is
the \emphidx{stopping-time problem}.  Specifically, histograms show that the
distribution of the \plainidx{wormspan} $\|\pi(w) - \pi^{-1}(w)\|_\Lambda$
peaks around $L/2$.

Recall from section \ref{sec:invt} that the correctness proofs of sections
\ref{sec:SO_correctness} and \ref{sec:worm_correctness} only address the limit
$M \to \infty$; they do not address rate of \plainidx{convergence}.  The worm
algorithm is correct, but we are not willing to wait long enough for it to
produce its correct results.  Figure \ref{fig:worm_vs_sar_perf} shows the
problem.  CPU time is plotted for $10^4$ SAR sweeps, at $T=6.0$, as a function
of $N=L^3$ for $L=5$ to $12$.  For the SAR algorithm, CPU time is nearly
\plainidx{linear} in $N$.  (In fact, it has an $N^2$ dependency, but with a low
constant of proportionality, as discussed in section \ref{sec:metro_step}.)
For the worm algorithm, CPU time is not linear in $N$; we cannot complete a
computation for $L$ large enough to be interesting, namely, 40 to 80.
Specifically, a log-log plot and regression on the data of figure
\ref{fig:worm_vs_sar_perf} show that the worm algorithm is strongly
\plainidx{quadratic} in $N$.  Fortunately, examination of random-variable plots
for $L=10$, comparing SAR to worm, show that similar results are produced ---
other than, of course, the winding-number histogram itself.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.65]{figures/sar_perf_small_L.eps}
\includegraphics[scale=0.65]{figures/worm_perf_small_L.eps}
\caption[Scalability of SAR and worm algorithms.]
	{Scalability of SAR and worm algorithms.  CPU times for $10^4$ SAR
	sweeps and $10^3$ worm sweeps are shown as a function of $N=L^3$ for
	$L=5$ to $12$.  SAR time is nearly linear in $N$; worm time is
	strongly quadratic in $N$.  Interesting $L$ (40-80) are unattainable.
	\label{fig:worm_vs_sar_perf}}
\end{center}
\end{figure}

Other ideas for addressing the winding-number problem include the following:

\begin{itemize}

\item In analogy with cluster updates for the Ising model, form a band around
the torus and do an $L$-cycle transformation.  Couple the SAR algorithm with
occasional band updates.  However, band updates have a too-low acceptance rate,
as was shown in chapter \ref{chap:band_updates}.

\item Temporarily pinch the torus geometry somehow in the SAR algorithm, such
that the distance penalty for wrapping around the torus is decreased.

\item Temporarily reduce and restore the temperature $T$ in the SAR algorithm
--- this is an annealing method.  This approach brings with it a performance
problem: re-thermalization (section \ref{sec:thermalization}) would need to be
performed after each annealing step.

\item Modify the worm algorithm to direct the worm somehow.  At the time the
worm is opened, add a distance weight of $\pm L$ in the $x$, $y$, or $z$
direction which will be removed by a wrap around the torus, increasing or
decreasing that winding-number component by 1.  Our attempts to do this have
not satisfied detailed balance.

\item Review the PIMC literature again and seek other inspiration.

\end{itemize}

The worm algorithm, even though it is effectively unusable as currently
designed, is the only way we currently have of sampling from the full
winding-number configuration space, i.e. odd as well as even winding numbers.
Thus, it will be worth the future effort to solve the stopping-time problem.

%% ================================================================
\chapter{$\Delta H$ computations}
\label{chap:Delta_H}

When computing $\Delta H$ for the swap-only, swap-and-reverse, or worm
algorithms, it is inefficient to find $H(\pi')$ and $H(\pi)$ separately, then
compute their difference: swap and worm moves are local, and most of the energy
terms are unchanged from $\pi$ to $\pi'$.  Instead (this is true for Metropolis
simulations in general), one discovers a formula for the energy change in a
proposed Metropolis move.  Even though these minimal energy-change formulas are
a software-optimization detail, they need to be considered carefully lest
errors intrude.

We write the energy of equation \eqref{eqn:ERCM_H_rell_V} as
\begin{equation}
\label{eqn:HDVW}
	H = D + V + W
\end{equation}
where $H$ is total energy, $D$ is the distance-related single-jump terms, $V$
is the jump-pair-interaction terms, and $W$ is the worm-dependent terms.  (Note
that $V$ is identically zero if there are no interactions, and $W$ is
identically zero for the SO, SAR, and band-update algorithms.)

%% ----------------------------------------------------------------
\section{Swap and worm with no interactions}
\label{sec:Delta_D}

Recall that the wormhole point is non-spatial and thus does not participate in
distance computations.  As is clear from figures \ref{fig:soswap} and
\ref{fig:wormmoves} (on pages \pageref{fig:soswap} and \pageref{fig:wormmoves},
respectively), the change in distance-related terms is
\begin{align*}
	\Delta D
	&= \|\vecx - \piy\|_\Lambda^2
	+  \|\vecy - \pix\|_\Lambda^2
	-  \|\vecx - \pix\|_\Lambda^2
	-  \|\vecy - \piy\|_\Lambda^2
	& &\, \textrm{(swap-only)} \\
%
	\Delta D
	&=-\|\vecx - \pix\|_\Lambda^2
	& &\, \textrm{(worm open)} \\
%
	\Delta D
	&= \|\piiw - \piw\|_\Lambda^2
	& &\, \textrm{(worm close)} \\
%
	\Delta D
	&= \|\piiw - \pix\|_\Lambda^2
	-  \|\vecx - \pix\|_\Lambda^2
	& &\, \textrm{(worm head swap)} \\
%
	\Delta D
	&= \|\vecx - \piw\|_\Lambda^2
	-  \|\vecx - \pix\|_\Lambda^2
	& &\, \textrm{(worm tail swap)}.
\end{align*}

%% ----------------------------------------------------------------
\section{Swap and worm with two-cycle interactions}

The non-spatiality of the wormhole point plays no role in the algebraic notion
of cycle lengths.  Thus, the same $\Delta r_2$ formulas apply to both
algorithms.  The $\Delta D$ is the same as in section \ref{sec:Delta_D}; he we
describe only the $\Delta V$.

Recall the definition of a swap from section \ref{sec:SO_algorithm}.  The
simplicity of figure \ref{fig:soswapx} masks a bit of detail: namely, the four
points may not all be distinct.  Thus, there are several cases.  (See figure
\ref{fig:r2cases}.)

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.7]{figures/gkswapx.eps}
\caption{A swap.
	\label{fig:soswapx}}
\end{center}
\end{figure}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.7]{figures/r2cases.eps}
\caption{Cases for $\Delta r_2$.
	\label{fig:r2cases}}
\end{center}
\end{figure}

\begin{itemize}
\item Case 0: $\pix=\piy$ (and so also $\vecx=\vecy$):  this is a trivial
move; $\pi'=\pi$.  $\Delta r_2 = 0$.

\item Case 1: $\vecx=\pix$.
	\begin{itemize}
	\item Case 1a:  $\vecy = \piy$.
		$\Delta r_2 = +1$.
	\item Case 1b:  $\vecy\ne\piy$ but $\vecy=\pi^2(\vecy)$.
		$\Delta r_2 = -1$.
	\item Case 1c:  $\vecy \ne \piy, \pi^2(\vecy)$.
		$\Delta r_2 =  0$.
	\end{itemize}

\item Case 2: $\vecy=\piy$.
	\begin{itemize}
	\item Case 2a:  $\vecx = \pix$.  Same as case 1a.
		$\Delta r_2 = +1$.
	\item Case 2b:  $\vecx\ne\pix$ but $\vecx=\pi^2(\vecx)$.
		$\Delta r_2 = -1$.
	\item Case 2c:  $\vecx \ne \pix, \pi^2(\vecx)$.
		$\Delta r_2 =  0$.
	\end{itemize}

\item Case 3: $\vecx=\piy$.
	\begin{itemize}
	\item Case 3a:  $\pix = \vecy$.
		$\Delta r_2 = -1$.
	\item Case 3b:  $\pi^2(\vecx) = \vecy$.
		$\Delta r_2 = +1$.
	\item Case 3c:  $\vecy \ne \pix, \pi^2(\vecx)$.
		$\Delta r_2 =  0$.
	\end{itemize}

\item Case 4: $\pix=\vecy$.
	\begin{itemize}
	\item Case 4a:  $\piy = \vecx$.  Same as case 3a.
		$\Delta r_2 = -1$.
	\item Case 4b:  $\pi^2(\vecy)=\vecx$.
		$\Delta r_2 = +1$.
	\item Case 4c:  $\vecx \ne \piy, \pi^2(\vecy)$.
		$\Delta r_2 =  0$.
	\end{itemize}

\item Case 5: $\pi^2(\vecx)=\vecx$.
	\begin{itemize}
	\item Case 5a:  $\pi^2(\vecy) = \vecy$.
		$\Delta r_2 = -2$.
	\item Case 5b:  $\pi^2(\vecy)\ne\vecy$.
		$\Delta r_2 = -1$.
	\end{itemize}

\item Case 6: $\pi^2(\vecy)=\vecy$.
	\begin{itemize}
	\item Case 6a:  $\pi^2(\vecx) = \vecx$.  Same as 5a.
		$\Delta r_2 = -2$.
	\item Case 6b:  $\pi^2(\vecx)\ne\vecx$.
		$\Delta r_2 = -1$.
	\end{itemize}

\item Case 7: $\pi^2(\vecx)=\vecy$.
	\begin{itemize}
	\item Case 7a:  $\pi^2(\vecy) = \vecx$.
		$\Delta r_2 = +2$.
	\item Case 7b:  $\pi^2(\vecy)\ne\vecx$.
		$\Delta r_2 = +1$.
	\end{itemize}

\item Case 8: $\pi^2(\vecy)=\vecx$.
	\begin{itemize}
	\item Case 8a:  $\pi^2(\vecx) = \vecy$.
		$\Delta r_2 = +2$.
	\item Case 8b:  $\pi^2(\vecx)\ne\vecy$.
		$\Delta r_2 = +1$.
	\end{itemize}

\item All other cases: $\Delta r_2 = 0$.

\end{itemize}


%% ----------------------------------------------------------------
\section{Swap and worm with $r_\ell$ interactions}
\label{sec:Delta_rell}

The non-spatiality of the wormhole point plays no role in the algebraic notion
of cycle lengths.  Thus, the same $\Delta r_2$ formulas apply to both
algorithms.

Recall proposition \ref{prop:SO_merge_or_split} and remark
\ref{rem:SO_merge_or_split_cyclens}: if $\vecx$ and $\vecy$ are in separate
cycles before the swap, they are in the same cycle afterward, and vice versa.
In the former case, the new common cycle length is the sum of the old separate
cycle lengths; in the latter case, the new cycle lengths are taken from the
number of permutation jumps from one site to the other.  (Throughout this
section, please consult figure \ref{fig:rellcases} for illumination.) Given
that general pair of facts, we split out subcases which are convenient as a
software-optimization detail:

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{figures/rellcases.eps}
\caption[Cases for $\Delta r_\ell$.]
	{Cases for $\Delta r_\ell$.  Sites and arrows not participating
	in changes are shown in grey.
	\label{fig:rellcases}}
\end{center}
\end{figure}

\begin{itemize}
\item Case 0: $\pix=\piy$ (and so also $\vecx=\vecy$):  this is a trivial
move; $\pi'=\pi$.  $\Delta r_\ell = 0$ for all $\ell=1, \ldots, N$.

\item Case 1:  $\vecx$ and $\vecy$ are in different cycles, but one of them is
in a one-cycle.

	\begin{itemize}
	\item Case 1a: $\vecx = \pix$:
		$\Delta r_1 = -1$,
		$\Delta r_{\ellypi} = -1$,
		$\Delta r_{\ellypi+1} = +1$.

	\item Case 1b: $\vecy = \piy$:
		$\Delta r_1 = -1$,
		$\Delta r_{\ellxpi} = -1$,
		$\Delta r_{\ellxpi+1} = +1$.
	\end{itemize}

\item Case 2: $\vecx$ and $\vecy$ are in the same cycle, but one is the
jump target of the other.
	\begin{itemize}
	\item Case 2a:  $\vecy = \pix$.
		$\Delta r_{\ellxpi} = -1$,
		$\Delta r_{\ellxpi-1} = +1$,
		$\Delta r_1 = +1$.

	\item Case 2a:  $\vecx = \piy$.
		$\Delta r_{\ellypi} = -1$,
		$\Delta r_{\ellypi-1} = +1$,
		$\Delta r_1 = +1$.
	\end{itemize}

\item Case 3: $\vecx$ and $\vecy$ are in the same cycle, and neither is the
jump target of the other.  Let $a=\ellxypi$ and $b=\ellyxpi$.  Then
		$\Delta r_{a+b} = -1$,
		$\Delta r_a = +1$,
		$\Delta r_b = +1$.

\item Case 4: $\vecx$ and $\vecy$ are in separate cycles.
	$\Delta r_{\ellxpi} = -1$,
	$\Delta r_{\ellypi} = -1$,
	$\Delta r_{\ellxpi+\ellypi} = +1$.
\end{itemize}

%% ----------------------------------------------------------------
\section{Swap with $V$ interactions}

Recall from proposition \ref{prop:marginality} that as long as the extended
energy function $H'$ agrees with the energy function $H$ on closed cycles, $P'$
has the correct marginal distribution on closed cycles.  Thus, when writing
energy terms for open cycles, we can choose how to define the energy.  For
$r_2$ and $r_\ell$ (the previous two sections), it is simplest to say that the
non-spatial point $w$ can participate in permutation cycles.  For other
interactions that depend on the spatiality of points, it is simplest to say
that $w$ does not participate.  Thus, here we split out swap and worm cases.

The change in energy is simply the contributions from the old arrows
$\vecx\mapsto\pix$ and $\vecy\mapsto\piy$ to all other arrows, along with their
mutual interaction, subtracted from the contributions from the new arrows
$\vecx\mapsto\piy$ and $\vecy\mapsto\pix$ to all other arrows, along with their
mutual interaction:
\begin{align*}
	\Delta V
	=& \sum_{\vecv \ne \vecx, \vecy} V(\vecx, \piy, \vecv, \piv)
	+ \sum_{\vecv \ne \vecx, \vecy} V(\vecy, \pix, \vecv, \piv)
	+ V(\vecx,\piy, \vecy, \pix) \\
	-&\sum_{\vecv \ne \vecx, \vecy} V(\vecx, \pix, \vecv, \piv)
	- \sum_{\vecv \ne \vecx, \vecy} V(\vecy, \piy, \vecv, \piv)
	- V(\vecx,\pix, \vecy, \piy).
\end{align*}

%% ----------------------------------------------------------------
\section{Worm with $V$ interactions}

The non-spatial point has no interactions, so we simply track the creation and
destruction of spatial-to-spatial arrows for the four types of worm move.  (See
figure \ref{fig:wormdeltav}.)

Open:
\begin{align*}
	-\sum_{\vecv \ne \vecx, w} V(\vecx, \pix, \vecv, \piv).
\end{align*}

Close:
\begin{align*}
	\sum_{\vecv \ne \piiw, w} V(\piiw, \piw, \vecv, \piv).
\end{align*}

Head swap:
\begin{align*}
	&\sum_{\vecv \ne \vecx, \piiw} V(\piiw, \pix, \vecv, \piv)
	- \sum_{\vecv \ne \vecx, \piiw} V(\vecx, \pix, \vecv, \piv).
\end{align*}

Tail swap:
\begin{align*}
	&\sum_{\vecv \ne \vecx, w, \piiw} V(\vecx, \piw, \vecv, \piv)
	- \sum_{\vecv \ne \vecx, w, \piiw} V(\vecx, \pix, \vecv, \piv).
\end{align*}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.7]{figures/wormdeltav.eps}
\caption[Cases for worm $\Delta_V$.]
	{Cases for worm $\Delta V$.  Non-spatial arrows (i.e. those
	starting or ending at $w$) are shown in grey.
	\label{fig:wormdeltav}}
\end{center}
\end{figure}

\afterpage{\clearpage} % flush figure queue

%%% ----------------------------------------------------------------
%\section{$\Delta D$ for point motion}
%
%Let $\vecX$ and $\vecX'$ be the old and new point configurations.
%They differ only at one $\vecx$, which changes position to $\vecx'$.
%\begin{align*}
%	D(\pi,\vecX)  &= \frac{T}{4} \sum_{\vecu \in \vecX}
%		\|\vecu - \pi(\vecu)\|_\Lambda^2 \\
%	\Delta D &=
%		 \|\vecx' - \pi(\vecx')\|_\Lambda^2
%		+\|\piinv(\vecx') - \vecx'\|_\Lambda^2
%		-\|\vecx - \pi(\vecx)\|_\Lambda^2
%		-\|\piinv(\vecx) - \vecx\|_\Lambda^2
%\end{align*}
%
%$\Delta r_2$ and $\Delta r_\ell$ are of course zero.
%
%$\Delta V$:
%\begin{align*}
%	V(\pi,\vecX) &= \frac{1}{2} \sum_{\vecu \ne \vecv}
%		V_4(\vecu,\pi(\vecu),\vecv,\pi(\vecv)). \\
%	\Delta V &=
%	 \frac{1}{2} \sum_{\vecu} V_4(\vecx', \pi(\vecx'), \vecu, \pi(\vecu))
%	+\frac{1}{2} \sum_{\vecu} V_4(\piinv(\vecx'), \vecx', \vecu, \pi(\vecu)) \\
%	&-\frac{1}{2} \sum_{\vecu} V_4(\vecx, \pi(\vecx), \vecu, \pi(\vecu))
%	-\frac{1}{2} \sum_{\vecu} V_4(\piinv(\vecx), \vecx, \vecu, \pi(\vecu))
%\end{align*}

%% ================================================================
%\chapter{Data structures and algorithms for single MCMC runs}
\chapter{Algorithms for single MCMC runs}
\label{chap:sw}

Chapters \ref{chap:SO_SAR}, \ref{chap:worm}, and \ref{chap:Delta_H} describe
the swap-only, swap-and-reverse, band-update, and worm algorithms.  The content
there focuses on algorithm steps and algorithm correctness, without reference
to a specific programming language or a specific \plainidx{software}
implementation.  This chapter, by contrast, focuses on particular
software-design choices which were made by the author.

The software program (\plainidx{\texttt{mcrcm}}) which does a single MCMC run
is written in the C language.  Execution of multiple MCMC runs, including
parallel processing, is done using a scripting language such as Bash or Python;
this is described in the next chapter.  Throughout this chapter and the next,
names of data structures and subroutines from the program code are written in
\texttt{typewriter font}.

The methods here are applicable for any of the algorithms of chapters
\ref{chap:SO_SAR} and \ref{chap:worm} --- swap-only, swap-and-reverse, and
worm --- or any other to-be-invented algorithm which satisfies the hypotheses
listed in section \ref{sec:MCMC_recipe} on recipes for MCMC algorithms.

%% ----------------------------------------------------------------
\section{Data structures}
\label{sec:sw_data_structures}

There is one main \plainidx{data structure}, of C type \texttt{points\_t},
containing \emphidx{points} and a \emphidx{cycle list} (see figure
\ref{fig:lattice_cycinfo}):

\begin{figure}[!thb]
\begin{center}
\psfragscanon
\includegraphics{figures/lattice_cycinfo.eps}
\caption[Lattice sites and cycle-information structure.]
	{Lattice sites and the wormhole point are shown in grey; three lattice
	sites participating in a 3-cycle are shown in black.  Every point
	(including the grey ones for which these arrows are not shown) contains
	the location (\texttt{pcycinfo}) of a cycle-information structure which
	caches the length of the cycle (\texttt{cyclen}); each cycle-information
	structure contains the location (\texttt{psite}) of one point in the cycle.
	Cycle-information structures are stored in a doubly linked list
	(\texttt{pprev} and \texttt{pnext}).
	\label{fig:lattice_cycinfo}}
\end{center}
\end{figure}

\begin{itemize}

\item \texttt{dims} contains the lattice dimensions $L$, $L$, $L$.  (For
1-dimensional or 2-dimensional use, not described in this thesis, these would
be $L,1,1$ or $L,L,1$, respectively.)

\item \texttt{N} is the product of the three dimensions.  It is used so
frequently in the program code that it is worth computing this product once at
the start of the program and keeping it here.

\item \texttt{lattice}:  $L \times L \times L$ array of points (data
type \texttt{point\_t}).

\item \texttt{wormhole}: an $(N+1)$st point (data type \texttt{point\_t})
called the \plainidx{wormhole point} (chapter \ref{chap:worm}).  (For the
swap-only and swap-and-reverse algorithms, all permutations send the wormhole
point to itself.)

\item \texttt{pcycinfo\_list\_head} and \texttt{pcycinfo\_list\_tail} are the
locations of the first and last cycle-information structure in the
doubly linked list of cycle-information structures.

\end{itemize}

Each point (\texttt{point\_t} data type) $\vecx$ contains:
\begin{itemize}

\item \texttt{selfi}, \texttt{selfj}, \texttt{selfk}:  lattice coordinates of
each point $\vecx$, with $x_i,x_j,x_k$ from $0$ to $L-1$.  For the wormhole
point, these coordinates are set to an undefined value.

\item \texttt{pfwd}: location of permutation image $\pi(\vecx)$.

\item \texttt{bfwd}: location of permutation \plainidx{preimage}
$\pi^{-1}(\vecx)$.  This is used for the reason described in section
\ref{sec:SO_algorithm}.  Namely, in a swap, one
	\begin{itemize}
	\item selects a site $\vecx$,
	\item follows the forward permutation pointer to find $\pix$,
	\item uses the lattice structure to find a site $\piy$ which is
		a nearest neighbor of $\pix$, and finally
	\item follows the backward permutation pointer to find
		$\vecy = \piinv(\piy)$.
	\end{itemize}

\item \texttt{fwd\_d} and \texttt{fwd\_dsq}: distance
$\|\pi(\vecx)-\vecx\|_\Lambda$ and squared distance
$\|\pi(\vecx)-\vecx\|_\Lambda^2$.  These are cached for performance reasons.
It is found empirically that approximately 10-20\% of proposed Metropolis
changes\index{acceptance rate} are accepted.  Thus, without caching of these
distances, most of the time the forward-distance values would be computed
redundantly.

\item \texttt{pcycinfo}: location of cycle-information structure (see
below).

\item \texttt{mark}:  this is a single integer stored at each lattice site.
When the cycle-information list is set up (section \ref{sec:sw_init}) or
sanity-checked (section \ref{sec:sw_check}), it is necessary to sweep through
all lattice sites, following permutation cycles, remembering which sites have
already been visited.  One could allocate a list of marks (one for each lattice
site) at the beginning of these routines, and free that list at the end.
Instead, the marks are stored in the lattice structure so that this scratch
space is available when needed.

\end{itemize}

Cycle information is stored in a doubly \plainidx{linked list} of
cycle-information structures (data type \texttt{cycinfo\_t}).  Each contains:
\begin{itemize}

\item \texttt{psite}: Location of one site in the cycle.

\item \texttt{cyclen}: Length of the cycle.

\item \texttt{pprev} and \texttt{pnext}: Location of the previous and next
cycle-information structure in the doubly linked list.

\end{itemize}

%% ----------------------------------------------------------------
\section{Overview}
\label{sec:sw_overview}

A true outline of the program (routine \texttt{main}
in file \texttt{mcrcm.c}) embodies the outline given in section
\ref{sec:MCMC_recipe}.  Namely:

\begin{itemize}

\item Determine the input parameters $L$, $T$, interaction type
(non-interacting, $r_2$, $r_\ell$) and parameter $\alpha$, algorithm type
(swap-only, swap-and-reverse, worm), and \texttt{number\_of\_sweeps}.  (These
are passed into the program via the command line.)

\item Print all control parameters (see section \ref{sec:MCMC_output}).

\item Initialize (see section \ref{sec:sw_init}).

\item Thermalization phase\index{thermalization phase}:

\vspace*{-0.4in}

	\begin{tabbing}
	\hspace{0.25in} \= \hspace{0.25in} \= \hspace{0.25in}
	\= \hspace{0.25in} \= \hspace{0.25in} \\
	\+	Loop until thermalized: \\
			Do one swap-only, swap-and-reverse, or worm sweep
					(section \ref{sec:metro_sweep}). \\
		See if thermalization is complete
			(section \ref{sec:thermalization}). \\
		Optionally sanity-check $H$ and cached cycle information
			(section \ref{sec:sw_check}). \\
	\-		Optionally display random-variable instances
					(section \ref{sec:MCMC_output}). \\
	\end{tabbing}

\vspace*{-0.4in}

\item Accumulation phase\index{accumulation phase}:

\vspace*{-0.4in}

	\begin{tabbing}
	\hspace{0.25in} \= \hspace{0.25in} \= \hspace{0.25in}
	\= \hspace{0.25in} \= \hspace{0.25in} \\
	\+	For sweep number from 0 to \texttt{number\_of\_sweeps}$ - 1$: \\
			Do one swap-only, swap-and-reverse, or worm sweep
				(section \ref{sec:metro_sweep}). \\
			Optionally write $\pi$ to disk
				(section \ref{sec:rzn_files}). \\
			Optionally sanity-check $H$ and cached cycle information
				(section \ref{sec:sw_check}). \\
			Optionally print realizations of user-specified random
				variables (section \ref{sec:MCMC_output}). \\
			Remember random-variable instances, for statistical use. \\
	\-		Compute statistics of random variables
				(sections \ref{sec:ergodic_sampling_thm} and
				\ref{sec:body_tauint}). \\
			Display statistics of random variables
				(section \ref{sec:MCMC_output}).
	\end{tabbing}

\end{itemize}

%% ----------------------------------------------------------------
\section{Initialization}
\label{sec:sw_init}

Software initialization consists of four main steps:

\begin{itemize}

\item Allocate memory for the lattice points: subroutine
\texttt{get\_cubic\_lattice\_points}.  Set the initial permutation to one of
the following:
	\begin{itemize}

	\item The identity permutation.  (This is the default, set up by
	the subroutine \texttt{get\_cubic\_lattice\_points}.)

	\item A uniform-random permutation on $\SN$, with the wormhole point sent
	to itself:  subroutine \texttt{set\_unif\_rand\_pmt}.

	\end{itemize}

\item Allocate time-series arrays for each random variable:
\texttt{allocate\_rvs}.

\item Initialize the cycle-information list:  subroutine
\texttt{set\_up\_cycinfo\_list}.

\item Find the initial system energy $H$, separated into $D$ and $V$ terms:
subroutine \texttt{get\_H\_of\_pi}.  This is a straightforward implementation
of equation \eqref{eqn:RCM_H_rell_V}.

\end{itemize}

%% ----------------------------------------------------------------
\section{Metropolis sweeps}
\label{sec:metro_sweep}

The\index{Metropolis sweep} swap-only algorithm uses a swap-only sweep; the
swap-and-reverse algorithm uses a swap-only sweep followed by a cycle-reverse
sweep.  A \plainidx{swap-only sweep} (subroutine \texttt{SO\_sweep}) is as
follows:
\begin{itemize}

\item Loop through lattice sites $\vecx=(x,y,z)$ lexically, i.e. $x$ from 0 to
$L-1$, $y$ from 0 to $L-1$, $z$ from 0 to $L-1$.

\item For the site $\vecx$, follow the forward permutation pointer to find
$\pix$.

\item Use the lattice structure to select $\piy$ which is one of the six
(i.e. $2d$) nearest-neighbor sites to $\pix$.

\item Follow the backward permutation pointer to find the point $\vecy$.

\item In subroutine \texttt{try\_SO\_swap}, propose and perhaps accept a
modification of the permutation.  This is a \plainidx{Metropolis step},
described in section \ref{sec:metro_step}.

\end{itemize}
(A slight modification of this algorithm would choose $\vecx$ at uniform-random
location on the lattice, $N$ times, rather than looping sequentially through
all $N$ lattice sites.) After a swap-only sweep has been performed, the
swap-and-reverse algorithm then does a \plainidx{reverse sweep} (subroutine
\texttt{reverse\_sweep}):
\begin{itemize}
\item For each cycle in the permutation (i.e. one follows the doubly-linked
list of cycle-information structures), with probability $1/2$ reverse all the
arrows in that cycle.  This is done for the reason described in section
\ref{sec:wno_SAR}, namely, it permits non-zero (but only even) winding numbers.
\item At each point, the forward and backward permutation pointers must be
updated, and the cached forward distance and forward squared distance must be
copied from one point to another.  The cycle-information structure is not
affected.  Also, the system energy is not affected.
\end{itemize}
A \plainidx{worm sweep} (subroutine \texttt{worm\_sweep}) is done as in section
\ref{sec:worm_algo}:
\begin{itemize}
\item One attempts to open the permutation at a uniform-random
lattice site $\vecx$.
\item If the open is not accepted, the sweep is complete.
\item Otherwise, some number of head swaps and/or tail swaps are proposed and
perhaps accepted.  Eventually, a close is proposed and accepted.  The sweep is
then complete.
\end{itemize}

Notice that the swap-only and reverse sweeps are of deterministic length:  the
former processes all $N$ lattice sites; the latter processes all cycles.  (Of
course, it takes more CPU time for an accepted proposal then a rejected
proposal.  Nonetheless, a fixed number of proposals is always made.)  For the
worm sweep, though, the \plainidx{stopping time} is random, depending on the
time for the worm head and tail to approach one another on the lattice.  (See
section \ref{sec:worm_stopping_time} for more details.)

%% ----------------------------------------------------------------
\section{Metropolis steps}
\label{sec:metro_step}

See\index{Metropolis step} chapter \ref{chap:Delta_H}, and in particular
section \ref{sec:Delta_rell} ($\Delta r_\ell$), for background information on
$\Delta H$ and $\Delta r_\ell$.  A \emphidx{Metropolis proposal}, for a swap as
described in section \ref{sec:SO_algorithm}, is as follows:

\begin{itemize}

\item To find $\Delta D$ as described in section \ref{sec:Delta_D}:  compute
$\|\vecx-\pi(\vecy)\|_\Lambda^2$ and $\|\vecy-\pi(\vecx)\|_\Lambda^2$.  These
will be $D$ terms for the proposed new permutation $\pi'$, if it is accepted.
The corresponding $D$ terms for the current permutation $\pi$, namely,
$\|\vecx-\pi(\vecx)\|_\Lambda^2$ and $\|\vecy-\pi(\vecy)\|_\Lambda^2$, are
already cached at the points $\vecx$ and $\vecy$.  Then
$$
	\Delta D = \frac{T}{4} \left(
		\|\vecx-\pi(\vecy)\|_\Lambda|^2 + \|\vecy-\pi(\vecx)\|_\Lambda|^2 -
		\|\vecx-\pi(\vecx)\|_\Lambda|^2 - \|\vecy-\pi(\vecy)\|_\Lambda|^2
	\right).
$$

\item The subroutine \texttt{get\_Delta\_V\_SO} performs the $\Delta V$
computations described in chapter \ref{chap:Delta_H}.  It also computes $\vecx
\ctdto \vecy$ (namely, whether the points $\vecx$ and $\vecy$ are in the same
cycle or not), along with $\ellxypi$ and $\ellyxpi$.  (If $\vecx$ and $\vecy$
are in the same cycle, then the cycle lengths are equal; if they are in
different cycles, $\ellxypi$ and $\ellyxpi$ are undefined.)

\item The total change in system energy for the proposed change is $\Delta H =
\Delta D + \Delta V$.

\end{itemize}

The Metropolis proposal is accepted with probability $\min\{1, \exp(-\Delta
H)\}$.  That is, if a pseudorandom number (section \ref{sec:rng}) uniformly
distributed between $0$ and $1$ is less than $\exp(-\Delta H)$, then $\pi$ is
replaced by $\pi'$.

A \emphidx{Metropolis update} consists of the following:

\begin{itemize}

\item The new system energy $H'$ is set to $H + \Delta H$.

\item The forward and backward permutation pointers \texttt{pfwd} and
\texttt{pbwd} at points $\vecx$ and $\vecy$ are updated so that $\pi'(\vecx) =
\pi(\vecy)$ and $\pi'(\vecx) = \pi(\vecy)$.

\item The cached forward squared distances $\|\vecx-\pi'(\vecx)\|_\Lambda|^2$
and $\|\vecy-\pi'(\vecy)\|_\Lambda|^2$ are stored in the \texttt{fwd\_dsq}
slots of the \texttt{point\_t} data structures for points $\vecx$ and $\vecy$.
Respective square roots are stored in the \texttt{fwd\_d} slots.

\item Cycle-information structures are updated by the subroutine
\texttt{update\_cycinfo}, which is discussed next.

\end{itemize}

\textbf{Without cycle-length caching:}  Recall from section\index{cycle-length
caching} \ref{sec:Delta_rell} that computing $\Delta r_\ell$ requires the
following steps:

\begin{itemize}
\item See if $\vecx$ and $\vecy$ are in the same cycle, i.e.
if $\vecx \ctdto \vecy$.

\item If so, find $\ellxypi$ and $\ellxypi$; if not, find $\ellxpi$ and
$\ellypi$.

\end{itemize}

To find these values, one may start at site $\vecx$, moving forward one
permutation jump at a time.  If one reaches $\vecy$ before returning to
$\vecx$, then $\vecx \ctdto \vecy$ and $\ellxypi$ has already been found.
Continuing to count hops back to $\vecx$ yields $\ellyxpi$.  If, on the other
hand, one returns to $\vecx$ without having encountered $\vecy$, then $\vecx
\notctdto \vecy$, and $\ellxpi$ has already been computed.  Counting hops from
$\vecy$ back to itself yields $\ellypi$.

Notice that each of these cycle-following steps requires $O(\ell)$ machine
operations where $\ell$ is the mean cycle length.  For subcritical temperatures
$T$ where cycles become long (of length at most $N$), these cycle-following
steps become unacceptably time-consuming.  Caching of cycle lengths has been
found to reduce simulation time, for $L=40$ lattices, by a factor of 15.  The
improvement is even more pronounced as $L$ is increased.

\textbf{With cycle-length caching:}  Keeping a list of cycles means that
the following Metropolis-proposal steps take $O(1)$ machine operations:

\begin{itemize}
\item To see if $\vecx$ and $\vecy$ are in the same cycle, i.e.
if $\vecx \ctdto \vecy$, check the two points' \texttt{pcycinfo} slots
and see whether they are equal or not.

\item The cycle lengths $\ellxpi$ and $\ellypi$ are immediately found
by consulting the \texttt{cyclen} slots of the \texttt{pcycinfo} data
structures.

\end{itemize}

Now, if $\vecx\ctdto\vecy$, one must additionally find either $\ellxypi$ or
$\ellyxpi$.  (Note that $\ellxypi+\ellyxpi=\ellxpi=\ellypi$ so it suffices to
find either one or the other.)  This is, \emph{a priori}, is of complexity
$O(\ell)$.  However, it has been found empirically that in the MCMC simulations
described by this thesis, one of the two of $\ellxypi$ or $\ellyxpi$ is almost
always small.  That is, a split of a large cycle usually pinches off a small
cycle; rarely is a large cycle split evenly.  It is likewise found empirically
that on merges of disjoint cycles, usually one of the two cycles is small.
Thus, if $\vecx\ctdto\vecy$, it suffices to start at $\vecx$, searching forward
and backward one jump at a time.  If one encounters $\vecy$ on forward jumps,
$\ellxypi$ has been found; if one encounters $\vecx$ on backward jumps,
$\ellyxpi$ has been found.  Thus the complexity is of order
$$
	O(\min\{\ell_\vecx, \ell_\vecy\}).
$$
A result of this is that all other computations done in our MCMC simulations
are $O(N)$.  This bit, however, is necessarily $O(N^2)$.  Yet, it is $O(N^2)$
with a low constant of proportionality, since one of $\ell_\vecx$ and
$\ell_\vecy$ is almost always small.  Plots of CPU time as a function of $N$
are shown in section \ref{sec:performance}.

It has just been demonstrated that keeping cached cycle lengths makes $\Delta
r_\ell$ computations for a Metropolis proposal quicker.  Of course, one pays
for this by needing to maintain cached cycle lengths after Metropolis updates.
The following steps are performed in the subroutine \texttt{update\_cycinfo}.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics{figures/update_cycinfo_split.eps}
\caption[Update of permutation and cycle information on a cycle split.]
	{Update of permutation and cycle information on a split swap.  Grey
	arrows represent pointers between sites and their cycle-information
	structures; black arrows represent forward permutation pointers.
	\label{fig:update_cycinfo_split}}
\end{center}
\end{figure}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics{figures/update_cycinfo_merge.eps}
\caption[Update of permutation and cycle information on a cycle merge.]
	{Update of permutation and cycle information on a merge swap.  Grey
	arrows represent pointers between sites and their cycle-information
	structures; black arrows represent forward permutation pointers.
	\label{fig:update_cycinfo_merge}}
\end{center}
\end{figure}

If the swap has split a cycle into two (figure
\ref{fig:update_cycinfo_split}):

	\begin{itemize}

	\item To minimize the number of computations, as described above for
	Metropolis proposals, find the shorter new cycle.  Suppose $\vecx$'s new
	cycle is longer than $\vecy$'s.  (If not, swap local variables in the
	subroutine to make this so.)

	\item All points in $\vecy$'s new cycle must now point to a new
	cycle-information structure.  The cycle has been split, so follow from the
	new $\pi'(\vecy)$ (which was $\pix$ before the merge) around to and
	including $\vecy$.  As above, the number of sites that must be visited is
	$\min\{\ell_\vecx(\pi'), \ell_\vecy(\pi')\}$.

	\item The cycle-information structures for both split cycles need to have
	their cycle lengths updated: $\ellxpiprime = \ellyxpi$ and $\ellypiprime =
	\ellxypi$.

	\item The cycle-information structures for the two cycles need to have
	their site pointers point to $\vecx$ and $\vecy$, respectively.

	\item The new cycle-information structure for the $\vecy$ cycle must be
	added to the doubly linked list of cycle-information structures.

	\end{itemize}

If\index{split}\index{merge}\index{cycle split}\index{cycle merge} the swap has
merged two cycles into one (figure \ref{fig:update_cycinfo_merge}):

	\begin{itemize}

	\item To minimize the number of computations, find the shorter old cycle.
	Suppose $\vecx$'s old cycle is longer than $\vecy$'s.  (If not, swap local
	variables in the subroutine to make this so.)

	\item The cycle-information structure for the merged cycle needs to have
	its cycle length updated:  $\ellxpiprime = \ellxpi + \ellypi$.

	\item All points in $\vecy$'s old cycle must have their
	cycle-information structures now point to $\vecx$'s cycle-information
	structure.  The two cycles have been merged, though, so follow from the new
	$\pi'(\vecx)$ (which was $\pi(\vecy)$ before the merge) around to and
	including $\vecy$.  As above, the number of sites that must be visited is
	$\min\{\ell_\vecx(\pi), \ell_\vecy(\pi)\}$.

	\item The cycle-information structure for the old $\vecy$ cycle must be
	removed from the cycle-information list and freed.

	\end{itemize}

%% ----------------------------------------------------------------
\section{Thermalization detection}
\label{sec:thermalization}

As noted in section \ref{sec:sw_overview}, the initial permutation selected in
an MCMC sequence is atypical:  the identity permutation has zero energy, lower
than the mean energy for the stationary distribution, whereas a uniform-random
permutation almost always has energy higher than the mean due to its long jump
lengths.  (See equation \eqref{eqn:RCM_H_rell_V}and figure
\ref{fig:thermo_plot}.)

As always in MCMC simulations \cite{bib:berg,bib:landaubinder}, one must run
through some number of Metropolis steps until the system has
\plainidx{thermalized}, i.e.  when the stationary distribution has been
reached.  In the MCMC discipline, practitioners use various techniques.  The
thermalization-detection algorithm chosen for the work described by this
dissertation counts \plainidx{turning points} of \plainidx{smoothed system
energy}.  This algorithm may be justified using conditional expectation of
$\Delta H$, as well as visually.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.70]{figures/thermo_plot.eps}
\caption[Thermalization detection.]
	{Plot of system energy versus Metropolis sweep number.  The transition from
	grey to black indicates thermalization was detected, via 40 turning points
	of energy smoothed over a sliding window of 200 sweeps.
	\label{fig:thermo_plot}}
\end{center}
\end{figure}

Recall from chapters \ref{chap:model_defns} and \ref{sec:SO_Markov_matrix} that
permutations have energies $H(\pi)$ and $H(\pi')$, probabilities $P(\pi) =
e^{-H(\pi)}/Z$ and $P(\pi') = e^{-H(\pi')}/Z$, and Metropolis transition
probabilities
$$
	M(\pi,\pi') = 1 \wedge e^{-(H(\pi')-H(\pi))}.
$$
The premise is that a permutation $\pi$ is taken from the stationary
distribution if the subsequent permutation $\pi'$ is equally likely to have
higher or lower energy.  Stated probabilistically, we say that the expected
value of $H(\pi')$, conditioned on transitioning from $\pi$, should be zero.
Recall that for a random variable $X$ and an event $A$, with outcomes $x$, we
have
\begin{align*}
	\bbE[f(X) \mid X \in A]
	&= \frac{
		\ds{\sum_{x\in A}} P(x) f(x)
	}{
		\ds{\sum_{x\in A}} P(x)
	}
%
	= \frac{
		\ds{\sum_{x\in A}} P(x) f(x)
	}{
		P(A)
	}.
\end{align*}
Here, this translates to
\begin{align*}
	\bbE[ H(\pi') \mid \pi ]
	&= \frac{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi') H(\pi')
	}{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi')
	}
%
	= \frac{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi) M(\pi,\pi') H(\pi')
	}{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi) M(\pi,\pi')
	}
\end{align*}
\begin{align*}
%
	&= \frac{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi) M(\pi,\pi')
		(H(\pi) + \Delta H)
	}{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi) M(\pi,\pi')
	}
\end{align*}
\begin{align*}
%
	&= \frac{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi) M(\pi,\pi') H(\pi) +
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi) M(\pi,\pi') \Delta H
	}{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi) M(\pi,\pi')
	}
\end{align*}
\begin{align*}
%
	&= H(\pi) +
	\frac{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi) M(\pi,\pi') \Delta H
	}{
		\ds{\sum_{\pi' \ctdto \pi}} P(\pi) M(\pi,\pi')
	}.
\end{align*}
(Recall from definition \ref{defn:R_pi_and_ctdto} that the sum over $\pi'
\ctdto \pi$ includes all permutations $\pi'$, including $\pi$ itself, reachable
from an accepted or rejected swap.) For pre-thermalization $\pi$, this
expectation should be highly positive (when the initial $\pi_1$ is the
identity), or highly negative (when the initial $\pi_1$ is uniform-random).
For post-thermalization $\pi$, this expectation should be approximately zero.
Alternatively, for various post-thermalization $\pi$, this expectation should
be equally likely positive or negative.  As discussed in section
\ref{sec:SO_Markov_matrix}, given $\pi$, there are $3N+1$ choices of $\pi'$
(including $\pi$ itself) which could be reached on a swap.  Yet, in the MCMC
sequence, only one $\pi'$ is chosen.  Thus, this conditional expectation is
CPU-intensive to compute, and moreover does not take advantage of the MCMC
sequence itself.

We estimate the above conditional expectation by first defining
\begin{align*}
	H_S(t) &= \frac{1}{S} \sum_{i=0}^{S-1} H(\pi_{t-i}),
\end{align*}
where $S$ is the \emphidx{smoothing window size} and $t$ denotes a Metropolis
sweep counter with $t\ge S$.  That is, the system energy at Metropolis sweep
$t$ is averaged over the last $S$ sweeps.  The system is deemed to be
thermalized when $H_S(t)$ has changed sign sufficiently many times, i.e. when
$H_S(t)$ has had more than a threshold number of \plainidx{turning points}.

As is typically the case in such matters, rigorously determining the
\plainidx{spectral gap} in the Markov transition matrix is computationally
intractable.  One relies instead on heuristics which are justified by the
practitioner's experience and all available evidence.  Visually examining the
plot in figure \ref{fig:thermo_plot}, one may decide that thermalization has
occurred by, say, Metropolis sweep 300.  Examining a plot for different $L$,
$T$, and interaction strength, one might choose a different Metropolis sweep
count.  I have examined such plots over a broad range of parameter values; I
have chosen $S=200$ and threshold number of turning points equal to $40$,
ensuring that the automated thermalization detection (when grey turns to black
in figure \ref{fig:thermo_plot}) agrees with my visual judgment.
Thermalization takes one percent or less of total CPU time, as shown in the
caption of figure \ref{fig:thermo_time_plot}.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.70]{../tests/fss3a/data/graph_rell_alpha0_0.000_Ntherm.eps}
\caption[Thermalization time as a function of $L$ and $T$.]
	{Thermalization time as a function of $L$ and $T$, for $\alpha=0$.  Plots
	for other $\alpha$ are similar.  Data accumulation takes $10^5$ or $10^6$
	sweeps; thermalization is here seen to take on the order of $10^3$ sweeps,
	i.e. a fraction of a percent of CPU time.
	\label{fig:thermo_time_plot}}
\end{center}
\end{figure}

% Include plots of some other RVs, for idinit and randinit, for
% comparison?  Point:  $H$ is an acceptable choice.

%% ----------------------------------------------------------------
\section{Computation of random variables}
\label{sec:compute_RVs}

All the random variables described in chapter \ref{chap:RV_theory} are computed
in \texttt{mcrcm}.  Details of each are described in the sections following
this one.  The software architecture of \texttt{mcrcm} is such that it is easy
to add a newly invented random variable to the code.

%% ----------------------------------------------------------------
\section{Computation of system energy}
\label{sec:comput_HDV}

The system energy $H$, with non-interacting terms $D$ and interacting terms $V$
(as defined in chapter \ref{chap:model_defns}), is tracked; one easily scales
to obtain the \plainidx{energy per site} (or \plainidx{energy density})
$h=H/N$, $d=D/N$, and $v=V/N$.

As described in section \ref{sec:sw_init}, system energy $H$ is computed for
the initial permutation.  As described in section \ref{sec:metro_sweep},
$\Delta H$ (split out into $\Delta D$ and $\Delta V$) is computed for a
proposed new permutation; if the proposal is accepted, $H$ is replaced by
$H+\Delta H$.  As described in section \ref{sec:sw_check}, optional automated
checks verify that the accumulated $\Delta H$ computations (chapter
\ref{chap:Delta_H}) correctly track the true system energy.

A plot of $H$ as a function of Metropolis sweep, within a single invocation of
\texttt{mcrcm}, is shown in figure \ref{fig:thermo_plot} on page
\pageref{fig:thermo_plot}.  Dependence of $H$ on $L$, $T$, and $\alpha$ is
shown in figure \ref{fig:mean_H_LTa}.  Note that the system energy, as
centrally important as it is, does not function as an order parameter (section
\ref{sec:ordps}):  it exhibits no sharp transition near the critical
temperature.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.000_H.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.002_H.eps}
\caption[Behavior of $H$ as function of $L$ and $T$.]
	{Behavior of system energy $H$ as function of $L$ and $T$, for
	$\alpha=0$, $0.002$.
	\label{fig:mean_H_LTa}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Computation of $r_\ell(\pi)$}
\label{sec:comput_rell}

Given the cycle-information list as described in sections
\ref{sec:sw_data_structures} and \ref{sec:metro_step}, it is trivial to compute
the cycle-length occupation numbers $r_\ell(\pi)$ for $\ell=1$ to $N$.  Namely:
Set $r_1, \ldots, r_N = 0$.  For each cycle in the cycle list, increment
$r_\ell$ by 1 where $\ell$ is the length of the current cycle.  Dependence of
the sample mean of $r_2$ as a function of $L$, $T$, and $\alpha$ is shown in
figure \ref{fig:mean_r2_LTa}.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.000_r2.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.002_r2.eps}
\caption[Behavior of $r_2$ as function of $L$ and $T$.]
	{Behavior of $r_2$ as function of $L$ and $T$, for $\alpha=0$,
	$0.002$.
	\label{fig:mean_r2_LTa}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Computation of cycle lengths and correlation length}
\label{sec:comput_cyclen_corrlen}

Given\index{cycle length}\index{correlation length} the lattice data structure
as described in section \ref{sec:sw_data_structures}, one easily computes the
the spatial cycle lengths $s_\vecx(\pi)$ defined in section
\ref{sec:theory_cyclen_corrlen}.  For each site $\vecx$ in the lattice
$\Lambda$, one examines the cached \texttt{fwd\_d} attribute, which is
precisely $s_\vecx(\pi)$.  As described in section
\ref{sec:theory_cyclen_corrlen}, the correlation length $\xi$ is the spatial
cycle length averaged over all $N$ lattice points.  Plots and analysis of the
order parameter $1/\xi$ may be found in chapter \ref{chap:results}.

%% ----------------------------------------------------------------
\section{Computation of mean and maximum jump length}
\label{sec:comput_mjl}

Mean jump length\index{mean jump length} is as defined in section
\ref{sec:theory_mjl}.  The \plainidx{maximum jump length} is the largest jump
length encountered at any of the $N$ lattice sites, for any of the $M$
permutations in the MCMC sequence.  This confirms the hypothesis
of\index{short-jump-length regime} short jump lengths as mentioned in section
\ref{sec:theory_wno}.  See figure \ref{fig:mean_max_jump_len_LTa}.  As
discussed in section \ref{sec:theory_cyclen_corrlen}, the jump length is
averaged not only over all permutations $\pi$ generated in the MCMC sequence,
but moreover is averaged over all $N$ lattice points for each $\pi$.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.000_jumplenbar.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.002_jumplenbar.eps}

\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.000_max_jump_len.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.002_max_jump_len.eps}
\caption[Mean and maximum jump lengths.]
	{Mean and maximum jump length as function of $L$ and $T$, for
	$\alpha=0$, $0.002$.
	\label{fig:mean_max_jump_len_LTa}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Computation of $f_I$}
\label{sec:comput_fI}
%For each, xref bwd to RV section, and have that section xref fwd.

As\index{$f_I$} discussed in section \ref{sec:theory_fI}, $f_I$ is computed
using the vertical intercept of a tangent-line approximation to $\bbE[f_{1,k}]$
as a function of $k/N$.

Computation of $\bbE[f_{1,k}]$ as a function of $k$ is straightforward:  we
maintain an array indexed from 1 to $N$ of counters, all initially set to zero.
For each permutation $\pi$, we count the number of sites participating in
cycles of length $k$.  This is directly obtained from the cycle-information
structure (see section \ref{sec:sw_data_structures}).  Scaling this array by
$1/N$ yields a finite-sample approximation to $\bbE[f_{k,k}]$.  Cumulatively
summing the array gives an estimator of $\bbE[f_{1,k}]$.  See figure
\ref{fig:fIplot}.

Given that, the tangent line is found, in the presence of statistical
variability, as follows:  subtract off the diagonal line $(k/N,k/N)$ which runs
from the lower left corner to the upper right corner.  The peak of the
difference (the dashed line in figure \ref{fig:fIplot}) shows the outermost
point of the original $\bbE[f_{1,k}]$ estimator.  Then the tangent line is
taken to have slope 1 running through this point.  As the number $M$ of
permutations increases, this outermost point adheres closely to the visible
diagonal; its location is defined by its peers.  Thus, we are not computing
$f_I$ based on a single, noisy data point, but rather using much of the
available $\bbE[f_{1,k}]$ data.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.8]{figures/fIplot.eps}
\caption[Estimation of $f_I$.]
	{Estimation of $f_I$.  The dotted line shows raw $\pig{f_{1,k}}_M$ data
	obtained by cumulatively summing an array of sample averages of
	$f_{k,k}(\pi)$.  The dashed line is the dotted line minus the diagonal
	$(k/N,k/N)$.  The abscissa of the peak of this difference is the abscissa
	of the outermost point of the dotted line.  The tangent line is drawn
	through there, with slope 1.  Then $f_I$ is one minus the vertical
	intercept of that tangent line:  in this case, $f_I = 1-0.825 = 0.175$.
	The simulation used an MCMC run of $10^4$ permutations on $L=20$ at
	$T=6.5$.
	\label{fig:fIplot}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Computation of $\ellmax$, $\fM$, and macroscopic-cycle quotient}
\label{sec:comput_lmax_GRU_quot}

The quantities $\ellmax$, $\fM$, $f_I$, and macroscopic-cycle quotient
$\fM/f_I$ were defined in sections \ref{sec:theory_fI} and
\ref{sec:theory_lmax_GRU_quot}.  It is easy to compute $\ellmax$: find the
longest cycle in the cycle-information list (section
\ref{sec:sw_data_structures}).  Computation of $f_I$ is found as described in
section \ref{sec:comput_fI}.

Figure \ref{fig:r_small_and_lmax}
makes clear the difference between subcritical and
supercritical behavior which was alluded to in section
\ref{sec:qual_long_cycles}.  Below $T_c$, $r_1$, $r_2$, etc. are smaller than
above $T_c$, since there is occasionally a long cycle: $\ellmax$ is markedly
higher below $T_c$.
Plots and analysis of the order parameter $\fM$ may be found in chapter
\ref{chap:results}.  The macroscopic-cycle quotient is analyzed in section
\ref{sec:mcq_const}.

\begin{figure}[!htb]
\begin{center}
\includegraphics[scale=0.70]{figures/r_small_T_6.0.eps}
\includegraphics[scale=0.70]{figures/r_small_T_7.0.eps}

\includegraphics[scale=0.70]{figures/lmax_T_6.0.eps}
\includegraphics[scale=0.70]{figures/lmax_T_7.0.eps}
\caption{Per-realization values of $r_\ell$ and $\ellmax$,
	$L=20$, $T=6.0, 7.0$.
	\label{fig:r_small_and_lmax}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Computation of winding numbers, $f_S$, and $f_W$}
\label{sec:comput_wno}

The\index{$f_S$}\index{$f_W$} winding-number triple $\vecW=(W_x,W_y,W_z)$ is as
defined in section \ref{sec:theory_wno}.  Straightforward application of
equations \eqref{eqn:def_wno} and \eqref{eqn:def_W2}, for $\vecW$ and
$\vecW^2$, respectively, are sufficient as long as the difference vectors
$\torusdiff(\vecx, \vecy)$ are obtained.  For these (see also section
\ref{sec:torus_diff_and_dist}) one first computes the difference $\vecx-\vecy$.
Then, for each of the three coordinate slots, one adds or subtracts multiples
of $L$ until the result is between $-L/2$ and $L/2$.  In figure
\ref{fig:Wx_histo} one observes the even parity of winding-number components,
as discussed in section \ref{sec:wno_SAR}.  As well, the temperature dependence
in the histograms shows the subcritical transition to winding cycles.  Plots
and analyses of the order parameters $f_S$ and $f_W$ may be found in chapter
\ref{chap:results}.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_Wx_histo_T_6.70.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_Wx_histo_T_6.80.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_Wx_histo_T_6.85.eps}
\caption{Histograms of $W_x$ for $\alpha=0$ and $T=6.70$, $6.80$, $6.85$.
	\label{fig:Wx_histo}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Computation of integrated autocorrelation times}
\label{sec:comput_tauint}

Integrated autocorrelation times\index{integrated autocorrelation time} are
estimated precisely as described in sections \ref{sec:c_hat} through
\ref{sec:estimate_meanvar} of appendix \ref{appx:eta}.  Error bars in
order-parameter plots in this dissertation are the $\tauint$-corrected sample
standard deviations of the sample means.

Some estimated integrated autocorrelation times are shown in figure3
\ref{fig:tauint_LTa}.  The key point is that uncertainty increases in the
critical region.  For this reason, simulations in the critical region were run
with $10^6$ Metropolis sweeps for $L=30,40,50$, and with $10^5$ sweeps
otherwise.  Similarly, figure \ref{fig:eta_LTa} shows estimates of the
correlation factors $\eta$ , in the context of appendix \ref{appx:eta}.
Namely, $\eta=0$ yields an IID sequence; $\eta$ for MCMC simulations done in
this dissertation are typically $0.99$ and above, indicating highly
autocorrelated MCMC sequences.

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.000_tauint_H.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.002_tauint_H.eps}

\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.000_tauint_lmax.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.002_tauint_lmax.eps}
\caption[Estimated integrated autocorrelation times of $H$ and $\ellmax$.]
	{Estimated integrated autocorrelation times of $H$ and $\ellmax$ as
	functions of $L$ and $T$, for $\alpha=0$ and $0.002$.
	\label{fig:tauint_LTa}}
\end{center}
\end{figure}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.000_eta_H.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.002_eta_H.eps}

\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.000_eta_lmax.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.002_eta_lmax.eps}
\caption[Estimated autocorrelation factor of $H$ and $\ellmax$.]
	{Estimated autocorrelation factor of $H$ and $\ellmax$ as functions
	of $L$ and $T$, for $\alpha=0$ and $0.002$.
	\label{fig:eta_LTa}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Consistency checks}
\label{sec:sw_check}

The\index{consistency checks} following checks are run for every MCMC
simulation described in this dissertation:

	\begin{itemize}
	\item Interaction type is one of none, two-cycle interactions, $r_\ell$
		(Ewens) interactions.  This protects against uninitialized variables.
	\item Worm move is one of open, close, head swap, or tail swap.
		Again, this protects against uninitialized variables.
	\item $L\ge 1$; $d=1,2,3$.
	\item The cycle-information list is never empty when a cycle-information
		structure is removed (e.g. on a merge).
	\end{itemize}

The following checks are omitted from production runs due to their CPU-time
expense, but were run during code development and testing:

	\begin{itemize}

	\item \texttt{check\_H}:  As described in sections \ref{sec:sw_init} and
	\ref{sec:metro_step}, the system energy is initially computed by
	\texttt{get\_H\_of\_pi}, then updated by $\Delta H$ as computed in
	Metropolis proposals/updates.  If $H$-checking is enabled (in the header
	file \texttt{checks.h}), then after every Metropolis sweep, the system
	energy is computed by brute force, and is verified to be within roundoff
	error of the system energy which has been tracked by $\Delta H$
	computations.

	\item \texttt{sanity\_check\_cycinfo\_list}:  This is also enabled in the
	header file \texttt{checks.h}.  It consists of three checks, which are run
	after every Metropolis sweep: (1) The cycle list partitions the lattice
	sites.  All sites are marked unvisited; all cycles in the cycle-information
	list are followed, with visits to each site counted; each site is checked
	to have been visited no more and no less than once.  (2) The cached cycle
	lengths are correct:  These are verified by following permutation pointers
	around each cycle.  (3) For each cycle, all points in the cycle are
	verified to point to the same cycle-information structure.

	\end{itemize}

The following visual checks were done for selected single runs:

	\begin{itemize}
	\item $H$ plots, such as figure \ref{fig:thermo_plot} of section
	\ref{sec:thermalization} should show system energy increasing from 0 up to
	equilibrium for initial identity; decreasing down to equilibrium for
	initial uniform-random.
	\end{itemize}

Visual checks for single runs:

	\begin{itemize}
	\item Output from \texttt{mcrcm}, as shown in section
		\ref{sec:MCMC_output}, looks sane; numbers appear to be
		in their normal ranges.
	\item $\pigm{f_{1,k}}$ plots, as shown in section \ref{sec:comput_fI},
		are as usual.
	\item $f_W$, $\fM$, and $f_I$ are between 0 and 1.
	\item Sample mean of $\sum_{\ell=1}^N \ell r_\ell$ is equal to
		$N$.  (This is \texttt{k*counts sum} in the MCMC output, as described
		in section \ref{sec:MCMC_output}.)
	\item Sample mean of energy density $h$ is of order 1.
	\item Mean jump length is of order 1; maximum jump length is
		approximately 3-4.
	\item Winding-number histogram peaks at $W_x=0$, with population out
		to perhaps $\pm 6$ depending on system temperature.
	\item Metropolis acceptance rate is $10$ to $20$ percent.
	\end{itemize}

Visual checks for runs over parameter values (chapter \ref{chap:scripts}):
	\begin{itemize}
	\item A 30-page file containing all plots of the form shown in this
		chapter --- not just a representative selection --- is used to compare
		random-variable output to results from before a software change.
	\end{itemize}

Automated software checking\index{software-development environment}:
	\begin{itemize}

	\item All source code is compiled with \texttt{gcc -Wall -Werror}.  This
	enables all warnings (e.g. unused variables, reading variables before they
	are initialized, missing arguments to \texttt{printf}, and so on), and
	treats warnings as fatal compilation errors.

	\item The open-source \texttt{valgrind} tool finds, at run time, many (but
	certainly not all) common programming errors.  These include reading or
	writing off the end of arrays, continuing to use dynamically allocated
	memory after it is freed, dynamically allocated memory which is not freed,
	and reading of uninitialized variables.

	\item The open-source \texttt{gprof} tool tabulates in which subroutines
	CPU time is being spent.  This helps to identify inefficient programming.
	See also the \texttt{gprof} output in section \ref{sec:tools}.

	\end{itemize}

%% ----------------------------------------------------------------
\section{Saved realizations}
\label{sec:rzn_files}

The computer program described up to this point is called \texttt{mcrcm}, since
it does Markov chain Monte Carlo simulations for the random-cycle model.
As described in section \ref{sec:sw_overview}, it uses MCMC methods
to generate a sequence of permutations, accumulating sums of various
random variables along the way, in order to display statistics of those
random variables at the end.

A key software-optimization insight was offered by Volker Betz.  Namely, the
MCMC steps are time-consuming, so one might optionally wish to have
\texttt{mcrcm} write the sequence of realized permutations to a disk file.
Then, another program can simply read those permutations --- quicker than they
were generated using MCMC methods --- and compute random variables.  This is
particularly advantageous in a shoulder-to-shoulder collaboration environment:
when one invents a new random variable to compute, one need not re-realize
another sequence of permutations.

The trade-off is that a single realization file can be quite large.
Specifically, $M$ permutations are stored.  For each permtuation, 3 bytes are
stored for each of $N$ lattice sites $\vecx_i$:  these are the $x$, $y$, and
$z$ coordinates of $\pi(\vecx_i)$.  The realization file contains a header and
a footer of negligible size (a few bytes each).  Thus, it totals $3ML^3$ in
size --- for example, 240 MB for $L=20$ and $M=10^4$, and one would likely want
several such files for different values of $L$, $T$, and/or $\alpha$.  One
might, of course, develop more clever storage representations which reduce the
necessary file size.

This second program is called \plainidx{\texttt{rvrcm}}, since it computes
random variables for the random-cycle model.  By default, \texttt{mcrcm} does
not store realization files:  they occupy several megabytes for each run,
totalling several gigabytes for a run through a set of parameters (chapter
\ref{chap:scripts}).  If desired, however, one invokes \texttt{mcrcm} with an
extra command-line argument \texttt{rzn=}\emph{myfile}\texttt{.rzn}.  Later,
one invokes simply \texttt{rvrcm rzn=}\emph{myfile}\texttt{.rzn}.  The
\texttt{.rzn} file contains a header with all control parameters which were
initially supplied to \texttt{mcrcm}.  The \texttt{rvrcm} program prints the
same information as described in section \ref{sec:MCMC_output}.

For example:
\begin{verbatim}
mcrcm L=20 T=6.4 rell alpha0=0.2 rzn=experiment.rzn
rvrcm rzn=experiment.rzn
\end{verbatim}

A \texttt{.rzn} file consists of three parts: The \plainidx{header} contains
all control parameters, e.g. $L$, $T$, interaction type, etc.  The
\plainidx{footer} contains elapsed time spent in \texttt{mcrcm} as well as
Metropolis statistics, i.e. acceptance rate for Metropolis proposals.  In
between is a sequence of permutation realizations.

%% ----------------------------------------------------------------
\section{MCMC output}
\label{sec:MCMC_output}

Outputs from \texttt{mcrcm} fall into two categories: (1) sample statistics of
random variables, which are always printed; (2) per-realization values of
specified random variables, which are optionally printed.

Each invocation of \texttt{mcrcm} prints information such as the following.
For interactive use, one views these data on-screen, or may send them to a
printer.  When running through a set of parameters, typically this output is
redirected to a self-descriptive filename, e.g.
\texttt{L\_80\_T\_6.7\_alpha\_0.000.txt}, as described in chapter
\ref{chap:scripts}.

\begin{verbatim}
# RNG = Mersenne twister
# L = 80 d = 3 N = 512000
# Boundary conditions: periodic.
# T =   6.7000000 beta =   0.1492537 alpha0 =   0.0000000
# gamma =   0.0500000
# Interactions:  constant r_ell.
# Initial permutation: identity.
# Site selection for Metropolis sweeps: sequential.
# Thermalization is detected by 40 turning points of system energy
# smoothed over a 200-point window.
# Terminate after 100000 accumulations:
# * 1 SAR  sweep per accumulation.
# * 0 worm sweeps per accumulation.
#
# Initial HDV =   0.0000000   0.0000000   0.0000000
# Sweep 0 HDV = 54809.3500000 54809.3500000   0.0000000
# Thermalization complete:  sweep   1778 H = 359840.2499997
# Ntherm =   1778
# Accumulation complete:  acc 100000 H = 373669.0499998
#
# rho_infty max dev =   0.9140418 at k = 21976
# fI                           =    0.0859582
#
# k=  1 <counts> 339457.4268600
# k=  2 <counts> 27347.3173400
# k=  3 <counts> 5740.3265700
# k=  4 <counts> 2631.4549600
# k=  5 <counts> 1342.3165500
# k=  6 <counts> 804.4376700
# k=  7 <counts> 512.2292200
# k=  8 <counts> 351.5231700
# k=  9 <counts> 252.2729800
# k= 10 <counts> 188.1364500
# k*counts sum                 = 512000.0000000
#
# fM                           =    0.0537150
# fM/fI                        =    0.6248961
#
# mean_H                       = 371597.3002873
# stddev_H                     = 1701.6752760
# tauint_H                     =  481.1931762
# eta_H                        =    0.9958523
# cssm_H                       =  118.0419619
#
# mean_D                       = 371597.3002873
# mean_V                       =    0.0000000
# mean_h                       =    0.7257760
# mean_d                       =    0.7257760
# mean_v                       =    0.0000000
#
# mean_r2                      = 27347.3173400
# stddev_r2                    =  172.6096035
# tauint_r2                    =  163.4730368
# eta_r2                       =    0.9878400
# cssm_r2                      =    6.9789168
#
# mean_lmax                    = 27502.0656900
# stddev_lmax                  = 8577.6258591
# tauint_lmax                  =    6.0556505
# eta_lmax                     =    0.7165392
# cssm_lmax                    =   66.7494207
#
# mean_jumplenbar              =    0.3754422
# stddev_jumplenbar            =    0.0015945
# maxjumplen                   =    3.7416574
#
# mean_ellbar                  = 1893.6137332
# stddev_ellbar                =  821.5275072
# tauint_ellbar                =   12.1998395
# eta_ellbar                   =    0.8484830
# cssm_ellbar                  =    9.0740082
#
# mean_recipmeanspatlen        =    0.0005406
# stddev_recipmeanspatlen      =    0.0002356
# tauint_recipmeanspatlen      =   38.0712869
# eta_recipmeanspatlen         =    0.9488115
# cssm_recipmeanspatlen        =    0.0000046
#
# mean_wno                     =   20.3278800
# stddev_wno                   =   16.5433065
#
# mean_fS                      =    0.5674866
# stddev_fS                    =    0.4618340
# tauint_fS                    =    3.5586073
# eta_fS                       =    0.5612695
# cssm_fS                      =    0.0027550
# recip_fS                     =    1.7621560
#
# mean_fW                      =    0.0810994
# stddev_fW                    =    0.0082444
# tauint_fW                    =  155.0150517
# eta_fW                       =    0.9871807
# cssm_fW                      =    0.0003246
# recip_fW                     =   12.3305479
#
# Wx < -10:         1 /  100000 = 0.00001000
# Wx = -10:        14 /  100000 = 0.00014000
# Wx =  -9:         0 /  100000 = 0.00000000
# Wx =  -8:       233 /  100000 = 0.00233000
# Wx =  -7:         0 /  100000 = 0.00000000
# Wx =  -6:      2195 /  100000 = 0.02195000
# Wx =  -5:         0 /  100000 = 0.00000000
# Wx =  -4:      9496 /  100000 = 0.09496000
# Wx =  -3:         0 /  100000 = 0.00000000
# Wx =  -2:     22900 /  100000 = 0.22900000
# Wx =  -1:         0 /  100000 = 0.00000000
# Wx =   0:     30423 /  100000 = 0.30423000
# Wx =   1:         0 /  100000 = 0.00000000
# Wx =   2:     22919 /  100000 = 0.22919000
# Wx =   3:         0 /  100000 = 0.00000000
# Wx =   4:      9341 /  100000 = 0.09341000
# Wx =   5:         0 /  100000 = 0.00000000
# Wx =   6:      2196 /  100000 = 0.02196000
# Wx =   7:         0 /  100000 = 0.00000000
# Wx =   8:       261 /  100000 = 0.00261000
# Wx =   9:         0 /  100000 = 0.00000000
# Wx =  10:        19 /  100000 = 0.00019000
# Wx >  10:         2 /  100000 = 0.00002000
# Wx_min    =     -12
# Wx_max    =      12
#
# OPENS:
#   None.
# CLOSES:
#   None.
# HS:
#   None.
# TS:
#   None.
# GK:
#   Metropolis keeps:   44596819174 / 51200000000 ( 87.103%)
#   Metropolis changes: 6603180826 / 51200000000 ( 12.897%)
# Elapsed thermalization seconds: 302.841613
# Elapsed accumulation   seconds: 136966.313018
# Elapsed total seconds:          137269.154631
\end{verbatim}

In addition to the above sample statistics, per-realization values of specified
random variables may also be printed.  A full list of options may be found by
invoking \texttt{mcrcm --help}.  For example, \texttt{mcrcm hv=1} (i.e. $H$
verbosity is set to 1, rather than its default value of 0) results in the
following output:

\begin{verbatim}
# RNG = Mersenne twister
# L = 10 d = 3 N = 1000
... (header information is similar to the previous example)
# Initial HDV =   0.00000   0.00000   0.00000
# Sweep 0 HDV = 132.60000 132.60000   0.00000
    0 132.60000 132.60000   0.00000 132.60000   0.00000 # 0 H D V
    1 190.40000 190.40000   0.00000 161.50000   0.00000 # 0 H D V
   ... (many per-realization values omitted for brevity)
  597 629.00000 629.00000   0.00000 603.73065   0.00000 # 0 H D V
  598 632.40000 632.40000   0.00000 603.73065   0.00000 # 0 H D V
  599 642.60000 642.60000   0.00000 603.73065   0.00000 # 0 H D V
# Thermalization complete:  sweep    600 H = 642.6000000
  600 598.40000 598.40000   0.00000 598.40000 598.40000 # 1 H
  601 591.60000 591.60000   0.00000 591.60000 591.60000 # 1 H
  602 581.40000 581.40000   0.00000 581.40000 581.40000 # 1 H
   ... (many per-realization values omitted for brevity)
 1597 581.40000 581.40000   0.00000 581.40000 581.40000 # 1 H
 1598 578.00000 578.00000   0.00000 578.00000 578.00000 # 1 H
 1599 595.00000 595.00000   0.00000 595.00000 595.00000 # 1 H
# Accumulation complete:  acc 1000 H = 372745.0766667
#
# rho_infty max dev =   0.9471790 at k = 27
# fI                           =    0.0528210
... (statistical output as in the previous example)
# Elapsed thermalization seconds: 0.241671
# Elapsed accumulation   seconds: 0.477683
# Elapsed total seconds:          0.719354
\end{verbatim}

Notice that all the sample statistics are printed as before, on lines which
start with a pound sign.  In addition, since $H$ verbosity was requested,
non-pound-sign lines show Metropolis sweep number, $H$, $D$, $V$, smoothed $H$
(see section \ref{sec:thermalization}), and thermalization flag times smoothed
$H$.  With pound-sign lines stripped out or ignored, a graphing utility can
then be used to produce a plot such as that shown in figure
\ref{fig:thermo_plot} on page \pageref{fig:thermo_plot}.

%% ----------------------------------------------------------------
\section{Pseudorandom numbers}
\label{sec:rng}

The default pseudorandom-number generator (``\plainidx{RNG}'') is the Mersenne
Twister \cite{bib:mersenne}.  One may instead select, at compile time via
\texttt{rcmrand.h}, \texttt{rand48} (of lower quality than Mersenne twister),
Linux \texttt{/dev/urandom} (slower than Mersenne twister), or \texttt{psdes}
from Numerical Recipes \cite{bib:nr}.

%% ----------------------------------------------------------------
\section{Tools}
\label{sec:tools}

\begin{itemize}
\item Linux environment, although\index{software-development environment}:
	in principle everything other than use of \texttt{/dev/urandom} should be
	portable to other operating systems.
\item Optimizing compiler with full warnings enabled:
	\texttt{gcc -O3 -Wall -Werror}.
\item Build tool: \texttt{make} and automatic makefile generation.
\item Performance analyzer: \texttt{gprof}.  This shows where a program
	is spending most of its time.
\item Error detector: \texttt{valgrind}.  Finds many (but not all)
	common errors, e.g. \texttt{malloc} without \texttt{free}, or
	double \texttt{free}.
\item Code navigation:  \texttt{ctags}.  Allows a smart text editor (e.g.
	\texttt{vim}, \texttt{emacs}) to jump directly to a subroutine body.
\item Graphing utility, used for all plots in this dissertation:
	\texttt{pgr}, which is the author's Python script wrapped around
	\texttt{pylab.plot()}.
\end{itemize}

Sample \texttt{gprof} output:
\begin{verbatim}
%     cumul.self         self    total
time  secs. secs.  calls us/call us/call name
32.52 1.20  1.20     1500 0.80   1.41  SO_sweep
25.47 2.14  0.94 21597444 0.00   0.00  get_mtrand_double
 9.49 2.49  0.35     1500 0.23   0.51  U_sweep
 7.32 2.76  0.27     1000 0.27   0.27  get_pmt_winding_numbers
 5.15 2.95  0.19     1000 0.19   0.19  get_mean_cycle_length
 4.61 3.12  0.17 12000000 0.00   0.00  get_Delta_V_SO
 2.71 3.22  0.10 12000000 0.00   0.00  get_mtrand_int32
 2.71 3.32  0.10     1000 0.10   0.10  get_mean_jump_length
 2.44 3.41  0.09 12000000 0.00   0.00  find_dxy_dyx_xoy
 2.17 3.49  0.08     1000 0.08   0.14  get_rho_L_pi
 1.63 3.55  0.06     1000 0.06   0.06  pmt_get_cycle_counts_and_lmax
 ...
 ...
 0.00 3.69  0.00        1 0.00   0.00  report_metro_stats
 0.00 3.69  0.00        1 0.00   0.00  set_default_mcmc_params
 0.00 3.69  0.00        1 0.00   0.12  set_up_cycinfo_list
 0.00 3.69  0.00        1 0.00   0.00  therm_ctl_free
 0.00 3.69  0.00        1 0.00   0.00  therm_ctl_init
\end{verbatim}

What is being seen here:
\begin{itemize}
\item The \texttt{name} column shows the names of all subroutines invoked
during the execution of the program.
\item The \texttt{\% time} column shows the percent of total CPU time
spent in a given subroutine.  The output is sorted by decreasing order
of CPU time.
\item The self-seconds column shows the total wall time spent in the
given subroutine; the cumulative-seconds column shows total wall
time spent in the given subroutine and all those listed above it.
\item The \texttt{calls} column counts the number of invocations of the
subroutine.  This helps the programmer distinguish between a routine which is
time-consuming on each call, and a routine which is quick but perhaps overused.
\item The \texttt{self us/call} and \texttt{total us/call} columns displays the
mean and total number of microseconds spent in invocations to the subroutine.
\end{itemize}

%% ----------------------------------------------------------------
\section{Performance}
\label{sec:performance}

Memory requirements with $N=L^3$ points and $M=10^5$ sweeps, taken from the
\texttt{VSZ} field of a Linux \texttt{ps aux} listing, are shown in table
\ref{table:mem_reqts}.  A few hundred bytes are needed for each lattice point;
this scales linearly with $N$.  As well, for each random variable, the full
time series over all $M$ permutations in the MCMC sequence is saved.  This
scales linearly with $M$.

Figure \ref{fig:CPU_time_LTa} shows CPU times as a function of $L$, $T$, and
$\alpha$.  For $T$ near $T_c$ and $L=30,40,50$, in order to reduce variance in
the critical-slowdown regime, $10^6$ sweeps were performed.  The sawtooth
effect is due to the fact that simulations for a few initial values of $T$,
e.g. $T=6.74$, $6.76$, were performed in a different computing environment than
later simulations for more values of $T$ including $T=6.75$, $6.834$, etc.

\begin{table}[!htb]
$$
\begin{tabular}{|l||r|r|r|r|r|r|r|r|}
\hline $L$       & 10 & 20 & 30 & 40 & 50 &  80 & 100 &  200 \\
\hline Megabytes & 25 & 26 & 29 & 34 & 44 & 103 & 177 & 1243 \\
\hline
\end{tabular}
$$
\caption[Memory requirements.]
	{Memory requirements for \texttt{mcrcm} with $M=10^5$ and varying $L$.
	\label{table:mem_reqts}}
\end{table}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.000_CPU_time.eps}
\includegraphics[scale=0.6]{../tests/fss3a/disfigs/rv_comput_alpha0_0.002_CPU_time.eps}
\caption[CPU time as function of $L$, $T$, and $\alpha$.]
	{CPU time in seconds as function of $L$ and $T$, for $\alpha=0$,
	$0.002$.
	\label{fig:CPU_time_LTa}}
\end{center}
\end{figure}

\begin{figure}[!htb]
\begin{center}
\psfragscanon
\includegraphics[scale=0.65]{figures/sar_perf_large_L.eps}
\caption[Scalability of the SAR algorithm.]
	{Scalability of the SAR algorithm.  CPU times for $10^5$ sweeps are shown
	as a function of $N=L^3$ for $L=30$, $40$, $50$, $60$, $70$, and $80$.  SAR
	time is nearly linear in $N$.
	\label{fig:sar_perf_N}}
\end{center}
\end{figure}

As was discussed in section \ref{sec:metro_step}, most computations in our
simulations are $O(N)$, with an $O(N^2)$ component that has a small constant of
proportionality.  See figure \ref{fig:sar_perf_N} which substantiates this
claim.  See also section \ref{sec:worm_stopping_time} for a comparison of the
SAR algorithm with the worm algorithm.

%% ================================================================
\chapter{Batching of MCMC runs}
\label{chap:scripts}

As described in chapter \ref{chap:sw}, the C program \texttt{mcrcm} is given a
set of parameters as follows: $L$, $T$, interaction type and interaction
parameter $\alpha$, algorithm type (i.e. SO, SAR, band-update, or worm) and
number of sweeps.  Then a sequence of random permutations is generated, and
sample means of random variables are computed over that sequence.  The result
is, for example, that the system energy $H$ had sample mean $4939.7$ with
sample standard deviation $155.6$.

One wishes, however, to find patterns in such data.  In particular, as
described in chapter \ref{chap:results}: for various interactions $\alpha$, for
larger and larger $L$ permitting extrapolation to the thermodynamic limit, one
wishes to estimate the critical temperature $T_c$ at which various order
parameters (section \ref{sec:ordps}) have a point of non-analyticity in the
infinite-volume limit.

The \plainidx{C language} was chosen for \texttt{mcrcm}, due to its efficiency
for large-scale computations.  (Data sets discussed in this dissertation have
taken approximately 5.5 CPU-years; the choice of C has proved worthwhile, as
an early Python\index{Python language} implementation ran a factor of 40 times
slower.) For the relatively lightweight task of scheduling parallel-processing
tasks over multiple parameter values, extracting and collating sample
statistics of random variables, and viewing the results --- tasks for which the
CPU time is measured in minutes, at most --- it suffices to use easier-to-code
scripting languages such as Bash or Python.  Examples are shown in subsequent
sections.  The author has developed a flexible Python module,
\texttt{taskutil.py}, for automating most of the tasks described in this
chapter.  However, such content is non-mathematical, of dubious value to an
already lengthy mathematics dissertation.  Equivalent, but briefer and simpler,
scripting snippets in Bash will be shown instead.

%% ----------------------------------------------------------------
\section{Collecting data over multiple parameter values}
\label{sec:script_run}

Given a choice of parameter \texttt{nacc} (number of sweeps), and choices of
parameters $L$, $T$, and $\alpha$ as described in chapter
\ref{chap:model_defns}, a simple example of running \texttt{mcrcm} programs to
compute sample statistics of random variables is as follows:
\begin{verbatim}
nacc=100000
datadir=sar_nacc_${nacc}
Ls="40 60 80"
Ts="6.40 6.50 6.60 6.70 6.80 6.90 7.00 7.10 7.20"
alphas="0.000 0.001 0.002"
mkdir -p $datadir
for L in $Ls; do
    for T in $Ts; do
        for alpha in $alphas; do
            file=$datadir/L_${L}_T_${T}_rell_alpha_${alpha}.txt
            mcrcm L=$L T=$T rell alpha0=$alpha nacc=$nacc > $file
        done
    done
done
\end{verbatim}
For example, one of the loop iterations will execute the command
\begin{verbatim}
mcrcm L=40 T=6.70 rell alpha0=0.001 nacc=100000
\end{verbatim}
and direct the output (as described in section \ref{sec:MCMC_output})
to the file
\begin{verbatim}
sar_nacc_100000/L_40_T_6.70_rell_alpha_0.001.txt,
\end{verbatim}
the contents of which were shown in section \ref{sec:MCMC_output}.  In total,
81 such files will be produced.  Next one may wish to, say, select out only
the values of \texttt{mean\_fS} --- the sample mean of $f_S$ (sections
\ref{sec:theory_wno} and \ref{sec:comput_wno}) --- from all 81 files.

The author's \texttt{taskutil.py} module implements this basic idea, with
various elaborations.  For example, one might divide the 81 tasks into 3 tasks
for 27 processors each, with processors running in parallel.  One might also
wish to implement restart logic in case of unexpected downtime (e.g. due to a
thunderstorm), wherein the script sees if a given file has already been
completed rather than launching an already-completed task.

%% ----------------------------------------------------------------
\section{Extracting data over multiple parameter values}
\label{sec:script_extract}

Given a list of data files as described in the previous section,
one may wish to extract out a specified sample statistic for
a specified random variable.  A simple sample script which does this is
\begin{verbatim}
RV_name="mean_fS"
nacc=100000
datadir=sar_nacc_${nacc}
Ls="40 60 80"
Ts="6.40 6.50 6.60 6.70 6.80 6.90 7.00 7.10 7.20"
alphas="0.000 0.001 0.002"
for alpha in $alphas; do
    echo "alpha = $alpha"
    for L in $Ls; do
        for T in $Ts; do
            file=$datadir/L_${L}_T_${T}_rell_alpha_${alpha}.txt
            RV=`grep $RV_name $file | awk '{print $NF}'`
            echo $L $T $RV
        done
    done
    echo ""
done
\end{verbatim}

\begin{verbatim}
alpha = 0.000
40 6.40 1.0506240
40 6.50 0.8573933
...

alpha = 0.1
40 6.40 1.3394773
40 6.50 1.2505133
...
\end{verbatim}
Such output may be analyzed or plotted as desired.  Examples were shown
throughout chapter \ref{chap:sw}.

%% ----------------------------------------------------------------
\section{Parallel processing}

As discussed in section \ref{sec:script_run}, when one is examining a set of
$(L,T,\alpha)$ parameter values, one invokes an \texttt{mcrcm} executable for
each particular triple of $(L,T,\alpha)$.  If sufficiently many
processors\index{parallel processing} are available, there is no reason one
cannot run, say, $(L=40,T=6.5,\alpha=0.1)$ at the same time as
$(L=40,T=6.5,\alpha=0.2)$.  In \plainidx{high-performance computing} jargon,
such parallelism is called \emphidx{trivially parallel} or
\emphidx{embarrassingly parallel}.  The author uses three such paradigms:
\begin{itemize}
\item On a single-processor laptop, \texttt{mcrcm} programs are launched
in sequence, as in section \ref{sec:script_run}.
\item On the University of Arizona Department of Mathematics chivo
cluster, which is four hosts with two CPUs each, one might (to
be civil to other users) pick three hosts, running one parameter
set on each, further prefixing with Unix \texttt{nice -10}.
\item On the University of Arizona High Performance Computing Center's
ICE cluster, which is a single host with over 1000 CPUs shared by
dozens of on-campus researchers, one might request, say, 32 CPUs
and divide the parameter set among those CPUs.
\end{itemize}

What has not been implemented is parallelization of \texttt{mcrcm} itself.  As
of this writing, there is no need to do so.

%% ================================================================
\chapter{Results}
\label{chap:results}

%% ================================================================
\section{Finite-size scaling methodology}
\label{sec:fss}

Finite-size scaling\index{finite-size scaling} takes the form of a hypothesis,
or rather a set of \plainidx{hypotheses}, which is tested against the data.
See \cite{bib:pv} for an excellent survey of techniques; see section
\ref{sec:fss_derivation} for a derivation of the formulas.

We have an infinite-volume\index{infinite volume} random variable $S(T)$, e.g.
any of the order parameters\index{order parameter} defined in section
\ref{sec:ordps}.  The finite-volume\index{finite volume} quantity is $S_L(T)$.
Define $t=(T-T_c)/T_c$.  Examine, say, $0.99 < t < 1.01$.  The first hypothesis
is that the \plainidx{correlation length} $\xi(T)$ follows a \plainidx{power
law}
$$
	\xi(T) \sim |t|^{-\nu}, \quad T \to T_c
$$
For the infinite-volume quantity, we also expect a power-law behavior
$$
	S(T) \sim t^{\rho}, (-t)^{\rho}, \qor |t|^\rho,
	\qie \xi^{-\rho/\nu}.
$$
(The domain of validity is $t<0$ or $t>0$ depending on whether the order
parameter $S$ is left-sided or right-sided, respectively.) One moreover
hypothesizes that for $T$ near $T_c$, $S_L(T)$ and $S(T)$ are related by a
\emphidx{universal function} $Q_S$ which depends on $T$ only through the ratio
$L/\xi$:
\begin{align}
\label{eqn:fss}
	S_L(T) &= L^{-\rho/\nu} Q_S(L^{1/\nu} t)
	\sim L^{-\rho/\nu} Q_S((L/\xi)^{1/\nu}).
\end{align}

The flow of data and respective uncertainties are as follows:

\begin{itemize}

\item Markov chain Monte Carlo simulations, with error bars determined using
the method of integrated autocorrelation time (see \cite{bib:berg} and our
appendix \ref{appx:eta}), yield $S_L(T, \alpha)$ data points.  There are five
order parameters $S$, six values of $L$ (30, 40, 50, 60, 70, 80), nine values
of $\alpha$, and a few dozen values of $T$ for each $\alpha$.

\item For each $S$, $L$, and $\alpha$, we use $S_L(T,\alpha)$ values for all
available values of $T$ and $\alpha$ to estimate \footnote{We use the
statistics convention wherein $\hat{\rho}$ is an experimental estimator for the
exact (but unknown) value $\rho$.} $\rhohat_S(L)$.  (Critical exponents are
assumed to be independent of $\alpha$ for small $\alpha$, or with weak enough
dependence on $\alpha$ that that dependence is lost in the noise.) Error
bars\index{error bar} may be propagated from the MCMC simulations, or computed
from \plainidx{regression} uncertainties.

\item Extrapolating $\rhohat_S(L)$ in $L \to \infty$ results in the five
estimated critical exponents\index{critical exponent} $\rhohat_S$.
Uncertainties are computed from the regression analysis.

\item Once the critical exponents have been estimated, we obtain
$\hat{T}_{c,S}(\alpha)$ for each of the five order parameters $S$ and for each
$\alpha$.  Uncertainties are computed by visual inspection of the
\plainidx{crossing plots} discussed in section \ref{sec:crossing}.

\item Once the critical exponents and $T_c$ have been estimated, one should be
able to obtain plots of the universal function $Q_S$ which is, up to sampling
variability, independent of $L$, $T$, and $\alpha$.  This verifies that the
finite-size-scaling hypothesis was the correct approach to use.

\item The shift in reduced critical temperature is as in equation
\eqref{eqn:Delta_Tc}.  Error bars are computed from regression uncertainties.

\end{itemize}

%% ----------------------------------------------------------------
\section{Derivation of finite-size scaling}
\label{sec:fss_derivation}

A clear explanation is found in on-line notes of Claudia Br\"uns of the
Argelander Institute for Astronomy of the University of Bonn.  Those notes are
are reproduced essentially verbatim in this section, except for change of
notation.

For $T$ away from $T_c$, $\xi \ll L$ and so $S_L(T)$ is not affected by lattice
size.  The finite-volume quantity $S_L(T)$ corresponds to the infinite-volume
quantity $S_\infty(T)$, and we know $S_\infty(T) \propto \xi^{-\rho/\nu}$ as
discussed in the previous section.  For $T$ near $T_c$, on the other hand, the
correlation length $\xi$ approaches the system size $L$ so
$S_L(T) \propto \xi^{-\rho/\nu} \approx L^{-\rho/\nu}$.  As well, $S_L(T)$
differs significantly from $S_\infty(T)$ via the constant of proportionality.
Combining these two regimes into a single expression gives
\begin{align}
\label{eqn:fss_deriv_S}
	S_L(T) &= \xi^{-\rho/\nu} R_S(L/\xi)
\end{align}
where
\begin{align}
	R_S(L/\xi) \propto \begin{cases}
		\textrm{constant}, & \xi \ll L \\
		(L/\xi)^{-\rho/\nu}, & \xi \to L.
	\end{cases}
\end{align}
The infinite-volume correlation length $\xi=\xi_\infty(T)$ is unknown, so we
define a \plainidx{scaling function} $Q_S$ to get rid of it:
\begin{align}
\label{eqn:fss_deriv_Q}
	Q_S(L/\xi) &= (L/\xi)^{\rho} R_S((L/\xi)^\nu),
\end{align}
i.e.
\begin{align}
\label{eqn:fss_deriv_R}
	R_S(L/\xi)   &= (L/\xi)^{-\rho/\nu} Q_S((L/\xi)^{1/\nu}).
\end{align}
The scaling function $Q_S$ is finite for $\xi \to L$:
\begin{align}
	Q_S(L/\xi) &= (L/\xi)^\rho R_S((L/\xi)^\nu) \\
	Q_S(L/\xi) &\propto (L/\xi)^\rho \cdot ((L/\xi)^\nu)^{-\rho/\nu} = 1.
\end{align}
Placing equation \eqref{eqn:fss_deriv_R} into equation \eqref{eqn:fss_deriv_S}
yields
\begin{align}
	S_L(T) &= \xi^{-\rho/\nu} (L/\xi)^{-\rho/\nu} \cdot Q_S((L/\xi)^{1/\nu}) \\
	&= L^{-\rho/\nu} Q_S(L^{1/\nu} \xi^{-1/\nu}) \\
	&= L^{-\rho/\nu} Q_S(L^{1/\nu} t).
\end{align}

%% ----------------------------------------------------------------
\section{Determination of $L$-dependent critical exponents}
\label{sec:rho_hat_L}

For each of order parameter $S$, interaction parameter $\alpha$, and box length
$L$, we examine all $S(L,T,\alpha)$ data for which $S > \veps$, with $\veps$
taken from the plots to ensure that we examine the portions of the curves
corresponding to non-zero order parameter in the infinite limit (see figure
\ref{fig:fmax_and_recip_xi}).  For $1/\xi$, this means $T>T_c$; for the other
four order parameters, this means $T<T_c$.  From plots such as those in figure
\ref{fig:fmax_and_recip_xi}, we choose $\veps$ to be
$0.1$  for $1/\xi$,
$0.01$ for $\fM$,
$0.01$ for $f_I$,
$0.05$ for $f_S$, and
$0.01$ for $f_W$.
For each $S$, $\alpha$, and $L$, we then apply linear regression to
$S(L,T)^{1/\rho_S}$ for varying $\rho_S$.  We find $\rhohat_S(L)$ which
optimizes the correlation coefficient \cite{bib:young} of the linear
regression.  Results are shown in figure \ref{fig:smiley_and_rhoestalpha}.
Given $\rhohat_S(L)$ along with its corresponding linear-regression parameters
$\hat{m}$ and $\hat{b}$, we may plot a power-law fit to the simulational data.
One such comparison plot is shown in figure \ref{fig:ordp_fit_comparison}.

% Results are shown in table \ref{table:rhohat_S_L} and figure
% \ref{fig:smiley_and_rhoestalpha}.

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.45]{../tests/fss3a/resultsfigs/graph_rell_alpha0_0.000_E_ellmax_N_small.eps}
\includegraphics[scale=0.45]{../tests/fss3a/resultsfigs/graph_rell_alpha0_0.001_E_ellmax_N_small.eps}
%
\includegraphics[scale=0.45]{../tests/fss3a/resultsfigs/grapheb_rell_alpha0_0.000_recip_xi_small.eps}
\includegraphics[scale=0.45]{../tests/fss3a/resultsfigs/grapheb_rell_alpha0_0.001_recip_xi_small.eps}
\caption
	[Order parameters $\fM$ and $1/\xi$.]
	{Order parameters $\fM$ and $1/\xi$ for $L=40,60,80$ and $\alpha=0$ and
	$0.001$.  The remaining order parameters $f_S$, $f_W$, and $f_I$ behave
	similarly to $\fM$ but with not all with the same critical exponents.
	\label{fig:fmax_and_recip_xi}}
\end{center}
\end{figure}

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.48]{../tests/fss3a/data/smiley_fS_L_80_alpha_0.000.eps}
\includegraphics[scale=0.48]{../tests/fss3a/rhoestalpha.eps}
\caption[Determination of critical exponent.]
	{On the left:  determination of critical exponent
	$\hat{\rho}_S(L,\alpha)$ for order parameter $f_S$, as the value which
	minimizes linear-regression error for $S_L(T,\alpha)^{1/\rho}$.  Visually,
	one sees $\hat{\rho}_S(L=80, \alpha=0.0) \approx 0.59$.
	%
	On the right:  estimated critical exponents for $L=30,40,50,60,70,80$.
	%
	\label{fig:smiley_and_rhoestalpha}}
\end{center}
\end{figure}

\begin{table}
\input{../tests/fss3a/fMfIvalues.tex}
\caption[$\fM/f_I$ as a function of $\alpha$.  A slight upward trend is
	visible.]
	{$\fM/f_I$ as a function of $\alpha$.  An upward trend is
	visible, but it is not pronounced.
	\label{table:fMfI_alpha}}
\end{table}

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.5]{../tests/fss3a/resultsfigs/fS_alpha_0.000_comp.eps}
\caption[Power-law fit vs. raw simulational order-parameter data.]
	{Power-law fit vs. raw simulational data for order parameter $f_S$,
	$\alpha=0$.
	\label{fig:ordp_fit_comparison}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Extrapolation of critical exponents for the infinite-volume limit}
\label{sec:rhohat_extrap}

Next, for each $S$, given estimates $\rhohat_S(L)$ for increasing values of
$L$, we plot $\rhohat_S(L)$ versus $1/L$.  The vertical intercept of this plot
estimates the infinite-volume exponent $\rhohat_S(\alpha)$.  (See figure
\ref{fig:smiley_and_rhoestalpha}.) Results are shown in table \ref{table:rhohat_S}.

\begin{table}
\input{../tests/fss3a/rhoest.tex}
\caption[Extrapolated estimates of the infinite-volume critical exponents.]
	{Extrapolated estimates of the infinite-volume critical exponents, found
	from the vertical intercept of figure \ref{fig:smiley_and_rhoestalpha}.
	\label{table:rhohat_S}}
\end{table}

%% ----------------------------------------------------------------
\section{Determination of critical temperature}
\label{sec:crossing}

% $fss3a/crossing.py

Given the above estimators of the critical exponents, the \emphidx{crossing
method} \cite{bib:pv} estimates $T_c(\alpha)$.  Namely, we plot
$L^{\rhohat/\nuhat} S_L(T)$ as a function of $T$.  At $T=T_c$ we have $t=0$ and
$L^{\rho/\nu} S_L(T)  = Q_S(0)$, regardless of $L$ (equation \eqref{eqn:fss}).
Thus, these curves will cross (approximately, due to sampling variability) at
$T=T_c$.  If they do not, the finite-size-scaling hypothesis is not verified.
(Note in particular that for order parameter $1/\xi$ whose critical exponent is
$\nu$, we apply the crossing method to $L S_L(T)$ as a function of $T$:  thus,
the $T_c(\alpha)$ estimate using $1/\xi$ is independent of $\nuhat$.) See for
example figure \ref{fig:fS_crossing}.  Results are in table
\ref{table:Tc_alpha} and figure \ref{fig:Tc_alpha}

Using order parameters $f_S$ and $f_W$, which depend on winding phenomena, one
does not see clear crossing behavior.  We suggest that either this is related
to the even-winding-number issue discussed in section \ref{sec:wno_SAR}, or
$f_S$ and $f_W$ are not good order parameters for this model.  We suspect the
former; in every manner except this crossing issue, $f_S$ and $f_W$ behave as
expected.

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.48]{../tests/fss3a/data/crossing_raw_fI_alpha_0.000.eps}
\includegraphics[scale=0.48]{../tests/fss3a/data/crossing_raw_zoom_fI_alpha_0.000.eps}
%
%\includegraphics[scale=0.48]{../tests/fss3a/data/crossing_fit_fI_alpha_0.000.eps}
%\includegraphics[scale=0.48]{../tests/fss3a/data/crossing_fit_zoom_fI_alpha_0.000.eps}
\caption
	[Estimation of $T_c(\alpha)$ for order parameter $f_I$.]
	{The crossing method to estimate $T_c(\alpha)$ for order parameter $f_I$,
	with $\rhohat$ and $\nuhat$ as above: $T_c(\alpha)$ corresponds to the
	horizontal coordinate of the intersection point of the plots.
	The upper-right-hand plot is a close-up of the upper-left-hand plot.
	Order parameters $f_S$ and $f_W$, which depend on winding phenomena, do not
	exhibit clear crossing behavior.
	\label{fig:fS_crossing}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Verification of finite-size-scaling hypothesis}
\label{sec:collapse}

Now that we have estimated $\rho_S$, $\nu$, and $T_c(\alpha)$ for each of the
five order parameters $S$, we  may plot $L^{\rho_S/\nu} S_L(T,\alpha)$ as a
function of $L^{1/\nu}t$.  This is a plot of the scaling function $Q_S$.  If
the hypothesis is correct, the curves for all $L$ should coincide, or
\plainidx{collapse}, to within sampling error --- which they do (e.g. figure
\ref{fig:fS_collapse}).

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/data/collapse_raw_fS_alpha_0.000.eps}
\caption
	{Collapse plot for order parameter $f_S$.
	\label{fig:fS_collapse}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Determination of the shift in critical temperature}
\label{sec:Delta_Tc_and_const}

% @@@ update manually

As discussed in section \ref{sec:conj}, we are seeking a linear relationship
between $\Delta T_c(\alpha)$ and $\alpha$, with constant $c$.  This can be
visualized in figure \ref{fig:Delta_Tc_cmp}, which is obtained from the
$T_{c,S}(\alpha)$ data of figure \ref{fig:Tc_alpha} using equation
\eqref{eqn:Delta_Tc}.  We start with all the $(\alpha,\Delta T_c(\alpha))$ data
points from section \ref{sec:crossing}.  We omit values obtained using $f_S$
and $f_W$, due to the aforemention lack of crossing behavior.  We also omit
values obtained using $\alpha=0.004$, since the critical-temperature plots of
figure \ref{fig:Tc_alpha} suggests that this starts to exceed the domain of
linear approximation.
We perform a linear regression with error bars
\cite{bib:young} on
the $(\alpha,\Delta T_c(\alpha))$ data points.  We use a slope-only fit, rather than
a slope-intercept fit, since $\Delta T_c(\alpha)$ has zero intercept by its very definition.
We find
\begin{align*}
	%c &= 0.665 \pm 0.067.
	%c &= 0.618 \pm 0.043 \textrm{  (1 $\sigma$ error bar)}.
	c &= 0.618 \pm 0.086 \textrm{  (2 $\sigma$ error bar)}.
\end{align*}
Within experimental uncertainty, this result, for points on the lattice with
Ewens cycle-weights, matches the $c$ value of equation \eqref{eqn:rho_c} for
point positions varying on the continuum with decaying-cycle-weight
interactions.

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/Tcest.eps}
\caption
	{Critical temperature as function of $\alpha$.
	\label{fig:Tc_alpha}}
\end{center}
\end{figure}

\begin{table}[!htb]
\input{../tests/fss3a/Tcest.tex}
\caption[Critical temperature as a function of $\alpha$.]
	{Critical temperature as a function of $\alpha$.  All values
	have error bars of approximately $0.003$.
	\label{table:Tc_alpha}}
\end{table}

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.6]{../tests/fss3a/Delta_Tcest_cmp.eps}
\caption
	[Shift in critical temperature as function of $\alpha$.]
	{Shift in critical temperature, and linear fit, as function of $\alpha$.
	Recall from equation \eqref{eqn:Delta_Tc} that
	$\Delta T_c(\alpha) = \frac{T_c(\alpha)-T_c(0)}{T_c(0)}$.
	Order parameters $f_S$ and $f_W$ were omitted
	from the fit, due to lack of crossing behavior; $\alpha=0.004$ was
	omitted due to onset of curvature of $T_c(\alpha)$.
	The heavy solid line shows a linear fit with empirically determined
	constant of proportionality; the lighter solid line is the comparison value
	of Betz and Ueltschi (slope $2/3$) for decaying cycle weights and continuum
	point positions.
	\label{fig:Delta_Tc_cmp}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Constancy of the macroscopic-cycle quotient}
\label{sec:mcq_const}

As discussed in section \ref{sec:conj}, we hypothesize that the
\plainidx{macroscopic-cycle quotient} $\fM / f_I$ in the infinite-volume limit
is dependent on $\alpha$ but is constant in $T$ where it is defined, i.e.  for
$T<T_c$ since $f_I=0$ for $T>T_c$.  This may be visualized by comparing figures
such as \ref{fig:E_ellmax_N}:  one sees that $\fM$ and $f_I$ appear to have the
same critical exponent.  Alternatively, one may plot the ratio $\fM/f_I$
(figure \ref{fig:fMfI_curves}).  In the infinite-volume limit, $f_I$ is zero
for $T>T_c$ and so we are interested only in the values of the quotient for
$T<T_c$.  In that region, the quotient does indeed appear to be constant in
$T$.

We test this constancy hypothesis as follows.  The respective critical
exponents are $\rho_M$ and $\rho_I$.  The estimators are $\rhohat_M$ and
$\rhohat_I$, computed by averaging over several different values of $L$ and
$\alpha$ as described in section \ref{sec:rhohat_extrap}.  Treating these
estimators as normally distributed (as justified by the raw data), we obtain
the standard deviations of the $\rhohat_{M,I}(L,\alpha)$ samples, along with the
standard deviations of the means $\rhohat_{M,I}$:
\input{../tests/fss3a/fMfIseparate.tex}
The difference $\rhohat_M - \rhohat_I$ is also normally distributed about the
true mean $\rho_M - \rho_I$, but $\rhohat_M$ and $\rhohat_I$ are not
independent since they are sample means of random variables computed from the
same Markov chain Monte Carlo sequence of permutations.  Thus we use
\begin{align*}
	\Var(\rhohat_M - \rhohat_I) &= \Var(\rhohat_M) + \Var(\rhohat_I)
		- 2 \Cov(\rhohat_M, \rhohat_I).
\end{align*}
Computing the sample covariance of the $\rhohat_M(L,\alpha)$ and
$\rhohat_I(L,\alpha)$ data series, we obtain the \plainidx{covariance} and
resulting standard error $s_d$ of the difference
\input{../tests/fss3a/fMfIcov.tex}
Normalizing, we find
\input{../tests/fss3a/fMfInormalize.tex}
We hypothesize $\rho_M -  \rho_I = 0$; the estimated value $\rhohat_M -
\rhohat_I$ lies comfortably within a standard deviation of this.  We note,
moreover, that the value of $\fM/f_I$, while constant in $T$, trends upward
with $\alpha$ (see table \ref{table:fMfI_alpha} and figure
\ref{fig:fMfI_alpha}).  This merits further investigation.

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.52]{../tests/fss3a/resultsfigs/graph_rell_alpha0_0.000_fMfI.eps}
\includegraphics[scale=0.52]{../tests/fss3a/resultsfigs/graph_rell_alpha0_0.002_fMfI.eps}
\caption
	{Macroscopic-cycle quotient $\fM/f_I$ for $\alpha=0, 0.002$.
	\label{fig:fMfI_curves}}
\end{center}
\end{figure}

\begin{figure}
\begin{center}
\psfragscanon
\includegraphics[scale=0.50]{../tests/fss3a/fMfIvalues.eps}
\caption{$\fM/f_I$ as a function of $\alpha$.
	\label{fig:fMfI_alpha}}
\end{center}
\end{figure}

%% ----------------------------------------------------------------
\section{Conclusions}
\label{sec:conclusions}

% @@@ update manually

(1) For \plainidx{annealed point positions}, equation \eqref{eqn:theo_Tc} gives $T_c(0)
\approx 6.625$.  Our result $T_c(0) = 6.873 \pm 0.006$ (2 $\sigma$ error bar)
unambiguously shows that the lattice structure modifies the \plainidx{critical
temperature}, even in the non-interacting ($\alpha=0$) case.

% @@@ update manually

(2) As detailed in section \ref{sec:Delta_Tc_and_const}, we find that the
reduced shift in critical temperature as a function of interaction parameter
$\alpha$ is
\begin{align*}
	\Delta T_c(\alpha) &\approx \frac{T_c(\alpha) - T_c(0)}{T_c(0)}
		= c \alpha
\end{align*}
with
\begin{align*}
	%c &= 0.665 \pm 0.067.
	c &= 0.618 \pm 0.086 \textrm{  (2 $\sigma$ error bar)}.
\end{align*}
This is compatible (section \ref{sec:conj}) with the related result of
\cite{bib:bu08}.  Even though the lattice structure changes the critical
temperature (conclusion 1), the \emph{shift} in critical temperature is
unaffected.

% @@@ update manually

(3) As described in section \ref{sec:known_results}, Shepp and Lloyd
\cite{bib:shepplloyd} find that $\bbE[\ellmax]/N \approx 0.6243$ for
uniform-random (non-spatial) permutations.  For spatial permutations, we define
a macroscopic-cycle quotient $\bbE[\ellmax]/N f_I$ which is the ratio of mean
maximum cycle length as a fraction of the number of sites in long cycles.  Our
result (table \ref{table:fMfI_alpha} and figure \ref{fig:fMfI_alpha}) is
compatible with that of Shepp and Lloyd for the non-interacting case, with an
increase which appears to be linear as a function of interaction parameter
$\alpha$.

(4) We proved correctness for the pre-existing SO algorithm \cite{bib:gru}; we
invented the SAR, band-update, and worm algorithms, and proved them correct.
The band-update algorithm suffers from a too-low acceptance probability; the
worm algorithm suffers from a too-long stopping time; the SO algorithm
prohibits (with very high probability) non-zero winding numbers.  The SAR
algorithm is our current best option, even though it only permits even winding
numbers.  Solving the deficiencies of the band-update or worm algorithms would
be worth the effort.

(5) The order parameter $1/\xi$ is the most convenient to use for our problem:
in the finite-size-scaling analysis, the crossings are independent of estimated
critical exponent $\hat\nu$.  The order parameters $f_I$ and $\fM$ are
second-most convenient; one must estimate their critical exponents, but they
are usable.  The order parameters $f_S$ and $f_W$, which depend on winding
phenomena, do not pass the finite-size-scaling hypothesis.  Either they are not
good order parameters for the model of random spatial permutations, or they
would benefit from a full-winding-number algorithm as discussed in the previous
paragraph.

%% ================================================================
\chapter{Future work}
\label{chap:future_work}

\textbf{Macroscopic-cycle quotient:} Now that the $\alpha$-dependence of the
macroscopic-cycle quotient's constant upon $\alpha$ has been found empirically,
one would next like to explain that dependence analytically.

\textbf{Non-asymptotic algorithm correctness:} The detailed-balance correctness
proof of the swap-and-reverse algorithm shows that there is a non-zero
transition probability between all pairs of permutations.  However, those
non-zero transition probabilities can be quite small.  As the number of
Metropolis steps goes to infinity, asymptotically all permutations can be
reached; more interesting is the question of which permutations are actually
reachable in reasonable simulation time.  One answers this question empirically
simply by running simulations; perhaps this suffices.  For the system discussed
in this paper, as well as for other systems studied using MCMC methods, it
would be useful to have a non-asymptotic correctness theory.

\textbf{Winding numbers of all parities:} Ideally, one would have an algorithm
to permit odd winding numbers, as discussed in section \ref{sec:wno_SAR}.

\textbf{Bose-gas Hamiltonian:} Sampling from the true Bose-gas distribution
using the random-cycle model requires three changes.  First, one needs to
conduct simulations using the Bose-gas interaction (equation
\eqref{eqn:RCM_H_gen_V}) rather than the cycle-weight interaction (equation
\eqref{eqn:RCM_H_rell_V}).  The interaction term $V$ is a CPU-intensive
Brownian-bridge computation \cite{bib:bu07}; unpublished work of Ueltschi and
Betz shows that it may be approximated in the weak-interaction case by a
simpler Riemann integral.  Precomputed tables and interpolation may make use of
this integral feasible.

Second, point positions must be allowed to vary on the continuum.  This entails
a second type of Metropolis step, in addition to that shown in section
\ref{sec:SO_algorithm}.  Namely, one picks a point and moves it to a new
position nearby, using the detailed-balance condition to choose the acceptance
probability.

Third, software efficiency requires a hierarchical partitioning of $\Lambda$.
The Metropolis step of section \ref{sec:SO_algorithm} relies on picking
$\pi(\vecy)$ near to $\pi(\vecx)$.  For points on the lattice, this is easy:
each site has six nearest neighbors.  For freely placed points, though, one
must remember which sites are close to which.  The most naive implementation
involves computing the distances between all $N(N-1)/2$ pairs of points; the
$O(N^2)$ computation time is overwhelming.  Instead, the lattice may be
partitioned into subcubes.  Distances need to be computed only between each
given point $\vecx$ and those in $\vecx$'s subcube and the 26 nearest-neighbor
subcubes.

The second and third points simply require a software effort.  Implementing
them will be worthwhile only if the interaction terms can be simplified to the
point that they are computationally feasible.  This is a mathematical effort.

%% ================================================================
\appendix

% Flush the figure queue.
\afterpage{\clearpage}

%% ================================================================
\chapter{Error bars, autocorrelation, and batched means}
\label{appx:eta}

\input{etaabs.tex}

\input{etabody.tex}

%%% ----------------------------------------------------------------
%\section{Uniform distribution on $\SN$}
%
%To do: Following Ueltschi.
%
%To do: scratch work; flesh this out.
%
%\begin{prop}
%For the uniform distribution on $\SN$,
%\begin{align*}
%	P_N(\ell_i = k) &= \frac{1}{N},\quad  1 \le k \le N.
%\end{align*}
%\begin{proof}
%\begin{align*}
%	P_N(\ell_1 = k)
%	&= P_N(\ell_i = k)
%	= \frac{1}{N!} \#\{\pi: \ell_1(\pi) = k\} \\
%	&= \frac{1}{N!} N (N-1) \cdots (N-k+1) (N-k)! \\
%	&= \frac{1}{N}.
%\end{align*}
%since there are $N(N-1)\cdots(N-k+1)$ choices for jumps $1, \pi(1), \pi^2(1),
%\ldots, \pi^k(1)$ and then $(N-k)!$ remaining choices for permutations on the
%$N-k$ remaining points.
%%
%%For $k = 1, \ldots, N$, there are $(N-1)!$ permutations $\pi$ with $\ell_1(\pi)
%%= k$.
%\end{proof}
%\end{prop}
%
%%\begin{cor}
%%\begin{align*}
%%	\frac{1}{V} \bbE[\varrho_{1,k}]
%%	&= \frac{1}{V} \sum_{\ell=1}^k \sum_{i=1}^N P(\ell_i = k)
%%	= \frac{1}{V} \sum_{\ell=1}^k \sum_{i=1}^N \frac{1}{N}
%%	= \frac{k}{V}.
%%\end{align*}
%%\end{cor}
%
%\begin{cor}
%\begin{align*}
%	\bbE[\varrho_{1,k}]
%	&= \sum_{\ell=1}^k \sum_{i=1}^N P(\ell_i = k)
%	= \sum_{\ell=1}^k \sum_{i=1}^N \frac{1}{N}
%	= k.
%\end{align*}
%\end{cor}

%% ================================================================
% Revisions:

% LARGER:
% * Sequential vs. random sweep, and separate Markov matrices.
% * Paragraph on Brownian-bridge interactions; comp-ish ...
% * Tom P notes; p. 43 ff.
% * JSP notes

% SMALL:
% * xxxx's in text
