\chapter{Appendix: LEMUR Results}
\label{chap:appendix-utility}

\begin{figure*}
   \begin{widepage}
   \begin{center}

   \includegraphics{build/lemur-sq/herb-master}

   \caption[Experimental results across six single-query motion planning
      instances for a 7-DOF robot arm.
      Top: expected planning cost $p$ (in seconds)
      vs. execution cost $x$ (in radians) for each parameterized
      planner for various values of their parameters.
      Bottom: the mean negative utility
      $-U = \lambda_U p + (1\!-\!\lambda_U) x$
      (solid lines) measured for each planner
      (lower on plot is better) as the
      utility parameter $\lambda_U$ is varied.
      The 95\% confidence interval of the mean is also shown.
      Planners used the same parameter schedule across the problems
      as shown in Figure~\ref{fig:herbarm-schedules}.
      The per-problem maximum achievable mean utilities
      (\ref{eqn:oracle-param-schedule})
      for each planner are shown as dotted lines.
      Planners are RRT-Connect with shortcutting, BIT*,
      LEMUR (no roadmap cache), and LEMUR (with roadmap cache).
   ][-30cm]{x}
   \label{fig:lemur:sq-herb-master}

   \end{center}
   \end{widepage}

   \vspace{0.1in}
   \smallskip\noindent\small Figure \ref{fig:lemur:sq-herb-master}:
      Experimental results across six single-query motion planning
      instances for a 7-DOF robot arm.
      Top: expected planning cost $p$ (in seconds)
      vs. execution cost $x$ (in radians) for each parameterized
      planner for various values of their parameters.
      Bottom: the mean negative utility
      $-U = \lambda_U p + (1\!-\!\lambda_U) x$
      (solid lines) measured for each planner
      (lower on plot is better) as the
      utility parameter $\lambda_U$ is varied.
      The 95\% confidence interval of the mean is also shown.
      Planners used the same parameter schedule across the problems
      as shown in Figure~\ref{fig:herbarm-schedules}.
      The per-problem maximum achievable mean utilities
      (\ref{eqn:oracle-param-schedule})
      for each planner are shown as dotted lines.
      Planners are
      \protect\tikz{\protect\node[fill=red,draw=black]{};}\;RRT-Connect with shortcutting,
      \protect\tikz{\protect\node[fill=green,draw=black]{};}\;BIT*,
      \protect\tikz{\protect\node[fill=blue,draw=black]{};}\;LEMUR (no roadmap cache),
      and \protect\tikz{\protect\node[fill=black!80,draw=black]{};}\;LEMUR (with roadmap cache).

\end{figure*}

\begin{figure*}
   \begin{widepage}
   \begin{center}

   \includegraphics{build/lemur-sq/herb-timing}

   \caption[Time breakdown of LEMUR for each of the six
      experimental problems across various values of $\lambda_p$.
      Cumulative time is shown performing the following operations:
      roadmap generation, graph search, collision checking, and unaccounted for.
      The bottom row shows the results of the algorithm over the same
      set of 50 roadmaps when reading the cached roadmap from disk
      to avoid online nearest-neighbor queries.
   ][-30cm]{x}
   \label{fig:lemur:sq-herb-timing}

   \end{center}
   \end{widepage}

   \vspace{0.1in}
   \smallskip\noindent\small Figure \ref{fig:lemur:sq-herb-timing}:
      Time breakdown of LEMUR for each of the six
      experimental problems across various values of $\lambda_p$.
      Cumulative time is shown performing the following operations:
      \protect\tikz{\protect\node[fill=red!20,draw=black]{};}\;roadmap generation,
      \protect\tikz{\protect\node[fill=blue!20,draw=black]{};}\;graph search,
      \protect\tikz{\protect\node[fill=green!20,draw=black]{};}\;collision checking,
      and \protect\tikz{\protect\node[fill=black!20,draw=black]{};}\;unaccounted for.
      The bottom row shows the results of the algorithm over the same
      set of 50 roadmaps when reading the cached roadmap from disk
      to avoid online nearest-neighbor queries.

\end{figure*}

\begin{figure*}
   \begin{widepage}
   \centering
   \includegraphics{build/lemur-sq/workcell-master}
   \end{widepage}
   \caption{Summary of $p$-vs-$x$ and utility results for each step in the
      workcell problem.}
   \label{fig:lemur:sq-workcell-master}
\end{figure*}

\begin{figure*}
   \begin{widepage}
   \centering
   \includegraphics{build/lemur-sq/workcell-timing}
   \end{widepage}
   \caption{Timing results for each step in the workcell problem.}
   \label{fig:lemur:sq-workcell-timing}
\end{figure*}


% This LaTeX was auto-generated from an M-file by MATLAB.
% To make changes, update the M-file and republish this document.

      \subsection{calcCost.m}

