\chapter{Stellar Clustering}
\label{ch:clustering}

\marginnote{
\textbf{Suggested background reading:}
\begin{itemize}
\item \href{http://adsabs.harvard.edu/abs/2014arXiv1402.0867K}{Krumholz, M.~R. 2014, Phys.~Rep., 539, 49}, section 5 \nocite{krumholz14c}
\end{itemize}
\textbf{Suggested literature:}
\begin{itemize}
\item \href{http://adsabs.harvard.edu/abs/2012MNRAS.426.3008K}{Kruijssen, J.~D.~M. 2012, MNRAS, 426, 3008} \nocite{kruijssen12a}
\end{itemize}
}

The previous two chapters focused on star formation at the scale of galaxies, with attention to what determines the overall rate at which stars form. In this chapter we will now zoom in a bit, and ask how star formation is arranged in space and time within a single molecular cloud, and how these arrangements evolve over time as star formation proceeds and eventually ceases. The central goal of this analysis will be to understand a striking observational feature of star formation: sometimes, but not often, it produces gravitationally-bound clusters of stars.

\section{Observations of Clustering}

We will start our discussion with a review of the observational situation, focusing first on young stars and gas and then moving on to older populations of stars that have become gas-free.

\subsection{Spatial and Kinematic Distributions of Gas and Young Stars}

Newborn stars are, like the gas in molecular clouds, distributed in a highly structured and inhomogeneous fashion. The gas is arranged in filaments, and young stars are largely arranged along those filaments, at least in the youngest regions. In somewhat older regions we start to see clusters of stars where the is no gas and the filamentary structure has dissolved, but with gas morphologies highly suggestive that it is being blown away by the young stars. Figure \ref{fig:maps_gutermuth11} shows examples of both a younger, filament-dominated region and an older one where substantial gas clearing has taken place.

\begin{figure}
\includegraphics[width=\linewidth]{maps_gutermuth11}
\caption[Maps of gas and young stars in two clouds]{
\label{fig:maps_gutermuth11}
Maps showing the distribution of gas (grayscale) and young stellar objects (YSOs, red points) in the MonR2 (top) and CepOB3 (bottom) clouds. The grayscale gas maps are measured from dust extinction, which is plotted using a linear stretch from extinction $A_V = -1$ to 10 mag; contours start at $A_V=3$ mag, and are at 2 mag intervals. Credit: \citet{gutermuth11a}, \copyright AAS. Reproduced with permission.
}
\end{figure}

Such an inhomogeneous structure calls for a statistical description, and a number of statistical techniques have been used to describe gas and star arrangements. For gas we have already encountered some of these, in the form of power spectra. Power spectra can be computed for velocity structure, but they can also be computed for density structure. They can be computed for both 2D projected images of density as well as true 3D data.

Stars, on the other hand, are point objects, and so one cannot compute a power spectrum for them as one would for a continuous field like the density. However, one can compute a closely-related quantity, the two-point correlation function. Recall that, for a continuous vector field (say the velocity), we defined the autocorrelation function as
\begin{equation}
A_{\vecv}(\vecr) = \frac{1}{V} \int \vecv(\vecx) \cdot \vecv(\vecx + \vecr)\, d\vecx.
\end{equation}
For a scalar field, say density $\rho$, we can just replace the dot product with a simple multiplication. It is also common to slightly modify the definition by subtracting off the mean density so that we get a quantity that depends only on the shape of the density distribution, not its mean value. This quantity is
\begin{equation}
\label{eq:autocorr}
\xi(\vecr) = \frac{1}{V} \int [\rho(\vecx)-\overline{\rho}] [\rho(\vecx + \vecr)-\overline{\rho}]\, d\vecx,
\end{equation}
where $\overline{\rho} = (1/V) \int \rho(\vecx)\, d\vecx$. If the function is isotropic, then the autocorrelation function depends only on $r=|\vecr|$.

This is still defined for a continuous field, but we can extend the definition to the positions of a collection of point particles by imagining that the point particles represent samples drawn from an underlying probability density function. That is, we imagine that there is a continuous probability $(dP(\vecr)/dV)\, dV$ of finding a star in a volume of size $dV$ centered at some position $\vecr$, and that the actual stars present represent a random draw from this distribution.

In this case one can show that the autocorrelation function can be defined by the following procedure. Imagine drawing stellar positions from the PDF until the mean number density is $n$, and then imagine choosing a random star from this sample. Now consider a volume $dV$ that is displaced by a distance $\vecr$ from the chosen star. If $dP(\vecr)/dV$ were uniform, i.e., if there were no correlation, then the probability of finding another star at that point would simply be $n\, dV$. The two-point correlation function is then the \textit{excess} probability of finding a star over and above this value. That is, if the actual probability of finding a star is $dP_2(\vecr)/dV$, we define the two-point correlation function by
\begin{equation}
\frac{dP_2}{dV}(\vecr) = n \left[1 + \xi(\vecr)\right].
\end{equation}
Defined this way, the quantity $\xi(\vecr)$ is known as the two-point correlation function. It is possible to show that, with this definition, $\xi(\vecr)$ is equivalent to that given by equation (\ref{eq:autocorr}) applied to the underlying probability density function. As above, if the distribution is isotropic, then $\xi$ depends only on $r$, not $\vecr$. Also note that this is a 3D distribution, but if one only has 2D data on positions (the usual situation in practice), one can also define a 2D version of this where the volume is simply interpreted as representing annuli on the sky rather than shells in 3D space.

How does one go about estimating $\xi(r)$ in practice? There are a few ways. The most sophisticated is to take the measured positions and randomize them to create a random catalog, measure the numbers of object pairs in bins of separation, and use the difference between the random and true catalogs as an estimate of $\xi(r)$. This is the normal procedure in the galaxy community where surveys have well-defined areas and selection functions. In the star formation community, things are a bit more primitive, and the usual procedure is just to count the mean surface density of neighbors as a function of distance around a star, that is, to estimate that
\begin{equation}
\Sigma(r) = n \left[1 + \xi(r)\right]
\end{equation}
where $r$ is taken to be the projected separation. This is quite rough, and is vulnerable to considerable biases arising from things like edge effects (formally the correlation function is only defined over an infinite volume, but in reality of course surveys are finite in size), but it is what the star formation community generally uses.

With that formal throat-clearing out of the way, we are now in a position to look at actual data, and, since we have these clean definitions, we can talk about gas and stars on essentially equal footing. So what do autocorrelation functions of gas and star look like? Figure \ref{fig:correlation_stargas} shows some example measurements.

\begin{figure}
\includegraphics[height=5.2cm]{starcorrelation_kraus08}\includegraphics[height=5cm]{gascorrelation_schneider11}
\caption[Correlation functions for gas and stars]{
\label{fig:correlation_stargas}
Measurements of the stellar and gas correlations in nearby star-forming regions. The two figures on the left show the surface density of neighbors around each star $\Sigma(r)$ in Upper Sco and Taurus. The right panel shows measurements, for a large number of nearby molecular clouds, of a statistic called the $\Delta$ variance, $\sigma \Delta^2$, which is related to the correlation function. Credit: left panel: \citet{kraus08a}, \copyright\, AAS, reproduced with permission; right panel: \citeauthor{schneider11a}, A\&A, 529, A1, 2011, reproduced with permission, \copyright\, ESO.
}
\end{figure}

In the stellar distributions, we can identify a few features. At small separations, we see one powerlaw distribution. This is naturally identified as representing wide binaries. This falls off fairly steeply, until it breaks to a shallower falloff at larger separations, which can be interpreted as describing the distribution of stars within the cluster. This is also a powerlaw, covering several orders of magnitude in separation. That fact that the distribution is well fit by a powerlaw indicates that the stars follow a self-similar, scale-free structure. One can interpret such a structure as a fractal, and the index of the powerlaw is related to the dimensionality of the fractal; typical values for the dimensionality are $\sim 1$, consistent with a highly filamentary structure.

\begin{marginfigure}
\includegraphics[width=\linewidth]{denvel_walsh04}
\caption[Velocity distributions in varying molecular lines]{
\label{fig:denvel_walsh04}
Velocity distributions measured toward a nearby protostellar core using three different molecular line tracers, as indicated. The transitions $^{13}$CO, C$^{18}$O, and N$_2$H$^+$ should be roughly ordered from lowest to highest in terms of the density of gas that produces them. Creidt: \citet{walsh04a}, \copyright AAS. Reproduced with permission.
}
\end{marginfigure}

For the gas, one tends to obtain a similar powerlaw structure over a broad range of scales, with possible breaks at the high and low end. Thus the basic conclusion is that the stars and gas are in highly structured, fractal-like distributions. At young ages, the gas and stellar distributions are highly correlated with one another, which is not surprising. For older stellar populations, the correlation begins to break down.

\begin{marginfigure}
\includegraphics[width=\linewidth]{gasstar_tobin09}
\caption[Spatial and velocity distributions of gas and stars]{
\label{fig:gasstar_tobin09}
Measured distributions of $^{13}$CO (grayscale) and young stellar objects (blue points) in velocity ($x$ axis) and position on the sky in one dimension ($y$ axis) for the Orion Nebula Cluster. Credit: \citet{tobin09a}, \copyright AAS. Reproduced with permission.
}
\end{marginfigure}

In addition to the spatial distribution of stars and gas, one can also ask about their kinematics. Stellar kinematics can be determined by spectroscopy, and gas kinematics by molecular line observations. Depending on the choice of line, one learns about the kinematics of either lower or higher density regions of gas. These studies show that both the dense gas and the stars have much lower velocity dispersions than the less dense gas (Figures \ref{fig:denvel_walsh04} and \ref{fig:gasstar_tobin09}), but that the mean velocities are quite well correlated. The lower velocity dispersion will prove important below.

\subsection{Time Evolution of the Stellar Distribution}

As discussed in Chapter \ref{ch:gmcs}, stars stay associated with the gas from which they form for only a relatively short period. One can see this transition directly by comparing older and younger stellar populations. The younger the stellar population, the better the star-gas correlation. By stellar ages of $\sim 5-10$ Myr, there is usually no associated gas at all. However, it is still interesting to investigate how the stars evolve, because this contains important clues about how they formed.

The typical star-forming environment is vastly denser than the mean of the ISM, and as a result the stars that form are also vastly denser, in terms of either mass or number of stars per unit volume, than the mean density of gas in the ISM or stars near the Galactic midplane. More than 90\% of star formation observed within 2 kpc of the Sun takes place in regions where the stellar mass density exceeds $1$ $M_\odot$ pc$^{-3}$, corresponding to a number density $n > 30$ cm$^{-3}$ \citet{lada03a}. In comparison, the stellar mass density in the Solar neighborhood is $\sim 0.04$ $M_\odot$ pc$^{-3}$ \citep{holmberg00a}, and the mean density of gas in the ISM is $\sim 1$ cm$^{-3} \approx 0.03$ $M_\odot$ pc$^{-3}$.

However, these high densities do not last. If one examines stars at an age of $\sim 100$ Myr, the ratio is flipped -- only $\sim 10\%$ are in star clusters with a density identifiably higher than that of the stellar field, while $\sim 90\%$ have dispersed and can no longer be identified as members of discrete clusters (Figure \ref{fig:clusterage_fall12}). (They can, however, still be grouped by their kinematics, which take much longer to be randomized than their positions. Collections of stars that are now at low density and no longer show up as clusters based on their positions, but that remain very close together in velocity space, are called moving groups.)

\begin{marginfigure}
\includegraphics[width=\linewidth]{clusterage_fall12}
\caption[Star cluster age distributions]{
\label{fig:clusterage_fall12}
Measured distributions of star cluster ages in several galaxies. Clusters have been binned in mass, and different symbols show different mass bins, as indicated. Credit: \citet{fall12a}, \copyright AAS. Reproduced with permission.
}
\end{marginfigure}

The exact functional form of this decline in number of star clusters, and whether the fraction that remain in clusters after some period of time varies with the large-scale properties of the galaxy, are both uncertain. The answers seems to depend at least in part on how one chooses to define "cluster" at very young ages when the stars are still in a fractal, non-relaxed distribution. Nonetheless, the fact that the stars disperse tells us something very important, which is that they must have formed via a mechanism that leaves the resulting stellar system gravitationally unbound. Only in very rare cases does a bound stellar system remain after the gas is removed. This is an important constraint for theories of star formation.

\begin{marginfigure}
\includegraphics[width=\linewidth]{clustermass_fall12}
\caption[Star cluster mass distributions]{
\label{fig:clustermass_fall12}
Measured distributions of star cluster mass in several galaxies. Clusters have been binned in age, and different symbols show different age bins, as indicated. Credit: \citet{fall12a}, \copyright AAS. Reproduced with permission.
}
\end{marginfigure}

A second important observational constraint is that the star clusters that do remain always show mass distribution that is close to a powerlaw of the form $dN/dM \propto M^{-2}$ (Figure \ref{fig:clustermass_fall12}), meaning equal mass per logarithmic bin in cluster mass. This mass function is recovered in essentially all galaxies that have been examined, and does not appear to vary with large-scale galaxy properties. The origin of this distribution is also currently debated.

\section{Theory of Stellar Clustering}

Having discussed the observational situation, we now turn to theoretical models for the origin of stellar clustering. The models here are somewhat less developed than for either the star formation rate or the IMF, but the problem is no less important and interesting.

\subsection{Origin of the Gas and Stellar Distributions}

The origin of the spatial and kinematic distributions of gas and stars, and the correlation between them, ultimately seems to lie in very general behaviors of cold gas. The characteristic timescale for gravitational collapse is the free-fall time, which varies with density as $t_{\rm ff} \propto \rho^{-1/2}$. As a result, the densest regions tend to run away and form stars first, leading a a highly structured distribution in which stars are concentrated in the densest regions of gas. Quantitatively, simulations of turbulent flows are able to reproduce the powerlaw-like two point correlation functions that are observed \citep{hansen12a}.

\begin{marginfigure}
\includegraphics[width=\linewidth]{gasstar_offner09}
\caption[Spatial and velocity distributions of gas and stars in a simulation]{
\label{fig:gasstar_offner09}
Distributions of $^{13}$CO (grayscale) and young stellar objects (black crosses) in velocity ($x$ axis) and position on the sky in one dimension ($y$ axis) in a simulation of the Orion Nebula Cluster. Credit:\citet{offner09b}, \copyright AAS. Reproduced with permission.
}
\end{marginfigure}

The kinematics also arise from the properties of cold, turbulent gas. One general feature of such flows is a density-velocity anti-correlation. The densest regions of gas are produced by strong converging shocks, and immediately after the passage of such a shock the velocity is small because of the cancellation of opposing fluid velocities. The stars form from these dense, shocked regions, and so they inherit the low velocities of the dense gas out of which they form -- in some sense the stars are simply the tip of the density distribution. Again, simulations can qualitatively and quantitatively reproduce the observed kinematics. Figure \ref{fig:gasstar_offner09} shows an example.

\subsection{Gas Removal and the Transition to Gas-Free Evolution}

It seems that the spatial and kinematic arrangements of young stars are understood reasonably well. This is mainly because the physics that is responsible for them -- gravity plus hydrodynamics -- is well understood and easy to simulate.  Where we start to run into trouble is when we try to follow the transition from gas-dominated to gas-free evolution, where stellar feedback almost certainly plays a role.

First of all, as a baseline, let us consider what happens if we do not include any feedback. We have already seen that this creates dimensionless star formation rates $\epsilon_{\rm ff}$ that are $\sim 2$ orders of magnitude too high. However, omitting feedback also leads to problems when it comes to stellar clustering, because if one omits feedback, then most of the available gas is transformed into stars. The result is that, if the gas cloud from which the stars formed was bound to begin with, the resulting stellar system is also bound, and thus all star formation occurs in bound clusters.

In fact, the situation is even worse than that: even if one starts with an \textit{unbound} gas cloud, then if star formation feedback does not prevent consumption of most of the gas, the result is still that most of the stars are members of bound clusters. This happens because most of the kinetic energy is on large scales, so that, even if the entire cloud is unbound, there are plenty of sub-regions within it that become bound as the turbulence dissipates \citep{clark04a}. The result is that unbound clouds wind up fragmenting into a few clusters that are unbound from one another, but that are at internally bound. Thus explaining the observed fact that most stars are not members of bound clusters requires some mechanism to truncate star formation well before the majority of the mass is transformed to stars.

\paragraph{Rapid Versus Adiabatic Mass Loss}

To see what fraction of the gas mass must be lost to render the system unbound, we can begin with a simple argument. Let us consider a system of gas and stars with total mass $M$ in virial equilibrium, and with negligible support from magnetic fields. In this case, we have
\begin{equation}
2\mathcal{T} + \mathcal{W} = 0,
\end{equation}
where $\mathcal{T}$ is the total thermal plus kinetic energy, and $\mathcal{W}$ is the gravitational potential energy. Now let us consider what happens if we remove mass from the system, reducing the mass from $M$ to $\epsilon M$. We can envision that this is because a fraction $\epsilon$ of the starting gas mass has been turned into stars, while the remaining fraction $1-\epsilon$ is in the form of gas that is removed by some form of stellar feedback.

First suppose the removal is very rapid, on a timescale much shorter than the crossing time or free-fall time. In this case there will be no time for the system to adjust, and all the particles that remain will keep the same velocity and temperature. Thus the new kinetic energy is
\begin{equation}
\mathcal{T}' = \epsilon \mathcal{T}.
\end{equation}
Similarly, the positions of all particles that remain will be unchanged, so if the mass removal is uniform (i.e., we remove mass by randomly removing a certain fraction of the particles, without regard for their location) then the new potential energy will be
\begin{equation}
\mathcal{W}' = \epsilon^2 \mathcal{W}.
\end{equation}
The total energy of the system after mass removal is
\begin{equation}
E' = \mathcal{T}' + \mathcal{W'} = \epsilon \mathcal{T} + \epsilon^2 \mathcal{W} = \epsilon(1-2\epsilon) \mathcal{T} = \epsilon\left(\epsilon-\frac{1}{2}\right) \mathcal{W}
\end{equation}
Since $\mathcal{T} > 0$ and $\mathcal{W} < 0$, it immediately follows that the total energy of the system after mass removal is negative if and only if $\epsilon > 1/2$. Thus the system remains bound only if we remove less than $1/2$ the mass, and becomes unbound if we remove more than $1/2$ the mass.

If the system remains bound, it will eventually re-virialize at a new, larger radius. We can solve for this radius from the equations we have already written down. The total energy of a system in virial equilibrium is
\begin{equation}
E = \frac{\mathcal{W}}{2} = -a\frac{GM^2}{2R},
\end{equation}
so if the system re-virializes the new radius $R'$ must obey
\begin{equation}
E' = -a\frac{G(\epsilon M)^2}{2R'}.
\end{equation}
However, we also know that
\begin{equation}
E' = \epsilon\left(\epsilon-\frac{1}{2}\right) \mathcal{W} = -\epsilon\left(\epsilon-\frac{1}{2}\right)a\frac{GM^2}{R},
\end{equation}
and combining these two statements we find that the new radius is
\begin{equation}
R' = \frac{\epsilon}{2\epsilon-1} R.
\end{equation}

Now consider the opposite limit, where mass is removed very slowly compared to the crossing time. To see what happens in this case, it is helpful to imagine the mass loss as occurring in very small increments, and after each increment of mass loss waiting for the system to re-establish virial equilibrium before removing any more mass. Such mass loss if referred to as adiabatic. If we change the mass by an amount $dM$ (with the sign convention that $dM < 0$ indicates mass loss), we can find the change in radius $dR$ by Taylor expanding the equation we just derived for the new radius, recalling that $\epsilon = 1 + dM/M$:
\begin{equation}
R' = \frac{\epsilon}{2\epsilon-1} R = \frac{1 + dM/M}{1 + 2 dM/M} R = \left[1 - \frac{dM}{M} + O\left(\frac{dM^2}{M^2}\right)\right] R
\end{equation}
Thus
\begin{equation}
\frac{dR}{R} = \frac{R' - R}{R} = -\frac{dM}{M},
\end{equation}
and if we integrate both sides then we obtain
\begin{equation}
\ln R = -\ln M + \mbox{const} \qquad\Longrightarrow\qquad R' \propto \frac{1}{M}.
\end{equation}
Thus if we reduce the mass from $M$ to $\epsilon M$ but do it adiabatically, the radius changes from $R$ to $R/\epsilon$. The system remains bound at all times, and just expands smoothly.

These simple arguments would suggest that mass loss should produce a bound cluster if the star formation efficiency is $>1/2$ and/or the mass removal is slow, and an unbound set of stars if the efficiency is $<1/2$ and the mass removal is fast. In reality, life is more complicated than these simple arguments suggest, for a few reasons.

First, even if gas removal is rapid, some stars will still become unbound even if $\epsilon > 1/2$, and some will still remain bound even if $\epsilon < 1/2$. This is because the energy is not perfectly shared among the stars. Instead, at any given instant, some stars are moving faster than their average speed, and some are moving slower. Those that are moving rapidly at the instant when mass is removed will simply sail on out of the much-reduced potential well without sharing their energy, and thus can be lost even if $\epsilon > 1/2$. Conversely, the slowest-moving stars will not escape even if there is a very large reduction in the potential well, because they will not have time to acquire energy from the faster stars that escape. Thus for rapid mass loss, there is not a sharp boundary at $\epsilon = 1/2$. Instead, there is more of a smooth transition from no stars becoming unbound at $\epsilon \sim 1$ to no stars remaining at $\epsilon \sim 0$.

Second, we have done our calculations in a vacuum, but in reality star clusters exist inside a galactic potential, and this creates a tidal gravitational field. If a star wanders too far from the cluster, the tidal field of the galaxy will pull it off. Thus our conclusion that, in the adiabatic case, the cluster always remains bound and simply expands, must fail once the expansion proceeds too far. The outermost parts of the cluster will start to be stripped if they expand too far, and if the expansion proceeds so far that the mean density of the cluster becomes too low, it will be pulled apart entirely.

Third, the calculation we have just gone through assumes that the system starts in virial equilibrium, with the stars moving at the speed expected for virial balance. However, as we discussed before, this is not a good assumption: the stars have a much lower velocity dispersion than the gas when the cluster is young, and thus are much harder to unbind than the above argument suggests. If star formation continues for more than a single crossing time, this should become less and less of a problem as time passes and the stars are able to relax and dynamically heat up in the potential well of the gas. However, if star formation is ended very rapidly, in a crossing time, then the efficiency will have to be even lower than the value we have just estimated to be able to unbind the stars, since they are starting from much lower kinetic energies than they would have in virial balance.

\paragraph{The Cluster Formation Efficiency}

Given the theoretical modeling we have just performed, what can we say about what fraction of star formation will result in bound stellar clusters that will survive the initial gas expulsion? To address this question, we must be able to calculate the star formation efficiency, which is of course a very difficult problem, quite analogous to the problem of understanding what limits the rate of star formation overall. The answer almost certainly involves some sort of stellar feedback, so we can study a simple model for how that might work, drawn from \citet{fall10a}.

Let us consider a spherical gas cloud of initial mass $M$ and radius $R$, which begins forming stars. Star formation ends when the stars are able to inject momentum into the remaining gas at a rate high enough to raise that gas to a speed of order the escape speed in a time comparable to the crossing time. The requisite speed is
\begin{equation}
v_e \sim \sqrt{\frac{G M}{R}}.
\end{equation}
If the stellar mass at any given time is $\epsilon M$, then the momentum injection rate is
\begin{equation}
\dot{p} = \left\langle\frac{\dot{p}}{M_*}\right\rangle \epsilon M,
\end{equation}
where the quantity in angle brackets is momentum per unit time per unit stellar mass provided by a zero age population of stars. Thus our condition is that star formation ceases when
\begin{equation}
M v_e \sim \dot{p} t_{\rm cr} \sim \left\langle\frac{\dot{p}}{M_*}\right\rangle \epsilon M \frac{R}{v_e},
\end{equation}
where, since we are dropping factors of order unity, we have simply taken $t_{\rm cr} \sim R/v_e$.

Re-arranging, we conclude that star formation should cease and gas should be expelled when
\begin{equation}
\epsilon \sim \left\langle\frac{\dot{p}}{M_*}\right\rangle^{-1} \frac{v_e^2}{R} \sim \left\langle\frac{\dot{p}}{M_*}\right\rangle^{-1} G\Sigma,
\end{equation}
where $\Sigma \sim M/R^2$ is the surface density of the cloud.

Thus we expect to achieve a star formation efficiency of $\epsilon \sim 0.5$ when
\begin{equation}
\left\langle\frac{\dot{p}}{M_*}\right\rangle\sim G \Sigma.
\end{equation}
Just to give a sense of what this implies, we showed in \autoref{ch:feedback} that $\left\langle\dot{p}/M_*\right\rangle$ for stellar radiation is 23 km s$^{-1}$ Myr$^{-1}$, and plugging this in we obtain $\Sigma \sim 1$ g cm$^{-2}$. Thus regions with surface densities of $\sim 1$ g cm$^{-2}$ should be able to form bound clusters, while those with lower surface densities should not. This might plausibly explain why most regions do not form bound clusters.

However, this is an extremely crude calculation, and it assumes that one can define a well-defined "cloud" with a well-defined surface density. Real clouds, of course, have complex fractal structures. The suggested literature reading for this chapter, \citet{kruijssen12a}, is an attempt to develop a theory somewhat like this for a more realistic model of the structure of a cloud.

\paragraph{The Cluster Mass Function}

As a final topic for this chapter, what are the implications of this sort of analysis for the cluster mass function? Again, we will proceed with a spherical cow style of analysis. Consider a collection of star-forming gas clouds with an observed mass spectrum $dN_{\rm obs}/dM_g$. Each such cloud lives for a time $t_\ell(M_g)$ before forming its stars and dispersing, so the cluster formation rate is
\begin{equation}
\frac{dN_{\rm form}}{dM_g} \propto \frac{1}{t_{\ell}(M_g)} \frac{dN_{\rm obs}}{dM_g}.
\end{equation}

Now let $\epsilon$ be the final star formation efficiency for a cloud of mass $M_g$, and let $f_{\rm cl}(\epsilon)$ be the fraction of the stars that remain bound following gas removal. Thus the final mass of the star cluster formed will be
\begin{equation}
M_c = f_{\rm cl} \epsilon M_g.
\end{equation}
From this we can calculate the formation rate for star clusters of mass $M_c$:
\begin{eqnarray}
\frac{dN_{\rm form}}{dM_c} & = & \left(\frac{dM_c}{dM_g}\right)^{-1} \frac{dN_{\rm form}}{dM_g} \\
& \propto & \left[\epsilon f_{\rm cl} + \left(f_{\rm cl}+ \frac{df_{\rm cl}}{d\ln \epsilon}\right) \frac{d\epsilon}{d\ln M_g}\right]^{-1}
\nonumber \\
& & {} \cdot
\frac{1}{t_{\ell}(M_g)} \frac{dN_{\rm obs}}{dM_g}.
\end{eqnarray}

Let us unpack this result a bit. It tells us how to translate the observed cloud mass function into a formation rate for star clusters of different masses. This relationship depends on several factors. The factor $1/t_\ell(M_g)$ simply accounts for the fact that our observed catalog of clouds oversamples the clouds that stick around the longest. The factor $\epsilon f_{\rm cl}$ just translates from gas cloud mass to cluster mass. The remaining factor, $(f_{\rm cl} + df_{\rm cl}/d\ln\epsilon)(d\epsilon/d\ln M_g)$, compensates for the way the gas cloud mass function gets compressed or expanded due to any non-linear mapping between gas cloud mass and final star cluster mass. The mapping will be non-linear if the star formation efficiency is not constant with gas cloud mass, i.e., if $d\epsilon/d\ln M_g$ is non-zero.

Since observed gas cloud mass functions are not too far from the $dN/dM \propto M^{-2}$ observed for the final star cluster mass function, this implies that the terms in square brackets cannot be extremely strong functions of $M_g$. This is interesting, because it implies that the star formation efficiency $\epsilon$ cannot be a very strong function of gas cloud mass.


\documentclass[12pt]{article}
\input{physics1}
\begin{document}

\noindent
Name: \rule[-1ex]{0.55\textwidth}{0.1pt}
NetID: \rule[-1ex]{0.2\textwidth}{0.1pt}

\section*{NYU Physics I---Term Exam 1}

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
(From Problem Set 1, Problem~3)
Combine a mass $M$ and a length $h$ and an acceleration $g$ into
something that has units of time. You don't have to use all three
quantities if you don't need to.

\vfill

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
(From Problem Set 2, Problem~3)
Make a plot of the velocity $v_y$ against time $t$ for a stone thrown upwards
at speed $v_y = +5\,\mps$. Use as the acceleration due to gravity $a_y = -10\,\mpss$.
Plot for the time interval $0<t<1\,\s$.
Label your axes with sufficient precision that I can check your numbers.

\vfill

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
(From Lecture, 2018-09-11)
We spent time talking about two vectors, $\vec{v}_3$ and $\vec{v}_4$,
which were the velocities of the rock on a no-air-resistance trajectory.
What was wrong with this picture, that we drew?
\marginpar{\includegraphics[width=1in]{../jpg/wrong_vectors.png}}

\vfill

\clearpage
\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
(From Lecture, 2018-09-13)
A car is moving at constant speed $v$ along a horizontal, circular path
of radius $R$. Is there a non-zero net force on the car? Why?

\vfill

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
(From Lecture, 2018-09-18)
We gave three arguments that $g\,\sin\theta$ was a good guess for the
acceleration of a block down an inclined plane. The first argument was that it
has the right units! What were the other two arguments? \emph{Hint:} They were limiting
cases!

\vfill

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
(From recitation, week of 2018-09-10)
You made a table of times, accelerations, positions, and velocities.
If in the third row you had
\begin{equation}
t_3 = 0.3\,\s
\quad
a_3 = -10.0\,\mpss
\quad
v_3 = -2.0\,\mps
\quad
x_3 = 9.7\,\m
\quad ,
\end{equation}
then what would you write for $v_4$ in fourth row, which looks like
\begin{equation}
t_4 = 0.4\,\s
\quad
a_4 = -10.0\,\mpss
\quad
v_4 = \rule[-1ex]{20pt}{0.1pt}\,\mps
\quad
x_4 = \rule[-1ex]{20pt}{0.1pt}\,\m
\quad ?
\end{equation}

\vfill
~
\end{document}


\documentclass[11pt,a4paper]{article}

% These are extra packages that you might need for writing the equations:
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{float}
\usepackage{outlines}

\lstset {language=Python,
		 basicstyle=\ttfamily,
         keywordstyle=\color{blue}\ttfamily,
         stringstyle=\color{red}\ttfamily,
         commentstyle=\color{purple}\ttfamily,
         morecomment=[l][\color{magenta}]{\#},
       	 basicstyle=\tiny}

% You need the following package in order to include figures in your report:
\usepackage{graphicx}

% With this package you can set the size of the margins manually:
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\begin{document}

% Enter the exercise number, your name and date here:
\noindent\parbox{\linewidth}{
 \parbox{.25\linewidth}{ \large CSP, Exercise 04 }\hfill
 \parbox{.5\linewidth}{\begin{center} \large Beat Hubmann \end{center}}\hfill
 \parbox{.2\linewidth}{\begin{flushright} \large Mar 28, 2019 \end{flushright}}
}
\noindent\rule{\linewidth}{2pt}

\section{Introduction}

The Swendsen-Wang~\cite{swendsen} and the Metropolis algorithm were implemented
for the 3d Ising system to study autocorrelation behavior around the critical
temperature and Monte Carlo speed.

\section{Algorithm Description}
\subsection{Swendsen-Wang algorithm}

On the highest level, the Swendsen-Wang algorithm for the Ising model works as follows.
\begin{outline}
	\1 Consider bonds between two sites active
		\2 if the sites have the same spin state
		\2 with probability $p=1-e^{2\beta J}$
	\1 Identify clusters
	\1 Go through all clusters and flip each cluster with probability $p=0.5$
	\1 Repeat until desired number of sweeps
\end{outline}

The task of identifying clusters can be considered a subalgorithm: Historically,
the Hoshen-Kopelman algorithm is often used for identifying clusters in the lattice.
As it is somewhat cumbersome to implement in three dimensions and its main benefit
of efficient memory usage is no longer relevant these days, clusters were identified
using a generic Union-find Forest algorithm (of which Hoshen-Kopelman is a special case)
with path compression~\cite{galler}.
The cluster identifying algorithm works as follows:
\begin{outline}
	\1 Go through all lattice sites
	\1 For each site, consider the bonded neighbors established (see above)
	\1 Perform a union-find step on the site with each neighbor in turn:
		\2 Find respective cluster roots
		\2 Find respective cluster masses
		\2 Adopt the lighter of the two clusters into the heavier cluster
\end{outline}

\subsection{Metropolis algorithm}
The Metropolis algorithm was implemented as previously described in the report for exercise 1
of this course.

\section{Results}

The program was implemented as described above and submitted with this report.
For all experiments, the coupling constant $J$ was fixed to the simplest ferromagnetic value of $J=1.0$.
Experiments where run for system side lengths $L \in \{8, 12, 16, 20\}$ and temperatures $T \in \{3, 4, 4.4, 4.515, 4.6, 5, 6\}$.
For both algorithms, 20 samples each were taken and averaged (figures~\ref{fig:1} and~\ref{fig:2}).

% \begin{figure}[b]
% 	\centering
% 	\begin{subfigure}{.5\textwidth}
% 		\centering
% 		\includegraphics[width=0.9\textwidth]{E_d_L10_E2900.pdf}
% 	\end{subfigure}%
% 	\begin{subfigure}{.5\textwidth}
% 		\centering
% 		\includegraphics[width=0.9\textwidth]{E_d_L10_E2500.pdf}
% 	\end{subfigure}
% 	\begin{subfigure}{.5\textwidth}
% 		\centering
% 		\includegraphics[width=0.9\textwidth]{E_d_L10_E2000.pdf}
% 	\end{subfigure}%
% 	\begin{subfigure}{.5\textwidth}
% 		\centering
% 		\includegraphics[width=0.9\textwidth]{E_d_L10_E1500.pdf}
% 	\end{subfigure}
% 	\begin{subfigure}{.5\textwidth}
% 		\centering
% 		\includegraphics[width=0.9\textwidth]{E_d_L10_E1000.pdf}
% 	\end{subfigure}%
% 	\begin{subfigure}{.5\textwidth}
% 		\centering
% 		\includegraphics[width=0.9\textwidth]{E_d_L10_E500.pdf}
% 	\end{subfigure}
% 	\caption[short]{$P(E_d)$ plots for $L=10$}
% 	\label{fig:1}
% 	\end{figure}

\begin{figure}[b]
	\includegraphics[width=0.9\textwidth]{Swendsen_Wang.pdf}
	\caption[short]{Results for Swendsen-Wang algorithm}
	\label{fig:1}
\end{figure}

\begin{figure}[b]
	\includegraphics[width=0.9\textwidth]{Metropolis.pdf}
	\caption[short]{Results for Metropolis algorithm}
	\label{fig:2}
\end{figure}

Also, the autocorrelation $\rho_{MM}$ of magnetization $M$ was calculated once
thermalization was reached (figure~\ref{fig:3} and~\ref{fig:4}).

\begin{figure}[b]
	\centering
	\includegraphics[height=26cm]{autocorr_Swendsen_Wang.pdf}
	\caption[short]{Autocorrelation behavior for Swendsen-Wang algorithm}
	\label{fig:3}
\end{figure}

\begin{figure}[b]
	\centering
	\includegraphics[height=26cm]{autocorr_Metropolis.pdf}
	\caption[short]{Autocorrelation behavior for Metropolis algorithm}
	\label{fig:4}
\end{figure}

Finally, autocorrelation time $\tau$ at critical temperature
$T_c \approx 4.515$ then was extracted from
a semilog plot of $\rho_{MM}$ versus Monte Carlo time $t$ measured in steps per site using
the relationship $\rho_{MM} \sim e^{-t/\tau}$ (figure~\ref{fig:5} and~\ref{fig:6}).

\begin{figure}[b]
	\centering
	\includegraphics[width=0.7\textwidth]{tau_Swendsen_Wang.pdf}
	\caption[short]{Autocorrelation time for Swendsen-Wang algorithm}
	\label{fig:5}
\end{figure}

\begin{figure}[b]
	\centering
	\includegraphics[width=0.7\textwidth]{tau_Metropolis.pdf}
	\caption[short]{Autocorrelation time for Metropolis algorithm}
	\label{fig:6}
\end{figure}

A comparison of actual simulation runtimes gives $0.141s$/sweep for the Swendsen-Wang algorithm
at $T=4.515$ and $L=20$ and $0.232s$/sweep for the Metropolis algorithm also at $T=4.515$ and $L=20$.
For this temperature and lattice size, we thus get $\text{MC}_{\text{speed:S-W}} = \frac{1\ \text{sweep}}{0.141 \text{s}}\frac{1}{0.87\ \text{sweep}}= \frac{8.152}{s}$
and $\text{MC}_{\text{speed:Metropolis}} = \frac{1\ \text{sweep}}{0.232 \text{s}}\frac{1}{2.486\ \text{sweep}}= \frac{1.731}{s}$.

\section{Discussion}
The plots of the magnetization, the magnetic susceptibility and the Binder cumulant
seem as expected and in line with literature.
As expected, the autocorrelation behaviour shows critical slowing down for the Metropolis
algorithm around the critical temperature while the Swendsen-Wang algorithm remains largely unaffected.
The comparison of Monte Carlo speed shows that the Swendsen-Wang algorithm beats the metropolis
algorithm by a factor of 4.7 near critical temperature.\\
Qualitatively, all observations work out as expected from literature. However, the measured autocorrelation times
fall short of published values by a linear factor. In spite of spending a relevant amount of time looking for possible errors,
 I could not establish the reason.

\pagebreak
\begin{thebibliography}{99}

% \bibitem{creutz}
% 	Creutz, M.\\
% 	\emph{Microcanonical Monte Carlo Simulation},\\
% 	Phys. Rev. Lett. American Physical Society. 50 (19): 1411–1414,\\
% 	1983.

% \bibitem{herrmann}
% 	Herrmann, H. J.,
% 	Singer, H. M.,
% 	Mueller L.,
% 	Buchmann, M.-A.,\\
% 	\emph{Introduction to Computational Physics - Lecture Notes},\\
% 	ETH Zurich,\\
% 	2017.

\bibitem{metropolis}
	Metropolis, N.;
	Rosenbluth, A.W.;
	Rosenbluth, M.N.;
	Teller, A.H.;
	Teller, E.\\
	\emph{Equations of State Calculations by Fast Computing Machines},\\
	Journal of Chemical Physics. 21 (6): 1087\\
	1953.

\bibitem{swendsen}
	Swendsen, R. H.; Wang, J.-S.\\
	\emph{Nonuniversal critical dynamics in Monte Carlo simulations}\\
	Phys. Rev. Lett., 58(2):86–88\\
	1987

\bibitem{boettcher}
	Boettcher, L.,\\
	\emph{Computational Statistical Physics - Lecture Notes},\\
	ETH Zurich,\\
	2019.

\bibitem{galler}
	Galler, B. A.; Fischer, M. J.\\
	\emph{An improved equivalence algorithm},\\
	Communications of the ACM. 7.: 301–303,\\
	1964

\end{thebibliography}

\end{document}


\documentclass[12pt,a4paper]{article}
\setlength{\topmargin}{-5mm}
\setlength{\textheight}{244mm}
\setlength{\oddsidemargin}{0mm}
\setlength{\textwidth}{165mm}

\usepackage{fancyvrb}
\DefineVerbatimEnvironment{verbatim}{Verbatim}{xleftmargin=4mm}

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{pxfonts}
\usepackage{textcomp}

\title{``white'' versus ``brown'' noise in roguelike maps}
\author{Jeremy Mates}
\date{May 13, 2018}

\usepackage{hyperref}
\hypersetup{pdfauthor={Jeremy Mates},pdftitle={``white'' versus ``brown'' noise in roguelike maps}}

\begin{document}
\bibliographystyle{plainnat}
\maketitle

\setlength{\parindent}{0pt}

\section*{White noise}

is simply random\cite{bulmer2000music}. In the context of a roguelike
given a grid of arbitrary size white noise may be achieved by placing
objects randomly on the grid. The file \texttt{noise.lisp} details the
complete code; only snippets will be shown here.

\begin{verbatim}
(defparameter *rows*  20)
(defparameter *cols*  72)

(defparameter *board* (make-array (list *rows* *cols*) ...)

(dotimes (n 100))
  (setf (aref *board* (random *rows*) (random *cols*)) #\x)))
\end{verbatim}

This produces no apparent pattern (and a human may dismiss it as ``oh,
random'').

\begin{verbatim}
...xxx...............................x..x......x..............x.........
.............x....x...............x................................x....
.........................xx...............x..........x.........x........
....x................x.....x.x............x.........x.....x..........x..
............xx...............x..........................................
..x...............................................................x..x..
....x.................................................................x.
............................................x..............xx...........
...............x............x....................................x......
......x...........x...x.......x............x.................x..........
...............x.............................x.....................x....
.x....x.................................xx..x..............x.....x......
......................x....x.........x..........x.x.................x...
.x.x................................xx...xx.x.........x...x.............
.........................x..............................................
x....x.....................................x.....x.............x........
......x......................x..x..........................x............
...............................................x........................
..............xxx......x..............x......x...........x............x.
............x......x.........x.......x.....x...................x......x.
\end{verbatim}

\section*{Brown noise}

by contrast will locate each new object relative to the previous object.
Care must be taken that the objects do not walk off of the grid (unless
they wrap around) and that there is no bias (unless such is desired)
that makes the walk favor a particular direction.

\begin{verbatim}
(defun if-legal (new max)
  (and (>= new 0) (< new max) new))

(defun nearby (x max range)
  (do ((new nil))
    ((numberp new) new)
    (setf new (if-legal (+ x (- (random range)
                                (truncate (/ range 2)))) max))))

(let ((r (random *rows*)) (c (random *cols*)))
  (dotimes (n 100)
    (setf (aref *board* r c) #\x)
    (setf r (nearby r *rows* 5))
    (setf c (nearby c *cols* 9)))))
\end{verbatim}

A notable feature here is that the randomization is different for the
rows and columns; rows move $\pm 2$ and columns $\pm 4$. Neither this
nor the previous implementation care if an object overwrites another.

\begin{verbatim}
......................................xx.x....x.......x.................
..................................x..xx..x...xx.x.x.....x...............
.......................................xxx.xx..........x................
.....................................xx.xx.................xx...........
......................................x..x..x..........x..x.............
...........................................x............................
...............................................x......xxx...............
.............................................xxxx.......................
............................................x..x.x.x......x.............
...........................................x.x.xx...x...................
............................................x.......x.........x.........
...........................................x.xx.......x........x........
....................................................xx..................
....................................................x.x............x....
.................................................x................xx....
...................................................x...x..........x...x.
........................................................x.x...........x.
.....................................................x........x..x.x....
........................................................x..xx...........
.........................................................x...xxxx.x.....
\end{verbatim}

This is obviously quite different from the white noise; moreover,
repeated runs of the white noise version will look more or less the same
while the brown noise will vary greatly depending on the starting point
and exact sequence of random values.

With multiple object types the differences between white and brown noise
can be made most notable; instead of \texttt{x} the following place
plants, fungus, and rocks.

\begin{verbatim}
............#.......P.....................f..f......#P..f........P..#..P
.......#...P...........#.........P....P..PP........f......P..#...P..#..f
.....P..P.P..........#f.f.f...f............#....#P...#..f..#............
f.P.P..#..f#...#.....P........#....#....f.P.fP...P....#f......f.f#.f....
...#.P.f...#.P.....P............f......P...............f.f...f..........
#...................Pf.....................#.....#...f.f.P.........f...P
.....#................P.f#...#..f.............#...#.f.#f...f......f....P
..P....Pf........ff.................f#.........ff..##.f........#........
.P.....#..#...P..........f.....f.......f.P...#ff.#..#.#.............f...
..f.P...#f..........fP.....f............#......fP....#..................
...f......P....f.....f.P...#....P...........P.P..f..P#.......P..........
....#.f#........#......f..f...fP......f.....P..#.#........#..##......#.P
#ff......#......#................f.................#....................
.....P........@.......#.P......P....P..f......#...........#.............
.#f#..#..........f....P..f....P...P.....P.P.P...P..P....#.......f.....#.
.........P...f......P....##....P#......#....P..#.#......fP..........#...
#f....f.....#.P.........f#...#..f#P...#........#............PP....f....#
.P...................f.#......f.....P..P.f...f.#....###....f........f..f
.PP.#PP.#..............##..#P.#...................................fP..#.
.#...#...................#..P....f...........f.......#.P...P....P.f.P..f
\end{verbatim}

and a brown noise version

\begin{verbatim}
......f......ff...f.ff........#...#####.................................
......f.....ff.......##............##.#.#.#.............................
...f...f..f.....f....#..#..#...######.#..##.............................
..........f.......#....#...#..##....###.#...............................
f...f....ff.......#......#...###.##.##.##...............................
......f...........#...#..#.#....#.#.#.................f.................
.f..................P...#..#.##..#.#####..#.............................
..................P....P.......###....##...#.........f..................
.P.P.f..P.....P.......P..P..##..#.#.....#................f..............
.P..P.....P..............#..#.##.......#...............f.f.f............
....P..fP..........P.P.PP.P###.............#............f..f............
..P...P.PP.fP....PP..P........#.............................f...........
....PP.f..f...@...f..Pf.....PP..............ff.f..............f.........
...PP..PP...f.....P..P.Pf.................f.f.f..........f..f..f........
P.P...P........f...f.f...f..............f........fff.f..................
.P.PPPP.........fP...f...f..f....ff.....f.f.f.f..f.fff..................
..PPP...P....................f......f.....f.f.f.ff.f..f.................
PPPPPP...P......P..PP......f..........f.f.f.......f..f..................
PPPPPPP.PP..............................f.f...f..ff...f.................
P.P.PPP.....P..............................fff..........................
\end{verbatim}

Other complications are possible under brown noise. The
randomization rules could vary depending on the object, or could
vary over time\textendash close randomization punctuated by the
occasional long leap would be an obvious thing to try (this may
approach ``pink noise'').

\section*{Evolved landscapes}

may in part replicate the real world; a first pass could use white
noise to distribute a random spread of colonizing species, and
subsequent passes use brown noise to place secondary growth. One could
also include rules for shade, nutrients, etc. though a simple mix of
white and brown noise will likely produce acceptable results. The
following used 3\% plants (white noise), 10\% fungus (brown noise), and
20\% rocks (brown noise).

\begin{verbatim}
..P...........................P.....P..f.Pfff.ff..f#f#f..#.fff.ff...ff.P
.............................................ff.ffff#fffff..f#f..##..#fP
................P...........P......P....ff......f.f.f#..ff.f..#..#.#...#
..............P.............................fP.ffff.#f#fffff...#.#####..
..........................P........................f#..##f#.#f....###..#
.........................P..P.................f..f#..#.#f#f#P.#.####.#..
.P.................P.................................ff...###f##..#.##..
.........................PP..........................#.#.####.###.......
...................................................P#..##.####.##.###.#.
..............@....................P..........#........##.#####.##......
..P.....P...........................P......##.......#.#.###.....###..#..
..........P........................P...P.#......#######.#...#.#.#..#...#
..............P..........P...................##.#.########.##.###.#.#.#.
...........................P..........#...#.....###.#.##.#..####.#......
\end{verbatim}

Cleanup passes may be required to sculpt the random results; look at
cellular automata algorithms for examples. Pathfinding may also need to
be done if an impassible map is not desired: hunting trails could be
carved out to join areas together. The real world does have various
amounts of impassable terrain; having some inaccessible areas may add
realism or interest to a game. (Note that while it may warm your black
heart to have \textit{The +17 Grand Scythe of Über Slaying} generate in
an inaccessible area players tend to be critically lacking in humor over
such quirks of the RNG\ldots)

\hskip 1.5em%
An improvement might be to generate random numbers of fungus and rocks
from random starting points, and using different rules for how much the
fungus and rocks can move. Code that does this can be found in
\texttt{noise.lisp}.

\begin{verbatim}
........#.......##...fPf..........f....P.........f.f.####.f.fPf.f...f...
.......#.#.#P..####..f#ff...f.f...................##..##..f...f......fff
.P...#.####......#.###.#fff.P.....PP.........fPff..##.......ff..f..f..ff
......###...........###.#.f.f.f.........ff.f#.....f#.ff...fff..ffff....f
......#...........P..###...................##.f.......f.ff.f......f.f...
................f...f##ff##.f........f...ff..#f......f.ff....f.f.f.f....
...#..........@...ff###.###..f.....f...f..f...f...f...f.ff.Pff..f...#..#
....####..........####..####f..fffff..f.ff.fff...f.........f...f..f.####
..###.###.......P....#...#f#f.f.......f...f..........#..f.ffff....f..###
..##.####.##.............#.##f..f......f.ff.........#.#..f.ff.fff..f####
..##..#.########....ff.##f###f.f.f.....f....f...P###..##...ff.f..ff#f#f.
...#.....#####.#.f..f#####.##f.ff..fff.f.#f.....###...##.ff.fffffff####.
.P..#.#fff.##ff......#######...f..f.f...P#.#...........###.f.ff..f#f###f
....##.###ff...........f.####..fff....f..####.P......ff###ff.f.f..f#f.#.
\end{verbatim}

\section*{Vaults}

enclose a particular amount of space with a particular structure; the
structures or rooms may be pre-designed or could be generated by some
algorithm. Either the vault or the noise could be drawn first,
depending on whether a definite vault structure or a ruin now overrun
by jungle is necessary. Some vaults may designate what points are
available to be filled in; these would be used to mask where the noise
is allowed to appear.

\begin{verbatim}
##.####    white ##.####    brown ##.####
##...##    noise ##.f.##    noise ##.f.##
#.....#     fill #...f.#     fill #.....#
#......          #....f.          #.f..f.
#.....#          #.....#          #.....#
##...##          ##f..##          ##.f.##
#######          #######          #######
\end{verbatim}

White noise will benefit smaller vaults where there is not enough space
available for a pattern to emerge. The above both used a 20\% fill (some
fungus were drawn under the walls) of which the white noise is much more
efficient to generate. If a human cannot tell the difference, use the
less expensive function.

\section*{Other improvements}

would be to where necessary maintain a count of objects placed; this
count could be used to ensure that the field has a suitable texture:
loop placing different types of objects, check the object count, repeat
if the output is still too sparse. This will be necessary if routines
with a high degree of variance are used (a 10\% chance of ending itself
\texttt{decay} function usually exits well before 20 iterations, until
it does not\ldots) or if the object placing functions only place a
fraction of the total required.

\hskip 1.5em%
The code used here does not check if a square is already occupied by
something; these checks will be necessary if there are structural
elements that must not change, or skipped if ornamental lichen are being
placed on an otherwise empty field.

\hskip 1.5em%
``Pink noise'' was alluded to above; this might be an interesting
line of study. For more information, see the

\bibliography{references}

\end{document}