\begin{par}
\textbf{Summary:} Function to calculate the incurred cost and its standard deviation, given a sequence of predicted state distributions and the cost struct
\end{par} \vspace{1em}
\begin{verbatim}[L sL] = calcCost(cost, M, S)\end{verbatim}
\begin{par}
\textbf{Input arguments:}
\end{par} \vspace{1em}
\begin{verbatim}cost               cost structure
M                  mean vectors of state trajectory (D-by-H matrix)
S                  covariance matrices at each time step (D-by-D-by-H)\end{verbatim}
\begin{par}
\textbf{Output arguments:}
\end{par} \vspace{1em}
\begin{verbatim}L                  expected incurred cost of state trajectory
sL                 standard deviation of incurred cost\end{verbatim}
\begin{par}
Copyright (C) 2008-2013 by Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen.
\end{par} \vspace{1em}
\begin{par}
Last modified: 2013-01-23
\end{par} \vspace{1em}

\subsection*{High-Level Steps}

\begin{enumerate}
\setlength{\itemsep}{-1ex}
   \item Augment state distribution with trigonometric functions
   \item Compute distribution of the control signal
   \item Compute dynamics-GP prediction
   \item Compute distribution of the next state
\end{enumerate}

\begin{lstlisting}
function [L sL] = calcCost(cost, M, S)
\end{lstlisting}

\subsection*{Code}

\begin{lstlisting}
H = size(M,2);                                             % horizon length
L = zeros(1,H); SL = zeros(1,H);

% for each time step, compute the expected cost and its variance
for h = 1:H
  [L(h),d1,d2,SL(h)]  = cost.fcn(cost, M(:,h), S(:,:,h));
end

sL = sqrt(SL);                                         % standard deviation
\end{lstlisting}


\documentclass[main.tex]{subfiles}
\begin{document}

% \section*{Thu Oct 17 2019}

% \marginpar{Thursday \\ 2019-10-17, \\ compiled \\ \today}

\section{Measuring distances} \label{sec:measuring-distances}

We want to be able to compute the comoving radius, given our knowledge of the evolution of the distribution of energy density in time.

% We will neglect spatial curvature.
We have shown that the luminosity distance is given by:
%
\begin{equation}
  d_L \equiv \sqrt{\frac{L}{4 \pi \ell}}
  = a_0 (1+z) r(z)
\,.
\end{equation}

Also recall \emph{conformal time} \(\eta\), which is defined by its relation to cosmic time, \(a(\eta ) \dd{\eta} = \dd{t}\): it allows us to write the FLRW metric as
%
\begin{equation}
  \dd{s^2} = a^2(\eta ) \qty(c^2 \dd{\eta^2} - \frac{\dd{r^2} }{1 - k r^2} - r^2 \dd{\Omega^2} )
\,.
\end{equation}

This is very important when we talk about massless particles, with no intrinsic length scale: the photon, which is our primary tool for astrophysical observations, is one of them.
This can be written in terms of the variable \(\chi\):
%
\begin{equation}
  \dd{s^2}  = a^2(\eta ) \qty(c^2 \dd{\eta^2} - \dd{\chi^2} - f^2_k (\chi ) \dd{\Omega^2})
\,,
\end{equation}
%
where \(f_k(\chi )=r\) is equal to \(\sin(\chi ) \), \(\chi \) or \(\sinh(\chi )\) if \(k\) is equal to \(1\), \(0\) or \(-1\); in other words we either have \(\chi = \arcsin(r)\), \(\chi = r\) or \(\chi = \operatorname{arcsinh}(r)\).

If we look at photons moving radially we do not need to account for the angular part, and we find
%
\begin{equation}
  \dd{s^2} = 0 = a^2(\eta ) \qty(c^2 \dd{\eta^2} - \dd{\chi^2})
\,,
\end{equation}
%
therefore \(c^2 \dd{\eta^2} = \dd{\chi^2}\):  we get \(c \qty(\eta (t_0 ) - \eta (t_e)) = \chi (r_e) - \chi (r_0 )\), where a subscript \(e\) means ``emission'', while a subscript \(0\) means detection.
We are choosing the negative sign when simplifying the square, since the problem we are considering is that of radiation starting from an astrophysical source and coming towards us: its radial coordinate \(\chi \) decreases when the temporal coordinate \(\eta \) increases.

This means that we can find out the comoving distance \(\Delta \chi \) between two events by calculating the difference between their comoving times \(\Delta \eta \).
This is what was meant by the fact that this expression of the metric is useful for massless particles: the scale factor gets factored out, we can write the expression in a very simple way.

\begin{equation}
  \dd{\eta} = \frac{\dd{t} }{a}  = \frac{\dd{a} }{a \dot{a} }
\,,
\end{equation}
%
and now recall \((1+z) = a_0 / a\): we differentiate this with respect to time to find
%
\begin{equation}
  \dv{z}{t} = - \frac{a_0 }{a^2} \dot{a} = - \frac{a_0 H(z)}{a}
\,,
\end{equation}
%
% \begin{equation}
%   \frac{\dd{a}}{a^2} = \frac{\dd{a} (1+z)^2}{a^2} = - \frac{\dd{z}}{ a_0 }
% \,,
% \end{equation}
% %
% which means
% %
% \begin{equation}
%   \dd{e} = - \frac{\dd{z}}{a_0 H(z)}
%   \,.
% \end{equation}
which means
%
\begin{align}
\dd{\eta } = \frac{ \dd{t}}{a} = - \frac{ \dd{z}}{a_0 H(z)}
\marginnote{Took the inverse of the equation, split the differentials, used the definition of \(\eta \)}
\,,
\end{align}
%
so we get our final expression:
%
\begin{align}
\dd{ \chi  } = \frac{c \dd{z}}{a_0 H(z)} \marginnote{Used the fact that \(\dd{\chi } = - c \dd{\eta }\).}[.2cm]
\,.
\end{align}

So, if we can find a way to parametrize the Hubble parameter \(H(z)\) in terms of the redshift we will be able to measure distances.
% \todo[inline]{??? probabily there is wrong stuff here}

The Hubble parameter is given by
%
\begin{equation}
  H^2= \frac{8 \pi G}{3} \rho - \frac{k c^2}{a^2}
\,,
\end{equation}
%
where the density comes from several components: \(\rho (t) = \rho _r (t) + \rho _m (t) + \rho _\Lambda \), where the first term is the density of radiation and scales like \(a^{-4}\), the second is the density of matter and scales like \(a^{-3}\), the third is the density of dark energy and is constant.

In terms of the redshift, they scale like \((1+z)^{4}\), \((1+z)^{3}\) (and \((1+z)^{0}\)) respectively.

We express the Hubble parameter as a multiple of its value now: \(H(z) = H_0 E(z)\), where \(E(z)\) is a dimensionless function.

Recall the definition of \(\Omega (t)\): it describes the ratio of the density of a certain type of fluid to the critical density. We can look at the \(\Omega_i (t)\) for \(i\) corresponding to matter, radiation and so on:
%
\begin{equation}
  \Omega _i (z) = \frac{8 \pi G \rho _i (z)}{3 H^2(z)}
  = \frac{8 \pi G \rho_{i}(z=0)}{3 H_0 ^2} \times  \frac{\rho _i (z) / \rho_{i}(z=0)}{E^2(z)}
  = \Omega _{i,0} \frac{(1+z)^{\alpha }}{E^2(z)}
\,,
\end{equation}

where \(\alpha \) is the exponent of the scaling of the fluid: \(\alpha = 4\) for radiation, \(\alpha = 3\) for matter, \(\alpha = 0\) for the cosmological constant \(\Lambda \), while for spatial curvature \(\alpha = 2\).

For the \(\Omega \) corresponding to the curvature we define: \(\Omega _k = - k c^2/(a^2 H^2)\) (see equation \eqref{eq:spatial-curvature-effective-density}).

We must have
%
\begin{equation}
  1 = \Omega _r + \Omega _m + \Omega _\Lambda + \Omega _k
\,.
\end{equation}

We can write an expression for \(E^2(z)\) by taking the ratio of the densities at emission versus now:
%
\begin{equation}
  E^2(z) = \frac{H^2}{H_0^2} =
  \Omega _{\Lambda , 0} +  \Omega_{m, 0} (1+z)^{3}
  +\Omega_{r, 0} (1+z)^4 + \Omega _{k, 0} (1+z)^2
\,,
\end{equation}
%
and to get \(E\) we just take the square root.

Now we can finally compute our integral
%
\begin{equation}
  \chi (z) = \frac{c}{a_0 H_0 } \int_{0}^{z} \frac{\dd{z'} }{E(z')}
\,,
\end{equation}
%

therefore
%
\begin{equation}
  r = f_k \qty(\frac{c}{a_0 H_0 } \int_0^z \frac{\dd{z'}   }{E(z')})
\,.
\end{equation}
%

This does depend on \(k\), but the differences between positive and negative curvature are only relevant starting from third order: regardless of the curvature, \(f_k\) is close to the identity for small \(z\).
If the curvature is zero, we get the comoving distance:
%
\begin{align}
d_C = r a_0 = \frac{c}{H_0 } \int_{0}^{z} \frac{ \dd{z'}}{E(z')}
\,.
\end{align}

If the curvature is not zero, we can still define a useful distance: the \emph{transverse comoving distance},
%
\begin{align}
d_M = a_0 r = a_0 f_k \qty(\frac{c}{a_0 H_0 } \int_0^z \frac{\dd{z'}   }{E(z')})
\,;
\end{align}
%
for \(k=0\) these two coincide.

% \todo[inline]{Right? I didn't write this down but it seems natural.}

% Two weeks ago we defined the luminosity distance: now we can compute it.

Now,  suppose we are looking at a certain far-away object with angular size \(\Delta \theta \) and linear size \emph{at emission} of \(\Delta x\): then the \emph{angular diameter distance} is given, in the small-angle approximation, by
%
\begin{equation}
d_A = \frac{ \Delta x}{\Delta \theta } = a(t_e) r
= \frac{a_0 r_z}{1+z} = \frac{d_M}{1+z}
\,.
\end{equation}

Since the luminosity distance is given by
%
\begin{equation}
 d_L = a_0 (1+z) r = d_M (1+z)
\,
\end{equation}
%
their ratio is
%
\begin{equation}
  \frac{d_L}{d_A} = (1+z)^2
\,.
\end{equation}

% \todo[inline]{This part is kind of confused, I think the concepts are well explained but there is some reorganization to do.}

% \todo[inline]{Add summary of cosmological distances, with explanation of their physical meaning, drawing from \cite{hoggDistanceMeasuresCosmology2000} and \cite{davisExpandingConfusionCommon2004}.}

\begin{figure}
\begin{tabular}{p{2.5cm}p{5cm}p{7cm}}
Distance name & Formula & Description\\
\hline
Comoving \newline distance  & \(d_C = r a_0\) \newline \( = \frac{c}{H_0 }\int_{0}^{z} \frac{ \dd{z'}}{E(z')}\) & Distance in comoving coordinates multiplied by the current scale factor: if the expansion of the universe froze during our measurement, this is the distance we would measure between the two events. Assumes \(k=0\). \\ \hline
Transverse \newline comoving \newline  distance  & \(d_M = r a_0\) \newline \( = a_0 f_k \qty(\frac{c}{H_0 a_0  }\int_{0}^{z} \frac{ \dd{z'}}{E(z')})\) & Generalization of the comoving distance to \(k \neq 0\). \\ \hline
Luminosity \newline  distance  & \(d_L = d_M (1+z)\)
\newline \(= \sqrt{L / (4 \pi \ell)}\) & Distance defined so that the radiative intensity we measure follows the inverse square law. \\ \hline
Angular \newline diameter \newline  distance  & \(d_A = d_M (1+z)^{-1}\)
\newline \(= \Delta x / \Delta \theta \) & Distance defined by the ratio of a far-away object's size (measured using the scale factor at the time of the emission of the radiation we observe now) to its angular size.
\end{tabular}
\label{tab:cosmological-distances}
\caption{A summary of the cosmological distances we defined, drawing on the summary by Hogg \cite[]{hoggDistanceMeasuresCosmology2000}.}
\end{figure}

\section{The cosmological constant} \label{sec:cosmological-constant}

Einstein thought that the universe had to be static: it was a common notion at the time that it should be, almost a philosophical principle.\footnote{An interesting historical fact: this was corroborated by a calculation error on Einstein's part, which was later pointed out by Friedmann. Einstein thought \cite{einsteinCommentFriedmannPaper1922} that \(\nabla_{\mu } T^{\mu \nu }= 0\) implied \(\partial_{t} \rho =0\), while Friedmann pointed out \cite{friedmannAlexanderFriedmann1922} that the correct equation reads \( \partial_{t} \qty(\sqrt{-g} \rho ) =0\): the density of the universe is not forced to be time independent if the determinant of the metric changes accordingly. Even the best make mistakes.}
Now we know that the universe is neither static nor stationary.\footnote{The distinction between static and stationary is subtle but significant \cite{ludvigsenGeneralRelativityGeometric1999}: \emph{stationarity} is about the existence of a timelike Killing vector, while \emph{staticity} is about the timelike Killing vector being orthogonal to spacelike submanifolds.
A concrete example: Schwarzschild geometry is both static and stationary, Kerr geometry is stationary but not static, FLRW geometry is neither, since there is no timelike Killing vector field.}

So, he sought static solutions (\(a = \const\)) for matter (\(P=0\)) to the Friedmann equations \eqref{eq:friedmann-equations}: if we set \(\dot{a} = \ddot{a} = 0\)
the third equation becomes \(\dot{\rho}= 0\), the second equation gives us \(\rho \equiv 0\), and from the first we must also have \(k=0\): the only way to have a static matter-filled universe is for the density of matter to be zero, and for the spatial curvature to be also zero.

In order to satisfy what he thought was an empirical fact, Einstein modified his equations in order to get a static non-empty solution.

The Einstein equations, from which the Friedmann ones are derived, read
%
\begin{equation}
  G_{\mu \nu } = 8 \pi G T_{\mu \nu }
\,,
\end{equation}
%
when \(c=1\), where the Einstein tensor \(G_{\mu \nu }\) can be defined in terms of the Ricci curvature tensor \(R_{\mu \nu }\) and the scalar curvature \(R\) as:
%
\begin{equation}
  G_{ \mu \nu } = R_{\mu \nu } - \frac{1}{2} g_{\mu \nu }R
\,.
\end{equation}

This peculiar construction is the only one which can be made in terms of the curvature tensor and which is covariantly constant: \(\nabla_{\mu } G^{\mu \nu } = 0\).
This is a necessary condition since \(\nabla_{\mu } T^{\mu \nu }=0\): the Einstein equations state that they are proportional, so if we take the covariant derivative of the equations we must get the identity \(0=0\).
% \footnote{This is the historical approach; nowadays it is more common for people to start by assuming that the Einstein equations hold; to derive the law \(\nabla_\mu T^{\mu \nu } = 0\) from there. }

% \begin{bluebox}
% Here, \(R = g^{\mu \nu } R_{\mu \nu }\) is the scalar curvature, while \(R_{\mu \nu } = R^{\rho }_{\mu \rho \nu }\) is the Ricci tensor, and finally \(R^{\mu }_{\nu \rho \sigma }\) is the Riemann tensor, defined in terms of the affine connection \(\Gamma^{\mu }_{\nu \rho }\) as
% %
% \begin{align}
% R^{\mu }_{\nu \rho \sigma } = -2 \qty(\Gamma^{\mu }_{\nu [\rho , \sigma ]} + \Gamma^{\alpha }_{\nu [\rho } \Gamma^{\mu }_{\sigma ] \alpha })
% \,,
% \end{align}
% %
% where commas denote coordinate differentiation. The connection \(\Gamma^{ \mu }_{\nu \rho } \)
% \end{bluebox}

Einstein added a term \(- \Lambda g_{\mu \nu }\) to the LHS of the Einstein equations, with \(\Lambda \) a constant scalar. This is allowed since

\begin{enumerate}
  \item it is tensorial (since it is a scalar multiple of the metric, which is a tensor);
  \item it is symmetric;
  \item it has zero covariant divergence, since \(\Lambda \) is constant and the metric is covariantly constant \(\nabla_{\mu } g^{\mu \nu } = 0\).
\end{enumerate}

Then, we can rewrite the EE in two equivalent ways: either
%
\begin{align}
\widetilde{G}_{\mu \nu } &= 8 \pi G T_{\mu \nu } &\text{with}&& \widetilde{G}_{\mu \nu } &= G_{\mu \nu } - \Lambda g_{\mu \nu }  \\
G_{\mu \nu } &= 8\pi G \widetilde{T}_{\mu \nu } &\text{with}&&
\widetilde{T}_{\mu \nu } &= T_{\mu \nu } + \frac{\Lambda g_{\mu \nu }}{8 \pi G}
\,.
\end{align}
%

In the first interpretation, the cosmological constant is an intrinsic geometric property of spacetime; in the second interpretation cosmological constant is a particular kind of fluid, with the property of its contribution to the stress-energy tensor always being a constant multiple of the metric.

In order to find out what the properties of this fluid are, we compare its stress-energy tensor to a generic ideal fluid tensor:
%
\begin{equation}
T_{\mu \nu }^{\text{(generic)}} = \left[\begin{array}{cccc}
\rho & 0 & 0 & 0 \\
0 & P & 0 & 0 \\
0 & 0 & P & 0 \\
0 & 0 & 0 & P
\end{array}\right]
\qquad \qquad
T^{(\Lambda )}_{\mu \nu } = \frac{\Lambda g_{\mu \nu }}{8 \pi G} = \frac{\Lambda}{8 \pi G} \left[\begin{array}{cccc}
1 & 0 & 0 & 0 \\
0 & -1 & 0 & 0 \\
0 & 0 & -1 & 0 \\
0 & 0 & 0 & -1
\end{array}\right]
\,,
\end{equation}
%
so the corrections to the stress energy tensor must be \(\rho \rightarrow \rho + \Lambda/ 8 \pi G \) and \(P \rightarrow P - \Lambda  / 8 \pi G\), or, in other words, the density and pressure of the ``cosmological constant fluid'' are \(\rho_{\Lambda } = - P_{\Lambda } = \Lambda/8\pi G\).
This proves that the equation of state of the cosmological constant is \(w = -1\).

Inserting this into the Friedmann equations we get:
%
\begin{align}
  \qty(\frac{\dot{a} }{a})^2 &=
  \frac{8 \pi G}{3} \rho + \frac{\Lambda }{3}
  - \frac{k}{a^2} \label{eq:friedmann-1-cosmological-constant}\\
  \frac{\ddot{a}}{a}  &= - \frac{4 \pi G}{3} \rho + \Lambda \label{eq:friedmann-2-cosmological-constant}\\
 \dot{\rho} &= -3 \frac{\dot{a}}{a }\qty(\widetilde{\rho} + \widetilde{P}) = -3 \frac{\dot{a}}{a} \qty(\rho + P)\label{eq:friedmann-3-cosmological-constant}
\,,
\end{align}
%
and we can see that in the third equation, the effect of the source is encompassed in a term \(\widetilde{\rho }  + \widetilde{P} \): the two \(\Lambda \) terms cancel, since they are opposite.
For a cosmological constant-dominated universe --- that is, for a universe in which the only fluid behaves like the cosmological constant -- we have \(\dot{\rho} = \dot{P} = 0\).

So, proceeding with the derivation by Einstein, we set \(\dot{a}= \ddot{a} =0 \): for the first Friedmann equation we get
%
\begin{equation}
  \frac{8 \pi G}{3} \rho + \frac{\Lambda}{3} = \frac{k}{a^2}
\,,
\end{equation}
%
and for the second:
%
\begin{equation}
  4 \pi G \rho = \Lambda
\,.
\end{equation}

So, we substitute the expression for \(4 \pi G \rho \) into the first Friedmann equation:
%
\begin{equation}
  \frac{2}{3} \qty(4 \pi G \rho ) + \frac{\Lambda}{3} =
  \Lambda \qty(\frac{1}{3}+ \frac{2}{3}) = \Lambda = \frac{k}{a^2}
\,.
\end{equation}

What are the physical conclusions to draw?
Since we want matter in the universe we must have \(\rho >0\), which implies \(\Lambda >0\), which implies \(k =1\): so the universe must be closed.

Friedmann studied perturbations around this solution and found it to be unstable: so, it is not suitable as a description of the universe.
This, combined with the observations by Hubble of an expanding universe, prompted the scientific community to discard the idea of a stationary universe in favor of an expanding one.

Einstein probably \cite{autInvestigatingLegendEinstein2018} called the introduction of the cosmological constant into the equation his ``greatest blunder''; however in modern cosmology the idea of a cosmological constant has gained new vigor: we observe the universe's expansion to be accelerated, that is \(\ddot{a} > 0\), and the only way for this to be the case if \(\rho >0\) is if \(\Lambda > 0\) as well.
It is the only kind of fluid which has a repulsive gravitational effect.

As opposed to the approach by Einstein, in which the cosmological constant was inserted to stationarize the universe, we make it a measurable parameter of our theory.

A candidate for the cosmological constant term, which is a kind of intrinsic energy of space, is the vacuum energy in Quantum Field Theory: however, the estimate we get when trying to make this quantitative is around \num{e120} times the measured value of \(\Lambda \).

% The next topic is a solution of the Friedmann equations.
% We will try to do it with \(p=0\): \(\rho \propto a^{-3}\).

\end{document}


%
%  set up at April 4th, 2009
%
%
%
\chapter{Second Quantization Methods}
%
%
%
The second Quantization methods is one of the powerful tools used in
relativistic quantum theory and quantum field theory, where the
physical problems that actually involves creation or destruction of
particles, photons, etc. In a majority of the applications of the
second quantization techniques to quantum-chemical problems, no
electrons or other particles are created or destroyed. Thus, this
method usually serve merely as a convenient and operationally useful
approach. However, this methods deeply simplifies the discussion about
the system involving many identical interacting particles; e.g., the electrons
in the molecules.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{General Discussion}
%
%
%
Now let's define some operator which is called ``creation operator'':
$\hat{r}^{+}$. This operator is used to generate an electron which is on orbital
of $\varphi_{r}$. Here we note that compared with traditional notion which
requires the label of electron, the creation operator does not need it anymore.
Hence we can generally express the Slater determinant of $\Phi$ as:
\begin{equation}
 \label{second_quantization_general_discussion:1}
\Phi = \frac{1}{\sqrt[2]{n!}} \left | \begin{array}{cccc}
  \varphi_{1}(1) & \varphi_{2}(1) & \cdots & \varphi_{n}(1) \\
  \varphi_{1}(2) & \varphi_{2}(2) & \cdots & \varphi_{n}(2) \\
  \cdots & \cdots & \cdots & \cdots                        \\
  \varphi_{1}(n) & \varphi_{2}(n) & \cdots & \varphi_{n}(n)
\end{array} \right | =
\hat{n}^{+}\cdots\hat{3}^{+}\hat{2}^{+}\hat{1}^{+}\ket{vac}
\end{equation}
Again we follow the convention that to use a, b, c etc. to designate the virtual
orbitals, the i, j, k etc. to refer to the occupied orbitals; and p,
q, r etc. to specify the general orbitals. What's more, we note that
$\hat{2}^{+}\hat{1}^{+}\ket{vac}$ denotes that firstly to generate an electron
in the $\varphi_{1}$, then to generate another electron in $\varphi_{2}$.

Compared with the traditional Slater determinant expression in
(\ref{second_quantization_general_discussion:1}), the most important thing is
that the Slater determinant satisfies the Pauli principle that if we exchange
two electrons in the wave function, then the wave function should change its
sign. Hence how can we express it in the second quantization?

For the creation operator, it generally follows the rule that:
\begin{equation}
  \label{second_quantization_general_discussion:2}
\hat{r}^{+}\hat{s}^{+} + \hat{s}^{+}\hat{r}^{+} = [\hat{r}^{+}\hat{s}^{+}]_{+}
= 0
\end{equation}
We note that it gives the Pauli principle. Let's generally consider some wave
function in second quantization: $\Phi
=\hat{r}^{+}\cdots\hat{s}^{+}\hat{t}^{+}\hat{u}^{+}\ket{vac}$,

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../../main"
%%% End:


\chapter{State of the Art}

In this section, the background to the state of the art in machine learning and recommendation systems will be presented.
In particular, the use of machine learning algorithms as the content filtering component of recommendation systems will be discussed.
The different approaches to machine learning and recommendation systems will also be introduced and then discussed in detail.

\section{Background}
In 1947, Alan Turing presented a lecture to the London Mathematical Society in which he theorised that it would be possible for a machine to learn from it's experiences.
In Turing's example, he proposed that learning was a prerequisite for a true intelligent system \cite{Turing1946}.
Turing further expanded on the concept of an intelligent machine in his 1950 paper in which he proposed a theoretical test, called the "imitation game", to identify whether machines could be considered intelligent \cite{Turing1950}.
This test has since become known as the Turing test.

Machine learning and recommendation systems can be viewed as semi-intelligent machines which try to learn from data fed into them\cite{mlTutorial}.
These machines are replacements for human operators who would have had to classify data or suggest recommendations in the past.
One of the main reasons machines are used, instead of humans for this task is largely due to the volume of data available\cite{lops}.
Another factor to consider is the quality of results obtained from the system.
Humans, for example, can possibly be biased in their opinion when presenting their results or findings.
A machine on the other hand should generate it's results using the model it has created using only the data that has been presented to it.
This approach is less likely to be skewed by a bias when the model has been created using a balanced dataset\cite{FProvost2000}.

\section{Machine Learning}
Machine learning is an interdisciplinary field concerned with the study of self learning systems.
Machine learning has applications in fields such as: statistics, mathematics, computer vision, game theory, information retrieval, software engineering, sentiment analysis, and artificial intelligence\cite{mlTutorial}.

Machine learning algorithms try to build a model of a dataset by learning the patterns in the data.
The resulting model created by many machine learning algorithms can then output seemingly intelligent results for data that it has never seen before.

Machine learning can be split into three different types of learning:
\begin{itemize}
    \item Supervised learning
    \item Reinforced learning
    \item Unsupervised learning
\end{itemize}

\subsection{Supervised learning}
Supervised learning is a machine learning technique which tries to create a model which maps inputs to desired outputs.
This can be represented as a function f(x) which maps an input \(x_i\) to an output \(y_i\).
This is achieved by using a training set T = \((x_i, y_i)\) and a learning algorithm.
The learning algorithm produces a function \(\hat{f}(x_i)\) which can then be modified in response to the difference between \(y_i - \hat{f}(x_i)\)\cite{mlTutorial}.

\subsection{Reinforced learning}
Reinforced learning is a machine learning technique where the machine interacts with an environment and produces actions \(a_i\).
This set of actions interact with the environment which in turn results in the machine receiving rewards \(r_i\) from a rewards function.
The machine tries to learn how to create actions which maximizes the future return on rewards\cite{mlTutorial}.

\subsection{Unsupervised learning}
Unsupervised learning is a machine learning technique which tries to find hidden patterns in data.
An unsupervised learning algorithm receives inputs \(x_i\) but receives no desired outputs nor rewards.
The machine tries to build a probabilistic model of the data or it uses clustering to partition the data in categories\cite{mlTutorial}.

The main difference between unsupervised techniques and other techniques is the lack of a clear measure of success.
This poses a problem when comparing the accuracy of different unsupervised techniques.
The effectiveness of unsupervised techniques therefore relies heavily on heuristic approaches when judging their quality\cite{elementsStat}.

The research conducted in this project is focused on the unsupervised approach to machine learning.
Due to the fact that there is no gold standard to compare the quality of the similarity results, their effectiveness will be a matter of opinion.
Where possible the results will also be compared against any possible meta-data to help judge their effectiveness.

\section{Recomendation Systems}
Recommendation systems are algorithms and techniques which try to generate recommendations for users.
The design of recommendation systems is an interdisciplinary field which touches upon information retrieval, human computer interaction, machine learning, data mining, etc.
These systems often try to generate recommendations based on similarities between users or between content.
There are two main approaches used in recommendation systems\cite{recHandbookIntro}:

\begin{itemize}
    \item Collaborative-filtering
    \item Content-filtering
\end{itemize}

\subsection{Collaborative-filtering}
Collaborative-filtering is an approach used by recommendation systems which tries to generate recommendations by comparing user data with other users.
The rationale behind this approach is to find similarities and differences  between different groups of users and build a user model.
Once users have been grouped together, recommendations can be generated based on what similar users have liked and disliked.
This type of recommendation system has been used extensively by Amazon when generating recommendations\cite{recHandbookIntro}.

The main problem with this approach is that it requires a huge amount of initial data in order to generate appropriate recommendations.

\subsection{Content-filtering}
Content-filtering is an approach used by recommendation systems which learns to generate recommendations based on a users previous interactions with an item.
This approach tries to learn the features of items in order to generate recommendations for items with similar features\cite{recHandbookIntro}.

Unlike collaborative-filtering a huge amount of user data is not required for content-filtering.
The recommendations for this approach can be generated by building a model using the individual item features.

The research conducted in this project is focused entirely on the information filtering component of a content-filtering recommendation system.
The research project conducted was based on a potential user being a student.
However all of the algorithms investigated could be used in content-filtering recommendation systems to filter recommendations based on the content of the items.

\section{State of the Art}
This research project is investigating the performance of Latent Dirichlet Allocation (LDA), k-Nearest-Neighbour (k-NN) and Word2Vec as the content-filtering component of a recommendation system.
Each of these algorithms have applications in information retrieval and are not just confined to the field of recommendations systems nor to an educational corpus.

\subsection{Latent Dirichlet Allocation}
LDA is a probabilistic model for any discrete data. In this research project and in most of the literature reviewed, textual data has been used.
LDA was introduced in 2004 by Blei, Ng and Jordan as an improvement on Deerwester's Latent Semantic Indexing (LSI) and on Hofmann's later Probabilistic Latent Semantic Indexing (pLSI).
LDA was created in response to two problems identified with pLSI; the number of parameters in the model grew linearly with the size of the corpus, and it was unclear as to how to assign a probability to a document that the model had never seen before\cite{LDAintro}.

LDA is hierarchical model which assumes that documents contain a mixture of topics and that topics are a mixture of word probabilities.
LDA is also a bag-of-words (bow) model which assumes that the topics are generated first and then documents are generated from these topics.
These assumptions are used when inferring topics as it is a reversing of the generation process\cite{LDAintro}.

LDA has been used in the past on a corpus of 17,000 articles from the magazine Science, with 100 topics.
The LDA model that was generated using this corpus was fed an unseen article on genome mapping and sequencing.
The distribution of topics in the article were then calculated and graphed.
It was found that the topics which seemed to be about; genetics, evolution, disease, and computers had a high concentration in the article\cite{ACMTopicModel}.

In a similar study to the above, LDA was applied to 21,434 articles from Science to create 50 topics.
The purpose of this experiment was to infer the most relevant topics from a document and then to find the most similar documents.
An article on Statistical Significance in Protein and DNA sequencing was used to generate recommendations for articles related to protein sequencing, genome sequencing and sampling strategies.

This research project used the LDA implementation from the Gensim Python library.
Gensim is a library which was originally created in 2008 to find similar articles in the Czech Digital Mathematics Library.
Gensim was chosen as it allows the creation of an LDA model which is memory independent of the size of the input corpus.
As the original intention for Gensim was to generate recommendations for academic articles, this influenced the choice of the library.\cite{rehurek_lrec}

\subsection{k-Nearest-Neighbours}
k-Nearest-Neighbours is a model free algorithm for classification and pattern recognition.
In k-Nearest-Neighbour classifiers when given a query point \textit{x}, the \textit{k} nearest points in distance to \textit{x} are used to classify \textit{x}.
When \textit{k} is 1, the query point \textit{x} is classified as being the same as the point nearest to it.
When \textit{k} is a value greater than 1 a simple majority vote of the \textit{k} nearest points can be used to classify \textit{x}.\cite{elementsStat}

When k-Nearest-Neighbours is applied to high-dimensional feature space, the distance between the k-nearest-neighbours can be quite high, causing bias and a degradation of performance.\cite{elementsStat}
An approach to try and overcome the distance problem is to weight each of the k nearest neighbours vote based on their distance to the query point \textit{x}.\cite{top10datamining}

Despite the simplicity of the approach used by k-NN it has been featured as one of the top algorithms to use in data-mining.\cite{top10datamining}
For this research project k-NN was not used to classify documents into predefined classes.
Instead k-NN was used to find the k-nearest documents to a query document.
This clustering of documents is based on the assumption that the k-nearest documents in feature space will be similar to the query document.

\subsection{Word2Vec}
Word2Vec is an algorithm introduced in 2013 by Mikolov which uses a simple neural network to learn continuous vector representations of words.
These vector representations of words can be used to describe the similarity between words.
Words which are spatially close in this representation can described as being semantically close, while words which are spatially distant can be described as being semantically different.
We also have the benefit of being able to apply algebraic operations to these  word vectors.
This was shown intuitively by Mikolov as: \textit{King - Man + Woman” = Queen} and by \textit{Madrid - Spain + France = Paris}.

By training the word vectors using a neural network we are able to learn the multiple degrees of similarity between words\cite{Mikolov1}.
The result is a vector representation which can encode linguistic patterns and regularities.\cite{Mikolov2}
A small problem with Mikolov's original word2vec paper was that the algorithm created a word based model.
The algorithm was later extended by Mikolov to allow word and phrase based models.\cite{Mikolov2}

The research project conducted used the word2vec implementation from the Gensim Python library.
The Gensim library contains a word2vec and a doc2vec implementation. The word2vec implementation follows Mikolov's original word base model while the doc2vec implementation is based on Mikolov's later phrase base model.\cite{radimDoc2Vec}
The later doc2vec implementation is the one which is being investigated by this project.

\section{Conclusion}
The field of machine learning and recommendation systems is vast and the number of techniques and approaches which could be used is equally as vast.
From the research conducted the scope of this project has been narrowed down to focus on the performance of three relevant algorithms: LDA, k-NN, and word2vec.
These three algorithms are quite different in their implementations and have different applications outside the scope of this project.
It is hoped that by focusing the research on these algorithms, it will be possible to successfully analyse the performance of some of the best algorithms, to use for the content-filtering component of a recommendation system.