% Created: Enze Chen, June 2017
% Last edited: Enze Chen, December 2017
%
% Chapter 6 of the MSE 142 coursereader. This chapter discusses parabolic potentials and the quantum harmonic oscillator. Students are introduced to operators, and in particular use the ladder operators to solve the Schrodinger equation. A wealth of additional properties are rather lamely appended to the last section.

% Uncomment the following three lines and last line to individually compile this chapter
%\documentclass[12pt, english]{book}
%\usepackage{142crstyle}
%\begin{document}

\chapter{Quantum Harmonic Oscillators} \label{ch:qho}
%{ \doublespacing
In this chapter, we will consider what happens when a particle is placed in a parabolic potential, which lacks the sharp discontinuities present in previous examples. We will see some pretty amazing behavior when we try to solve the \Sch\ equation for this non-constant potential, which will give us a much better understanding of quantization in quantum mechanical systems.

\section{Parabolic potential}
Consider a one-dimensional quadratic potential energy surface given by $V(x)=\frac{1}{2}kx^2$ which is typically associated with harmonic oscillators. Like the simple harmonic oscillator (see Appendix~\ref{sec:shm} for a short review), the \textbf{quantum harmonic oscillator} (QHO) also has an effective spring constant $k$ and an associated angular frequency $\omega$ that is related by $\omega = \sqrt{k/m}$. The QHO is a powerful model for things like the forces that hold atoms together in materials and any potential surface near a local minimum (Figure~\ref{fig:qpot}).

\begin{figure}[!h]
	\centering
	\subfloat[]{\raisebox{1.7\height}{\includegraphics[width=0.25\linewidth]{atoms-spring}} \label{fig:qho-mod1}} \hspace{4ex}
	\subfloat[]{\includegraphics[width=0.43\linewidth]{qpot-min} \label{fig:qho-mod2}}
	\caption{The quantum harmonic oscillator is particularly powerful at modeling \protect\subref{fig:qho-mod1} the forces that hold atoms together, which are often approximated with springs, and \protect\subref{fig:qho-mod2} the minima of any generic potential surface, which is approximately parabolic when one considers the Taylor series near the minimum.}
	\label{fig:qpot}
\end{figure}

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

\section{Operators}
In order to work with the QHO, we will have to revisit the concept of \textbf{operators}, which are just special functions that represent physical observables. If we represent the quadratic potential energy in terms of angular frequency, i.e. $V(x)=\frac{1}{2}m\omega^2x^2$, we can then represent the Hamiltonian of the particle, which is the sum of the kinetic and potential energies, as
\begin{tcolorbox}[title = Hamiltonian for the QHO] \vspace{-2ex}
	\begin{equation}
	\hat{H} = \frac{\hat{p}^2}{2m} + \frac{1}{2}m\omega^2x^2 \label{eq:ham-qho}
	\end{equation}
\end{tcolorbox}

Notice that in the first term, we used $\hat{p}$ to represent the momentum operator, which is defined as $\hat{p}=-i\hbar\dv{x}$.\footnote{Technically position here is also an operator $\hat{x}$, but it happens to be defined as $\hat{x}=x$, so we substitute.} Now we need to solve the time-independent \Sch\ equation, given by:
\begin{tcolorbox}[title = \Sch\ equation for the QHO] \vspace{-2ex}
	\begin{equation}
		\hat{H}\Psi = -\frac{\hbar^2}{2m}\dv[2]{\Psi}{x} + \frac{1}{2}m\omega^2x^2\Psi = E\Psi \label{eq:se-qho}
	\end{equation}
\end{tcolorbox}

Recall that this form for the operator $\hat{p}$ was motivated by the first wave equation we wrote down, corresponding to the free particle. This was an expression of the form $\exp\left(i(kx-\omega t)\right) = \exp \left( \frac{i}{\hbar}(px-Et) \right)$. If we act on this wave equation with the operator $\hat{p}$ defined as above, we get the same function back multiplied by $p$:
\begin{align*}
	\hat{p}\exp \left(\frac{i}{\hbar}(px-Et)\right) &= -i\hbar\exp \left(\frac{i}{\hbar}(px-Et)\right) \left(\frac{ip}{\hbar}\right) \\
	&= p\exp \left(\frac{i}{\hbar}(px-Et)\right)
\end{align*}
One can think of this as essentially representative of what it means to make a measurement of the momentum in a quantum mechanical system. \par

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

\subsection{Ladder operators}
In order to solve Equation~\ref{eq:se-qho}, we will attempt to \emph{factor} the Hamiltonian given by Equation~\ref{eq:ham-qho}. To see the motivation behind this, notice that if the Hamiltonian was given by two real numbers $c^2+d^2$, we could then factor this expression as
\begin{equation*}
	c^2 + d^2 = (c + di)(c - di)
\end{equation*}

Following this example, we first reformulate the Hamiltonian so that we can factor it as follows:
\begin{align*}
	\hat{H} &= \frac{\hat{p}^2 }{2m} + \frac{1}{2}m\omega^2\hat{x}^2 \\
	&= \frac{m\omega^2}{2}\left[\hat{x}^2 + \frac{\hat{p}^2}{m^2\omega^2}\right] \\
	&= \frac{m\omega^2}{2}\left[\hat{x} + \frac{i\hat{p}}{m\omega}\right] \left[\hat{x}-\frac{i\hat{p}}{m\omega}\right] \numberthis \label{eq:ham-factored}
\end{align*}

\emph{A word of caution}: Though it seems straightforward, we actually hand-waved a lot of the rigor here, because dealing with operators (which are functions) is trickier than dealing with real quantities. The theory is outside the scope of this course, but we will see shortly how this affects what are normally intuitive results. \par

Now, the factored Hamiltonian in Equation~\ref{eq:ham-factored} is suggestive of some form of symmetry, particularly the expressions inside the square brackets. We are now going to define two new operators
\begin{tcolorbox}[title = Ladder operators] \vspace{-2ex}
	\begin{align}
		a &= \sqrt{\frac{m\omega}{2\hbar}}\left(\hat{x} + \frac{i\hat{p}}{m\omega}\right) = \sqrt{\frac{m\omega}{2\hbar}}\left(\hat{x} + \frac{\hbar}{m\omega}\dv{x}\right) \label{eq:annihile} \\
		\ad &= \sqrt{\frac{m\omega}{2\hbar}}\left(\hat{x} - \frac{i\hat{p}}{m\omega}\right) = \sqrt{\frac{m\omega}{2\hbar}}\left(\hat{x} - \frac{\hbar}{m\omega}\dv{x}\right) \label{eq:creation}
	\end{align}
\end{tcolorbox}

The method we are using to solve the \Sch\ equation involves these two \textbf{ladder operators} $a$ and $\ad$ (called ``a-dagger''), which are known as the \textbf{annihilation}/\textbf{lowering} operator and \textbf{creation}/\textbf{raising} operator respectively (you will soon see why). This clever method was developed by Paul Dirac\footnote{Dirac was extremely influential in developing the formalism of quantum theory, introducing this and bra-ket notation which you will see later. He shared the 1933 Nobel Prize in Physics with \Sch. Curiously, Einstein describes that ``[he has] trouble with Dirac. This balancing on the dizzying path between genius and madness is awful.'' (N. Sukumar, \emph{A Matter of Density}, 2012).} and allows us to eventually solve for the energy without directly solving the \Sch\ equation. Note that we chose the coefficient of $\sqrt{m\omega/2\hbar}$ largely for the purpose of eliminating constants in the end.

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

\subsection{Hamiltonian revisited}
We see that the ladder operators are individually defined in terms of the position and momentum operators, so why not try solving for them? If we add Equation~\ref{eq:annihile} and~\ref{eq:creation}, we get
\begin{equation*}
	a + \ad = \sqrt{\frac{m\omega}{2\hbar}}2\hat{x}
\end{equation*}
which allows us to solve for the position operator as
\begin{tcolorbox}[title = Position operator] \vspace{-2ex}
	\begin{equation}
		\hat{x} = \sqrt{\frac{\hbar}{2m\omega}}\left(\ad + a \right) \label{eq:x-op}
	\end{equation}
\end{tcolorbox}

Similarly, we can subtract the two ladder operators to get
\begin{equation*}
	a - \ad = \sqrt{\frac{m\omega}{2\hbar}} \frac{2i\hat{p}}{m\omega}
\end{equation*}
which gives the momentum operator as
\begin{tcolorbox}[title = Momentum operator] \vspace{-2ex}
	\begin{equation}
	\hat{p} = i\sqrt{\frac{m\omega\hbar}{2}}\left(\ad - a \right) \label{eq:p-op}
	\end{equation}
\end{tcolorbox}

OK, so why might this be useful? Let's rewrite the Hamiltonian in terms of these new operators:
\begin{align*}
	\hat{H} &= \frac{\hat{p}^2}{2m} + \frac{1}{2}m\omega^2\hat{x}^2 \\
	&= -\frac{1}{2m}\frac{m\omega\hbar}{2}\left(\ad - a\right)^2 + \frac{1}{2}m\omega^2 \frac{\hbar}{2m\omega} \left(\ad + a \right)^2 \\
	&= -\frac{\hbar\omega}{4} \left(\left(\ad\right)^2 - \ad a - a\ad + a^2\right) + \frac{\hbar\omega}{4}\left(\left(\ad\right)^2 + \ad a + a\ad + a^2 \right) \\
	\Aboxed{ \hat{H} &= \frac{\hbar\omega}{2} \left( \ad a + a\ad \right)} \numberthis \label{eq:ham-qho2}
\end{align*}

Now, we might be tempted to combine the $\ad a$ term with the $a \ad$ term, but this is one of the tricky aspects of operators: in general, \textbf{they do not commute} with each other, so we can't expect them to represent the same quantity when we switch the order. \par

Of course, we shouldn't be fazed by this fact and we will try to see if we can find some relationship between the two terms. Luckily, in quantum mechanics, there is a quantity called the \textbf{commutator} (adopted from group theory) that precisely indicates to what degree two operators fail to commute. Given two operators $A$ and $B$, we define the commutator as
\begin{equation}
	[A,B] = AB - BA \label{eq:comm}
\end{equation}
which you can see for normal variables should be zero. \par

As a first example, let's consider the commutation relation between $\hat{x}$ and $\hat{p}$, i.e. $[\hat{x}, \hat{p}]$. To aid the derivation, we will have both operators act on an arbitrary dummy function $\Psi$ that we will discard in the end.
\begin{align*}
	[\hat{x}, \hat{p}]\Psi &= (\hat{x}\hat{p})\Psi - (\hat{p}\hat{x})\Psi \\
	&= x\left(-i\hbar \dv{x}\Psi \right) + i\hbar \dv{x}(x\Psi) \\
	&= -i\hbar x \dv{x}\Psi + i\hbar x \dv{x}\Psi + i\hbar\Psi \\
	&= i\hbar\Psi
\end{align*}

From this, one then concludes that
\begin{tcolorbox}[title = Canonical commutation relation] \vspace{-2ex}
	\begin{equation}
		[\hat{x}, \hat{p}] = i\hbar
	\end{equation}
\end{tcolorbox}

which is known as the \textbf{canonical commutation relation} because it establishes a fundamental relationship between two conjugate variables, such as $\hat{x}$ and $\hat{p}$, that eventually leads to the uncertainty principle. \par

Now what about the commutation relation between $a$ and $\ad$? The result actually follows nicely from the canonical commutation relation. First, we also show that if two operators can be expressed as $f+g$ and $f-g$, where $f$ and $g$ are arbitrary operators, then their commutation relation can be simplified as follows:
\begin{align*}
	[f+g,f-g] &= (f+g)(f-g) - (f-g)(f+g) \\
	&= f^2 - fg + gf -g^2 - f^2 - fg + gf + g^2 \\
	&= 2(gf - fg) \\
	&= 2[g,f]
\end{align*}

We can apply this result to find that
\begin{align*}
	[a, \ad] &= \frac{m\omega}{2\hbar}\left[\hat{x} + \frac{i\hat{p}}{m\omega}, \hat{x} - \frac{i\hat{p}}{m\omega} \right] \\
	&= \frac{m\omega}{\hbar} \left[ \frac{i\hat{p}}{m\omega}, \hat{x} \right] \\
	&= \frac{i}{\hbar}[\hat{p},\hat{x}] \\
	&= \frac{i}{\hbar}(-i\hbar)
\end{align*}

\begin{tcolorbox}[title = Ladder operators commutation relation] \vspace{-2ex}
	\begin{equation}
		[a,\ad] = a\ad - \ad a = 1  \label{eq:a-comm}
	\end{equation}
\end{tcolorbox}

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

\section{Solutions of the QHO}
We're almost there! Now using this commutation relation, we can rewrite Equation~\ref{eq:ham-qho2} in its standard form. In particular, using the fact that $a\ad = 1 + \ad a$, we find that
\begin{tcolorbox}[title = Hamiltonian of the QHO (with ladder operators)] \vspace{-2ex}
	\begin{equation}
	\hat{H} = \hbar\omega \left(\ad a + \frac{1}{2} \right) \label{eq:ham-qho3}
	\end{equation}
\end{tcolorbox}

OK, now let's try to understand why all of the above definitions and mathematics are useful in terms of solving the QHO problem. To begin with, let's rewrite the time-independent \Sch\ equation in terms of these new variables. We have:
\begin{equation}
\hbar\omega \left(\ad a + \frac{1}{2} \right)\psi_n = E_n\psi_n \label{eq:sch-qho}
\end{equation}
where we have introduced a quantum number $n$ as an index for the allowed solutions of this equation, just like we did for the particle in a box. Now let's act from the left on Equation~\ref{eq:sch-qho} with the lowering operator $a$, carefully keeping track of the order of the operators since we know they don't commute with each other (but they can commute with scalars, like the energy $E_n$). This gives
\begin{align*}
\hbar\omega \left(\ad a + \frac{1}{2} \right)\psi_n &= E_n\psi_n \\
\hbar\omega \left(a \ad a + \frac{1}{2} a\right)\psi_n &= E_na\psi_n \\
\hbar\omega \left(\left(1 + \ad a \right) a + \frac{1}{2} a\right)\psi_n &= E_na\psi_n \\
\hbar\omega \left(1 + \ad a + \frac{1}{2} \right) a\psi_n &= E_na\psi_n \\
\Aboxed{\hbar\omega \left(\ad a + \frac{1}{2} \right) (a\psi_n) &= (E_n-\hbar\omega)(a\psi_n)} \numberthis \label{eq:sch-qho2}
\end{align*}

If we look carefully at this equation and compare it to Equation~\ref{eq:sch-qho}, we see that they are the same form! This says in particular that if $\psi_n$ is a solution of the QHO with energy $E_n$, then $a\psi_n$ is also a solution, with energy $E_n-\hbar\omega$. This is a key result and explains why $a$ is called the lowering operator. From a known solution one can essentially generate all other known solutions of lower energy by applying this operator. This is quite handy!

So imagine that one starts from some known solution and starts applying this operator, generating lower and lower energy states. At some point one must find the ground state solution. But what happens if one then applies the lowering operator to this? If this gives some new function, then this can't really have been the ground state! We therefore conclude that the ground state wave function must satisfy the simple equation
\begin{equation*}
a\psi_0 = 0
\end{equation*}

Here you can really see how we have successfully factorized the initial second order differential equation (Equation~\ref{eq:se-qho}) to obtain a solution for the wave function. In particular, we can use the right hand side of Equation~\ref{eq:annihile} to substitute for the lowering operator $a$ and obtain a first order differential equation:
\begin{equation*}
	\left(x + \frac{\hbar}{m\omega} \dv{x}\right)\psi_0 = 0
\end{equation*}

We can solve this using separation of variables as follows.
\begin{align*}
	\left(x + \frac{\hbar}{m\omega} \dv{x}\right)\psi_0 &= 0 \\
	\frac{\hbar}{m\omega} \dv{\psi_0}{x} &= -x\psi_0 \\
	\frac{1}{\psi_0} \dd{\psi_0} &= -\frac{m\omega}{\hbar}x \dd{x} \\
	\ln (\psi_0) &= -\frac{m\omega}{2\hbar}x^2 \\
	\Aboxed{\psi_0 &= A \exp \left(-\frac{m\omega}{2\hbar}x^2\right)} \numberthis
\end{align*}

We have to normalize the wave function the same way we always do, which allows us to solve for $A$ as
\begin{align*}
	\int_{-\infty}^{\infty} \abs{\psi_0}^2 \dd{x} &= 1 \\
	\abs{A}^2 \int_{-\infty}^{\infty} \exp \left(-\frac{m\omega}{\hbar} x^2 \right) \dd{x} &= 1 \\
	\abs{A}^2 \sqrt{\frac{\pi\hbar}{m\omega}} &= 1  \tag{We use $\displaystyle\int_{-\infty}^{\infty}e^{-ax^2} \dd{x} = \sqrt{\frac{\pi}{a}}$}\\
	\Aboxed{A &= \left(\frac{m\omega}{\pi\hbar}\right)^{1/4}} \numberthis
\end{align*}

Combining these two results finally gives us
\begin{tcolorbox}[title = Ground state for the QHO] \vspace{-2ex}
	\begin{equation}
		\psi_0 = \left(\frac{m\omega}{\pi\hbar}\right)^{1/4} \exp \left(-\frac{m\omega}{2\hbar}x^2\right) \label{eq:qho-ground}
	\end{equation}
\end{tcolorbox}

One can easily substitute this back into the \Sch\ equation to verify this does indeed solve the differential equation. A sketch of this wave function has a Gaussian shape within the boundary of the potential with probability maximized at the center of the quadratic potential, analogous to the equilibrium position of the effective mass on a spring (Figure~\ref{fig:qho-ground}). The key difference between this state and its classical analogue is that the quantum ground state has non-zero energy.

\begin{figure}[!h]
	\centering
	\includegraphics[width=0.38\linewidth]{qho-ground}
	\caption{A sketch of the ground state of the particle inside the parabolic potential. The wave function has a Gaussian profile within the parabolic potential and it is centered about the minimum.}
	\label{fig:qho-ground}
\end{figure}

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

\subsection{Zero-point energy}
What is the energy of the particle in this ground state? One can substitute Equation~\ref{eq:qho-ground} into the differential equation and solve for $E_0$, or explicitly solve Equation~\ref{eq:sch-qho} when $n=0$. Both approaches work, and we will proceed with the latter approach to obtain
\begin{align*}
	\hbar\omega \left(\ad a + \frac{1}{2} \right)\psi_0 &= E_0\psi_0 \\
	\frac{\hbar\omega}{2}\psi_0 &= E_0\psi_0 \tag{since $a\psi_0=0$}
\end{align*}
which gives the energy for the ground state as
\begin{tcolorbox}[title = Zero-point energy] \vspace{-2ex}
	\begin{equation}
		E_0 = \frac{\hbar\omega}{2} \label{eq:zpe}
	\end{equation}
\end{tcolorbox}

This ground state energy is commonly referred to as \textbf{zero-point energy}, a concept that we've been alluding to previously. The zero-point energy arises due to quantum mechanical fluctuations between energy states that occur even at absolute zero, which explains, for example, why liquid helium does not freeze at standard pressure regardless of temperature.\footnote{Physicists Richard Feynman and John Wheeler have calculated that the zero-point energy in a vacuum the size of a light bulb is enough to boil all the world's oceans. See M. Pilkington, \href{https://www.theguardian.com/education/2003/jul/17/research.highereducation}{\emph{The Guardian}} (2003).} Although it fits the contexts of the models presented in this text, the physical manifestations of zero-point energy are still poorly understood and are an active area of research. \par

Now we leave it as an exercise to the reader to show, using a similar procedure as above, that if $\psi_n$ is a solution with energy $E_n$, then $\ad\psi_n$ is also a solution with energy $E_n+\hbar\omega$ and thus $\ad$ behaves as a raising operator. Given this, we can now essentially reconstruct all solutions at least in principle by simply applying the raising operator to the known ground state solution. By this procedure, we can write down a very simple result for the allowed energy states:
\begin{tcolorbox}[title = Allowed energy states of the QHO] \vspace{-2ex}
	\begin{equation}
		E_n = \hbar\omega\left(n + \frac{1}{2}\right) \label{eq:estates-qho}
	\end{equation}
\end{tcolorbox}

We see that like the particle in a box, the energy states of the QHO are quantized and indexed by the quantum number $n$. Where the two differ is that while the energy levels of the particle in a box scale as $n^2$, the energy levels here scale linearly in $n$, which means that these discrete energy levels are equally spaced by $\hbar\omega$. \par

Now, you might be asking yourself if this procedure really generates all the possible solutions or just a subset of them. The answer is that it really does get them all! If there was some other state $\psi_m$ not generated by applying the raising operator successively from the ground state, one could simple lower this state by successively applying the lowering operator until eventually one arrives at the ground state satisfying $a\psi_0 = 0$. But this is just the ground state we've already uniquely identified and indicates that there are no other unique solutions of the \Sch\ equation that we've somehow missed.

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

\section{Additional properties}
\subsection{Bra-ket notation} \label{sec:braket}
We will start by formally introducing some notation to help us from here on out. Back in Chapter~\ref{ch:intro}, we used $\ket{S}$ as a way to describe quantum states. This is standard \textbf{bra-ket notation}, where $\ket{S}$ is called the \textbf{ket} and represents the state of the quantum system, whether it's the momentum, position, or something else. Every ket has an associated \emph{dual} or ``left half'' called the \textbf{bra}, written as $\bra{S}$. Energy states can be expressed as both $\ket{\Psi_0}$ or just $\ket{0}$ for short. \par

As you can probably imagine, the bra and ket can be combined together. Specifically, if we have $\bra{\Psi_m}$ and $\ket{\Psi_n}$ representing two quantum states, then this leads to
\begin{tcolorbox}[title = Bra-ket inner product] \vspace{-2ex}
	\begin{equation}
		\braket{\Psi_m}{\Psi_n} =
		\int_{-\infty}^{\infty} \Psi_m^*\Psi_n \dd{x} \label{eq:bk-int}
	\end{equation}
\end{tcolorbox}

Essentially this notation is representing an \textbf{inner product}, which is a generalization of the dot product that you have seen in previous math classes. Indeed, one can think of a bra as a row vector that is multiplying a column vector ket. Furthermore, changing a quantum state from a bra to a ket (e.g. $\bra{f} \rightarrow \ket{f}$) is equivalent to taking the conjugate transpose. Working with this vector notation, we can also easily to apply operators by multiplying it to the left of a ket, e.g.
\begin{equation*}
	\hat{H} \ket{\Psi} = E\ket{\Psi}
\end{equation*}
where you can treat $\hat{H}$ as a $n\times n$ matrix and $E$ as a constant.

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

\subsection{Expected value}
Since we work with probabilities in quantum mechanics, it is only suitable (and perhaps even delayed at this point) that we cover the concept of \textbf{expectation}, which can be thought of as the \textbf{average} or \textbf{mean} value. Given a quantity $x$, we denote the expected value of $x$ by $\expval{x}$. In general, the average value of some function of $x$ is given by
\begin{equation}
	\expval{g(x)} = \sum_{i=1}^{\infty} g(x_i) p(x_i)
\end{equation}
where $p(x_i)$ is the probability of obtaining $g(x_i)$. This is the case for \emph{discrete} variables, such as the expected value of the roll of a die. For \emph{continuous} variables, we can't use a single probability for a point (it would be equal to zero) but rather a \textbf{probability density} $\rho(x)$ that can be applied over an interval. You're already experienced with probability densities since you've worked with the modulus squared of the wave function. Now our definition for the expectation of a function of a continuous variable becomes
\begin{equation}
	\expval{f(x)} = \int_{-\infty}^{\infty} f(x) \rho(x) \dd{x}
\end{equation}

When we're working with operators or physical observables, the expectations turn nicely into
\begin{equation}
	\expval{f(x)} = \int_{-\infty}^{\infty} \Psi^* f(x) \Psi \dd{x} = \mel{\Psi}{f}{\Psi} \label{eq:expval}
\end{equation}

Now, a measurement of the energy or momentum must return a real outcome, which means $\expval{f(x)}=\expval{f(x)}^*$. This can be rewritten as
\begin{equation*}
	\int_{-\infty}^{\infty} \Psi^* f(x) \Psi \dd{x} = \left( \int_{-\infty}^{\infty} \Psi^* f(x) \Psi \dd{x} \right)^* = \int_{-\infty}^{\infty} \left( f(x) \Psi\right)^* \Psi \dd{x}
\end{equation*}

or
\begin{equation}
	\braket{\Psi}{f\Psi} = \braket{f\Psi}{\Psi} \label{eq:hermitian}
\end{equation}

This condition defines the operator $f$ as \textbf{Hermitian}, which gives real values for the expectation and has real eigenvalues among its many nice properties. As a result, all quantum mechanical operators for physical observables are Hermitian, e.g. momentum, Hamiltonian, position, etc.

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

\subsection{Hermitian conjugates}
We show that $a$ and $\ad$ are \textbf{Hermitian conjugates} (or \textbf{Hermitian adjoints}), which are operators that are related by
\begin{tcolorbox}[title = Hermitian conjugates] \vspace{-2ex}
	\begin{equation}
		\braket{f}{ag} = \braket{\ad f}{g} \label{eq:h-conj}
	\end{equation}
\end{tcolorbox}
for arbitrary $f$ and $g$. If we go back to the integral definition in Equation~\ref{eq:bk-int}, we get that
\begin{equation*}
	\int_{-\infty}^{\infty} f^*ag \dd{x} = \int_{-\infty}^{\infty} (\ad f)^*g \dd{x}
\end{equation*}

which says that $a$ operating on $g$ must give the same result for the integral as $\ad$ operating on $f$. To prove this, we will use the differential form of the operator $a$ and integrate by parts.
\begin{align*}
	\braket{f}{ag} &= \int_{-\infty}^{\infty} f^* \left(x + \frac{\hbar}{m\omega} \dv{x} \right)g \dd{x} \\
	&= \int_{-\infty}^{\infty} f^*xg \dd{x} + \frac{\hbar}{m\omega} \int_{-\infty}^{\infty} f^* \dv{g}{x} \dd{x} \\
	&= \int_{-\infty}^{\infty} f^*xg \dd{x} + \frac{\hbar}{m\omega} \left[ \cancel{f^*g} \bigg|_{-\infty}^{\infty} - \int_{-\infty}^{\infty} \dv{f^*}{x} g \dd{x} \right] \\
	&= \int_{-\infty}^{\infty} \left[ \left(x - \frac{\hbar}{m\omega} \dv{x}\right) f \right]^* g \dd{x} \\
	&= \int_{-\infty}^{\infty} \left(\ad f\right)^*g \dd{x} \\
	&= \braket{\ad f}{g}
\end{align*}

It is also true that
\begin{equation*}
	\braket{f}{\ad g} = \braket{af}{g}
\end{equation*}

We note here that even though the ladder operators are Hermitian conjugates, their product, which appears in the Hamiltonian, \emph{is} a Hermitian operator.

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

\subsection{Scaling factor}
We already know that the raising and lowering operators generate new solutions of the \Sch\ equation. But this is defined only up to a proportionality factor. Given a normalized solution like $\psi_0$ found above, how do we find the higher order solutions exactly? We could normalize each one by brute force, but there is a simpler result. We start by saying that
\begin{equation*}
	\ad \ket{\psi_n} = c_n \ket{\psi_{n+1}}
\end{equation*}

Next, we can apply the result of Equation~\ref{eq:h-conj} in a clever way and note that
\begin{equation*}
	\braket{\ad \psi_n}{\ad \psi_n} = \braket{a\ad \psi_n}{\psi_n}
\end{equation*}

Then, if we take a closer look at our two expressions for the allowed energy states of the QHO (Equation~\ref{eq:sch-qho} and~\ref{eq:estates-qho}), we see that it must be the case that
\begin{align}
	\ad a \psi_n &= n\psi_n \label{eq:ada-prop} \\
	a \ad \psi_n &= (\ad a + 1)\psi_n = (n+1)\psi_n \label{eq:aad-prop}
\end{align}

We can combine these results to obtain
\begin{equation*}
	\braket{\ad \psi_n}{\ad \psi_n} = \braket{a\ad \psi_n}{\psi_n} = (n+1) \braket{\psi_n}{\psi_n} = \abs{c_n}^2\braket{\psi_{n+1}}{\psi_{n+1}}
\end{equation*}

Since $\psi_n$ and $\psi_{n+1}$ are normalized, it follows that $\abs{c_n}^2 = n+1$, and we have
\begin{tcolorbox}[title = Raising operator proportionality] \vspace{-2ex}
	\begin{equation}
		\ad \psi_n = \sqrt{n+1} \psi_{n+1} \label{eq:ad-prop}
	\end{equation}
\end{tcolorbox}

We will leave it as an exercise to the reader to derive (in essentially the same fashion) the proportionality coefficient for the lowering operator, which is
\begin{equation}
	a \psi_n = \sqrt{n} \psi_{n-1} \label{eq:a-prop}
\end{equation}

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

\subsection{Orthogonality}
As you may have guessed by now, the stationary state solutions to the QHO are orthogonal,\footnote{In fact they also form an orthonormal basis.} which means that
\begin{equation}
	\braket{\psi_m}{\psi_n} = \int_{-\infty}^{\infty} \psi_m^*\psi_n \dd{x} = \delta_{mn} \label{eq:ortho_qho}
\end{equation}

We can prove this using Equation~\ref{eq:h-conj} and~\ref{eq:ada-prop}. First, the second equation gives us
\begin{equation}
	\braket{\psi_m}{\ad a \psi_n} = \braket{\psi_m}{n\psi_n} = n\braket{\psi_m}{\psi_n} \label{eq:qho-orth1}
\end{equation}

However, we can also apply the first equation twice to the left hand side and obtain
\begin{equation}
	\braket{\psi_m}{\ad a \psi_n} = \braket{a \psi_m}{a \psi_n} = \braket{\ad a \psi_m}{\psi_n} = m\braket{\psi_m}{\psi_n} \label{eq:qho-orth2}
\end{equation}

Putting Equation~\ref{eq:qho-orth1} and~\ref{eq:qho-orth2} together, one obtains
\begin{equation*}
	(m-n)\braket{\psi_m}{\psi_n} = 0
\end{equation*}

which shows that if $m \neq n$, then
\begin{equation*}
	\braket{\psi_m}{\psi_n} = \int_{-\infty}^{\infty} \psi_m^*\psi_n \dd{x} = 0
\end{equation*}
and the orthogonality condition is satisfied.

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

\section[Applications]{Applications of the QHO}
By now we've seen just how powerful the QHO model is and how useful some of these properties are. The existence of an exact, analytical solution to the QHO makes it a powerful framework for developing more advanced theories to analyze complex quantum mechanical systems. We mentioned at the beginning of this chapter how the QHO could be used to model subatomic particles and the forces between atoms, but a proper treatment involves delving a little deeper into \textbf{quantum field theory} (QFT), which is a framework that is partially derived from the concepts presented in this chapter. Rather than cramming this rich topic into a section here, we will instead be devoting the entire next chapter to QFT and combining the results from QFT and the QHO to analyze vibrational modes in solids called \textbf{phonons}. Stay tuned! \par

% TODO: Consider adding power series to Appendix C?
For the time being, however, let's briefly revisit the wave function solutions we derived earlier. We sidestepped a lot of the ugly algebra by employing the ladder operators method, but I would be doing you a disservice (particularly if you continue to study quantum mechanics in a different field like physics or electrical engineering), if I didn't at least \emph{mention} the analytic method using \textbf{power series}.\footnote{We will skip all the details here, but there's a thorough derivation in Griffiths, Chapter 2.3.} When we work out the math, we arrive at the following expression for the stationary states of the QHO:\footnote{I encourage you to derive another expression for the $n$th stationary state using just the ladder operators! \emph{Hint}: The expression is far more concise, albeit recursive.}
\begin{equation}
	\psi_n(x) = \left(\frac{m\omega}{\pi\hbar}\right)^{1/4} \frac{1}{\sqrt{2^n \cdot n!}} H_n \left(\sqrt{\frac{m\omega}{\hbar}}x\right) \exp \left(-\frac{m\omega x^2}{2\hbar}\right) \label{eq:pow-qho}
\end{equation}

where $H_n$ are the \textbf{Hermite polynomials}, given explicitly and recursively by
\begin{align*}
	H_n(z) &= (-1)^n e^{z^2} \dv[n]{z} \left( e^{-z^2} \right) \\
	H_n(z) &= 2zH_{n-1}(z) - 2(n-1)H_{n-2}(z)
\end{align*}

More concretely, the first few Hermite polynomials are
\begin{align*}
	H_0(z) &= 1 \\
	H_1(z) &= 2z \\
	H_2(z) &= 4z^2-2 \\
	H_3(z) &= 8z^3 - 12z \\
	H_4(z) &= 16z^4 - 48z^2 + 12
\end{align*}

The benefit of this method is that we have a closed-form expression for the wave function at any energy level. We already saw what the ground state $\psi_0$ looked like, which had maximum amplitude at the center of the quadratic potential, so now we plot $\abs{\psi_{50}}$ in Figure~\ref{fig:qho-50}.

\begin{figure}[!h]
	\centering
	\includegraphics[width=0.5\linewidth]{hermite}
	\caption{The probability density function of the QHO with $n=50$ contains nodes where the probability of finding the particle is zero. The general profile also resembles the probability density of a classical harmonic oscillator.}
	\label{fig:qho-50}
\end{figure}

There are two interesting properties of this probability density function. First, notice that there are nodes where the probability of finding the particle is zero, just like the particle in a box. This is true of all energy states above the ground state. Second, we notice that the profile looks very different from the ground state; namely, the regions of largest probability are at the sides instead of the middle. This actually corresponds to a classical harmonic oscillator if you think about it---a moving mass on a spring with high elastic potential energy will spend the longest amount of time when it's most stretched out or most compressed (it moves the slowest as it changes direction), whereas it will move the fastest when it passes the equilibrium position. Thus we see a nice analogy where the high-energy quantum mechanical system begins to exhibit classical behavior.

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

\section{Summary}
Whew! This was a lengthy chapter that was heavy on operators and bra-ket notation. Using ladder operators, we derived the ground state of the quantum harmonic oscillator, from which one can theoretically construct all the stationary states. We also discovered zero-point energy and determined that the allowed energies of the QHO are evenly spaced by $\hbar\omega$. I hope you found the derivations conducive towards your learning, and please come talk to me in office hours if something is unclear! Students find it helpful to try deriving some of these equations on their own to ensure full understanding. In the next chapter we will explore quantum field theory as an extension of the concepts presented here.

%} % for doublespacing
%\end{document}


\documentclass{article}

% these packages let you do math
\usepackage{amsmath}
\usepackage{amssymb}

% we need these packages for fancy R tables
\usepackage{booktabs}
\usepackage{float}
\usepackage{colortbl}
\usepackage{xcolor}

% these packages play with the spacing/margins of the document. Uncomment the commands on lines 16 and 17 to see what they do.
\usepackage{a4wide}
\usepackage{setspace}
\usepackage{geometry}
\usepackage{parskip}
%\doublespacing
%\geometry{margin=1.5in}

% this package helps us with including images. Setting the graphics path makes it easier to refer to things in the \includegraphics command.
\usepackage{graphicx}
\graphicspath{ {../figures/} }

% make some hyperlinks using the \href command
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    urlcolor=blue
}

% set the author, title, and date of the document. \maketitle adds it to the document.
\author{Elle Boodsakorn}
\title{My Paper on incarcerations Data}
\date{Sping 2022}

\begin{document}
\maketitle

\section{Introduction}

This paper analyzes incarceration data in 2002. The variable \texttt{incarcerated} is assigned to 1 if the person was incarcerated and 0 otherwise. Then, I calculate total incarcerations by race and gender. Section 2 presents a bar graph of total number of incarcerations in 2002 by race and gender, a table of total number of incarcerations, and a regression table.

\newpage

\section{Data}

Figure ~\ref{fig:graph} presents the total number of incarceration in 2002 categorized by race and gender. From the graph, we see that male were incarcerated a lot more than female for all race. Black male were incarcerated the most followed by Non-Black/Non-Hispanic and Hispanic respectively.

\begin{figure}[H]
    \begin{center}
        \includegraphics[width=.85\textwidth]{incarcerations_by_racegender}
    \end{center}
    \caption{Total Number of Incarceration in 2002 by Race and Gender}
    \label{fig:graph}
\end{figure}

The table below shows total number of incarcerations by race and gender.

\input{../tables/incarcerations_by_racegender.tex}

Table 2 presents the regression output regressing \texttt{incarcerations in 2002} on race and gender. The constant term reflects the probability of being incarcerated in 2002 for black female (base group). The coefficient -0.014 on Hispanic means that for female hispanic, the probability of being incarcerated is 1.4 percentage points lower than that of black female

\input{../tables/regress_incarcerations_by_racegender.tex}

\end{document}


\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{subcaption}

\title{Reinforcement Learning results analysis}
\author{Marco Marini}

\begin{document}

\maketitle
\tableofcontents

\begin{abstract}
Reinforcement Learning results analysis.
\end{abstract}

\section{Measures}

One hundred tests were run a maze environment with two different hyper parameters configurations.

Each test consist of 1000 episodes with a limit of 300 steps per episode.

\begin{figure}[h!]
	\centering
	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{alpha-returns.png}
		\caption{$\alpha$ Returns.}
	\end{subfigure}
	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{alpha-errors.png}
		\caption{$\alpha$ Errors.}
	\end{subfigure}

	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{epsilon-returns.png}
		\caption{$\varepsilon$ Returns.}
	\end{subfigure}
	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{epsilon-errors.png}
		\caption{$\varepsilon$ Errors.}
	\end{subfigure}

	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{lambda-returns.png}
		\caption{$\lambda$ Returns.}
	\end{subfigure}
	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{lambda-errors.png}
		\caption{$\lambda$ Errors.}
	\end{subfigure}

	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{kappa-returns.png}
		\caption{$\kappa$ Returns.}
	\end{subfigure}
	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{kappa-errors.png}
		\caption{$\kappa$ Errors.}
	\end{subfigure}

	\caption{Hyper parameters}
	\label{fig:hyper}
\end{figure}

\section{Adam optimizer}

The figure \ref{fig:adam} show the comparison between the SGD and ADAM alghoritm.

\begin{figure}[h!]
	\centering
	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{Adam-returns.png}
		\caption{$\alpha$ Returns.}
	\end{subfigure}
	\begin{subfigure}[b]{0.4\linewidth}
		\includegraphics[width=\linewidth]{Adam-errors.png}
		\caption{$\alpha$ Errors.}
	\end{subfigure}

	\caption{Adam optimizer}
	\label{fig:adam}
\end{figure}

\section{Hyper paramaters}

The best value of  $\alpha$\ hyper parameter for linear regression single layer neural network is $ 0.1 $ with binary inputs not normalized (0 / 1 values).

In case general with normalized inputs (-1 / 1 values) and multi layer neural network the $\alpha$ hyper parameter may be set to

\begin{equation}
	\alpha = \frac{0.1}{n}
\end{equation}

where $ n $ is the number of neural network parameters
\end{document}


\subsection{Link/activation functions}


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

\subsection{A decay example}

\marginpar{Wednesday\\ 2020-4-1, \\ compiled \\ \today}

This and next week we will finish the introduction to particle physics, then we will start discussing the open problems in cosmology and astroparticle physics.

We consider the following process:
%
\begin{align}
e^{+} e^{-} \to \mu^- \mu^+
\,,
\end{align}
%
where the mass of the electron is around \(m_e \sim \SI{.5}{MeV}\), the mass of the muon is around \(m_{\mu } \sim \SI{100}{MeV}\).

Digression: there are different families of fermions (leptons and quarks), the first encompasses \(e, \nu_{e}, u, d\); the second encompasses \(\mu, \nu_{\mu }, c, s\) and the third encompasses \(\tau, \nu_{\tau }, t, b\).
The characteristics of the four members of the family are well-known, and between families the characteristics are the same: the only thing which varies between the families is the mass.

So, Rabi famously asked ``who ordered the fermions''?

Coming back to our problem: the state \(\ket{e^{+}e^{-}}\) must be annihilated by the EM current \(j^{\mu }_{EM} = \overline{\psi}_e \gamma^{\mu } \psi_e \); it is then converted to a photon, which however is not on mass shell --- it cannot be, since its momentum must be that of the electron-positron pair, so a timelike vector.
It is then called a \emph{virtual photon}: it can exist, as long as it does so for a short time.

Then, this photon decays to a muon-antimuon pair: then we will have a term \(\bra{\mu^- \mu^+} j^{\mu }_(\mu )\). The index between parenthesis is not a Lorentz one, it just means that this is a muonic current, different from the electronic one.

Let us call \(p_{-}\) and \(p_{+}\) the momenta of the electron and positron, and \(p^{\prime }_{-}\) and \(p^{\prime }_{+}\) those of the muon and antimuon.

The momentum \(q\) of the photon cannot have \(q^2  =0 \), but this is fine: it is just an excitation.

The physics of the process is all contained in the matrix element \(\mathcal{M}(e^{+}e^{-} \to \mu^+ \mu^-)\). How do we calculate it? We will not go into details here, but it can be directly derived from the Feynman diagram of the interaction \cite[sec.\ 4.1.2]{tissinoTheoreticalPhysicsNotes2020}: we have
%
\begin{align}
\mathcal{M}(e^{+}e^{-} \to \mu^+ \mu^-) =
(-e)
\bra{\mu^- \mu^+} j^{\mu } \ket{0}
\frac{1}{q^2}
(-e)
\bra{0} j_{\mu } \ket{e^{+} e^{-}}
\,,
\end{align}
%
where the \(-e\) factor is because of the EM coupling to the photon.
The Breit-Wigner factor looks like
%
\begin{align}
\frac{1}{P^2-M_R^2}
\,,
\end{align}
%
but for the photon we have no mass, therefore we only get a factor \(1/q^2\).

The Feynman diagrams are just a way to collect the Feynman rules needed to compute the process, they are not meant to represent how the process ``looks like''.

Let us take the ultrarelativistic limit, in which the energy of the process is much larger than the muon's mass.
If this is the case, then we can set \(m_e = m_\mu  = 0\).

Let us consider the Dirac equation, in the case in which the mass \(m\) is equal to zero: then we get
%
\begin{align}
i \slashed{\partial} \psi = 0
\,.
\end{align}

Let us use the chiral representation for the \(\gamma \) matrices:
%
\begin{subequations}
\begin{align}
\gamma^{\mu } = \left[\begin{array}{cc}
0 & \sigma^{\mu } \\
\overline{\sigma}^{\mu } & 0
\end{array}\right]
\,,
\end{align}
\end{subequations}
%
where we mean by \(\sigma^{0} = \mathbb{1}\), \(\sigma^{\mu } = (\sigma^{0}, \sigma^{i})\) and \(\overline{\sigma}^{\mu } = (\sigma^{0}, - \sigma^{i})\).

Let us then split the spinor \(\psi \) into
%
\begin{subequations}
\begin{align}
\psi = \left[\begin{array}{c}
\psi_{L} \\
\psi_{R}
\end{array}\right]
\,,
\end{align}
\end{subequations}
%
where \(\psi_{L, R}\) are two-component spinors. This allows us to write two two-dimensional equations:
%
\begin{subequations}
\begin{align}
i \overline{\sigma}^{\mu } \partial_{\mu } \psi_{L} &= 0 \\
i \sigma^{\mu } \partial_{\mu } \psi_{R} &= 0
\,,
\end{align}
\end{subequations}
%
where we get no interaction terms between the two: if we have no mass the equations decouple.

We can do the same thing if the Dirac equation is coupled to the EM field, since the issue is with the structure of the \(\gamma^{\mu }\), it does not matter if we have \(\gamma^{\mu } \DD_{\mu }\) or \(\gamma^{\mu } \partial_{\mu }\); however we will write the decoupled solution for now.

So, for the right-handed spinor we have:
%
\begin{align}
\qty(i \partial_{t} + i \vec{\sigma} \cdot \vec{\partial}) \psi_{R}
\,,
\end{align}
%
which is solved by a plane wave:
%
\begin{align}
\psi_{R} = u_R (p) e^{-iEt + i \vec{p} \cdot \vec{x}}
\,.
\end{align}

Let us suppose the equation reads
%
\begin{subequations}
\begin{align}
\qty(E - p \sigma^{3}) u_R = \left[\begin{array}{cc}
E-p & 0 \\
0 & E+p
\end{array}\right] u_{R} = 0
\,,
\end{align}
\end{subequations}
%
so we must have two solutions: they look like
%
\begin{subequations}
\begin{align}
\psi_{R} = \left[\begin{array}{c}
1 \\
0
\end{array}\right] e^{-i Et + i E x_3 }
\qquad \text{and} \qquad
\psi_{R} = \left[\begin{array}{c}
0 \\
1
\end{array}\right] e^{+i Et + i E x_3 }
\,.
\end{align}
\end{subequations}

The solution \(\psi_{R} \sim \exp(-iEt + i E x_3)\) describes a right-handed electron with spin eigenvalue \(+1/2\) along the direction of motion (this is called the \emph{helicity} \cite[sec.\ 1.4.9]{tissinoTheoreticalPhysicsNotes2020})

On the other hand, the solution \(\psi_{R} \sim \exp(iEt + iE x_3)\) describes a right-handed electron with spin eigenvalue \(s = - 1/2\).

Our quantum field operator \(\psi_{R}\) acts as on the right by destroying a right-handed electron:
%
\begin{align}
\bra{0}\psi_{R} \ket{e^{-}_{R} (p)} = u_R(p) e^{-ipx}
\,.
\end{align}

Then, we can have it acting on the left by destroying a left-handed positron:
%
\begin{align}
\bra{e^{+}_{L}(p)} \psi_{R} \ket{0} = v_L (p) e^{+ipx}
\,.
\end{align}

If we were to repeat the analysis for the other spinor, we would get the specular result.

The Lagrangian can be written as
%
\begin{align}
\mathscr{L} =
\psi_R ^\dag \qty(i \sigma \cdot \partial) \psi_{R}+
\psi_L ^\dag \qty(i \overline{\sigma} \cdot \partial) \psi_{L}
- m \qty( \psi ^\dag _R \psi_{L}
+ \psi ^\dag_L \psi_{R})
\,,
\end{align}
%
so the coupling between the left and right handed fermions depends on the mass, if we are in a situation in which \(T \gg m\) they effectively decouple.

In order to describe this spin, we introduce the helicity quantum number, which is defined as
%
\begin{align}
h = \hat{p} \cdot \vec{s}
\,,
\end{align}
%
the projection of the spin along the direction of motion.
For \(\psi_{R}\), we have the \((1,0)\) state with helicity \(h = 1/2\), while the state \((0,1)\) is a positron with helicity \(h = - 1/2\).

If \(m=0\), then helicity is exactly conserved. At high energies, it is suppressed by a factor \(m / E\).

Let us compute the cross section: we must calculate
%
\begin{align}
\bra{0} j^{\mu } \ket{e^{-}_{R} (p_{-}) e^{+}_{L} (p_+)}
\,,
\end{align}
%
where we have a term \(j^{\mu } = \overline{\psi} \gamma^{\mu } \psi = \psi ^\dag \gamma^{0} \gamma^{\mu } \psi \); the term \(\gamma^{0} \gamma^{\mu }\) reads
%
\begin{align}
\gamma^{0} \gamma^{\mu } = \left[\begin{array}{cc}
0 & \mathbb{1} \\
\mathbb{1} & 0
\end{array}\right]
\left[\begin{array}{cc}
0 & \sigma^{\mu } \\
\overline{\sigma}^{\mu } & 0
\end{array}\right]
= \left[\begin{array}{cc}
\overline{\sigma}^{\mu } & 0 \\
0 & \sigma^{\mu }
\end{array}\right]
\,,
\end{align}
%
so we get
%
\begin{align}
j^{\mu } = \psi_{L} ^\dag \overline{\sigma}^{\mu } \psi_{L} + \psi_{R} ^\dag \sigma^{\mu } \psi_{R}
\,.
\end{align}

We describe the process in the center-of-mass frame, and we choose to align the axes so that the electron and positron have momenta \(p^{\mu } = (E, 0, 0, \pm E)\) respectively (minus for the positron).

The wavefunction \(\psi ^\dag_{R}\) annihilates the positron \(e^{+}_{L}\) yielding a term \(v ^\dag _L (p_+)\), the wavefunction \(\psi_{R}\) annihilates the electron \(e^{-}_{R}\) yielding a term \(u_R (p_-)\).

Then, we are left with
%
\begin{align}
v_L ^\dag (p_+) \sigma^{\mu } u_R (p_-) &= \sqrt{2E}
\left[\begin{array}{cc}
0 & 1
\end{array}\right]
(\mathbb{1}, \vec{\sigma}) \sqrt{2E}
\left[\begin{array}{c}
1 \\
0
\end{array}\right]  \\
&= 2E (0, 1, i, 0)^{\mu }
\,,
\end{align}
%
so if we define the vector \(\vec{\epsilon}_{+} = (\hat{1} + i \hat{2}) / \sqrt{2}\) we can write
%
\begin{align}
\bra{0}
j^{\mu }
\ket{e^{-}_R (p_-) e^{+}_L (p_+)}
= 2 E \sqrt{2} \qty(0, \vec{\epsilon}_{+})^{\mu }
\,,
\end{align}
%
while we would have
%
\begin{align}
\bra{0}
j^{\mu }
\ket{e^{-}_L (p_-) e^{+}_R (p_+)}
= - 2 E \sqrt{2} \qty(0, \vec{\epsilon}_{-})^{\mu }
\,,
\end{align}
%
with \(\vec{\epsilon}_{-} =(\hat{1} + i \hat{2}) / \sqrt{2} \).

On the other hand, the terms \(e_{R}^{-} e_{R}^{+}\) and \(e_{L}^{-} e_{L}^{+}\) do not contribute (in our \(m = 0\) approximation).

The muons are massless fermions as well in our treatment, so we get analogous terms:
%
\begin{align}
\bra{\mu^-_R (p'_-) \mu^+_L (p'_+)} j^{\mu } \ket{0} &= 2E \sqrt{2} \qty(0, \vec{\epsilon}^{\prime *}_+)^{\mu } \\
\bra{\mu^-_L (p'_-) \mu^+_R (p'_+)} j^{\mu } \ket{0} &= - 2E \sqrt{2} \qty(0, \vec{\epsilon}^{\prime *}_-)^{\mu }
\,,
\end{align}
%
so in the end we find
%
\begin{align}
\mathcal{M} (e^{-}_{L} e^{+}_{R} \to \mu^-_R \mu^+_L)
&= - \frac{e^2}{q^2} 2 (2E)^2
\vec{\epsilon}^{\prime *}_{+} \cdot \vec{\epsilon}_{+}  \\
&= - 2 e^2 \vec{\epsilon}^{\prime *}_{+} \cdot \vec{\epsilon}_{+}
\,,
\end{align}
%
since \(q  =2 E\).
The scalar product here depends on the direction of emission of the muons in the center of mass frame, \(\theta \); we find the absolute value \(\abs{\mathcal{M}}^2 = e^{4} (1 \pm \cos \theta )^2\), depending on whether we are looking at an \(LR \to LR\) process or \(LR \to RL\) process. The unpolarized (spin-averaged) differential cross section comes out to be:
%
\begin{align}
\dv{\sigma }{\cos \theta } = \frac{1}{2} \frac{\pi \alpha^2}{2 E_{CM}^2} \qty(1 + \cos^2\theta )
\,,
\end{align}
%
which can be integrated across the sphere to get the total cross section for the process \(e^{-} e^{+} \to \mu^- \mu^+\):
%
\begin{align}
\sigma = \frac{4 \pi }{3} \frac{\alpha^2}{E^2_{CM}}
\,.
\end{align}

We could have guessed the dependence on \(\alpha^2  / E^2_{CM}\), but for the numerical factor we needed to do the full computation.
This is because the cross section is a length square, so it must depend on the inverse square of our only energy parameter, \(E_{CM}\).

Also, the coupling was fixed: we are working in QED, so we only have a coupling constant: \(e\), so we will have terms \(e^2 / 4 \pi = \alpha \) inside of \(\mathcal{M}\), so we will get \(\alpha^2\) inside of \(\abs{\mathcal{M}}^2\).
The \(4 \pi \)s will cancel because of the phase-space angular integrals.

Once we have done this, can we generalize it? suppose we want to compute the cross section \(\sigma (e^{+}e^{-} \to \text{hadrons})\). How could we do it?

We can make a similar kind of reasoning: the process will look like \(e^{-} e^{+} \to q \overline{q}\), and while the coupling for the first vertex in the Feynman diagram will be \(-e\) the one for the second vertex will look like \(Q_q\), the charge of these quarks.
We calculate the unpolarized cross section, counting all the quarks which can be produced at a fixed COM energy: we assume \(E \sim \SI{100}{GeV}\), so all the quarks except for the top are candidates; so the computation goes:
%
\begin{align}
\frac{\sigma (e^{+} e^{-} \to q \overline{q})}{\sigma (e^{+ }e^{-} \to \mu^+ \mu^-)} \approx \sum _{q} Q_q^2 = \underbrace{2 \frac{4}{9} }_{u, c} + \underbrace{3 \frac{1}{9}}_{d, s, b}
= \frac{11}{9}
\,.
\end{align}

In experiments, however, we get a cross section ratio which is \(11/3\), 3 times larger than expected: this indicates that we have a different type of charge, color charge, which means we have a multiplicity of \(3\) for each quark.

We shall see that this is related to certain kinds of internal symmetries of our field theory.

\end{document}


\chapter{Results}
This chapter consists of two main parts. In the first part of the chapter, the results from training models for predicting sex and brain age from brain graphs will be presented. The models were first evaluated using ten-fold cross validation on the training/validation set. Then, a final model was trained and evaluated on the test set. In the second part of the chapter, the saliency maps for these final models will be presented, with the aim of gaining insight into what functional brain networks in the data are related to age and sex differences.

To reliably evaluate the models, the data set was split into a training/validation set and a test set. These data sets where then undersampled to make them unbiased, which yielded training/validation sets of size 30000 and 20000, and test sets of size 4678 and 3148 for sex and age prediction, respectively. For age prediction, an unbiased data set corresponds to a uniform distribution of ages. Model training and evaluation was implemented in \texttt{Python} \cite{python} using \texttt{Keras} \cite{keras} with the \texttt{TensorFlow} \cite{tensorflow} backend. Furthermore, all models where trained using the \texttt{Adam} \cite{adam} optimizer.

\section{Evaluating model performance}
\label{sec:model_pred}
The model performance for both sex and age prediction is presented in the form of the loss and two additional metrics. For sex classification, these metrics are \acrfull{bce} (loss), accuracy and \acrfull{mcc}. For age regression, they are \acrfull{mse} (loss), \acrfull{mae} and Pearson correlation coefficient ($r$). \acrshort{mcc} is defined identically to $r$, but refers to the performance of a binary classifier. An \acrshort{mcc} of +1 thus indicates a perfect prediction, -1 all miss-predicted and 0 randomly guessing.

\subsection{Sex}

To evaluate the model performance for sex classification, the three metrics calculated from cross-validation on the training/validation set are presented in \cref{tab:sex_model_results}. All three metrics indicate that Baseline, GCN and Popencoder have comparable performance, with an accuracy around $79\,\%$. It is also clear that these three models significantly outperform Poptoy regardless of metric. The performance of the final models, evaluated on an external test set, is presented in \cref{tab:sex_final_model_results}. The final models' performance are in line with the cross-validation results in \cref{tab:sex_model_results}, where all metrics are within, or around, one standard deviation. Thus, the performance of the models generalises to external data.
\begin{table}[!htbp]
    \centering
    \caption{\acrfull{bce}, accuracy (in $\%$) and \acrfull{mcc} for each of the four models, evaluated using ten-fold cross validation, with the mean and standard deviation calculated over the ten folds.}
    \begin{tabular}{c|c|c|c}
         & BCE & Accuracy & MCC\\ \hline
        Baseline & $0.450\pm0.008$ & $79.0\pm0.6$ &$0.58\pm 0.01$\\
        GCN &$0.45\pm0.02$ & $79.2\pm0.9$& $0.59\pm0.02$\\
        Poptoy &$0.674\pm 0.006$ & $58\pm1$ &$0.17\pm0.02$\\
        Popencoder &$0.446\pm0.009$& $79.3\pm 0.6$ & $0.59\pm0.01$\\
    \end{tabular}
    \label{tab:sex_model_results}
\end{table}
\begin{table}[!htbp]
    \centering
    \caption{\acrfull{bce}, accuracy (in $\%$) and \acrfull{mcc} for each of the four models evaluated on the test set.}
    \begin{tabular}{c|c|c|c}
         & BCE & Accuracy & MCC\\ \hline
        Baseline & 0.444 & 79.5 &0.59\\
        GCN & 0.43& 80.2 & 0.60 \\
        Poptoy &0.678 &57.4 &0.16\\
        Popencoder & 0.450 & 79.1& 0.59\\
    \end{tabular}
    \label{tab:sex_final_model_results}
\end{table}

The results presented in \cref{tab:sex_model_results} and \cref{tab:sex_final_model_results} have several interesting implications. Observe that there is basically no performance difference between Baseline, GCN and Popencoder, implying that increasing model complexity beyond Baseline is not necessary for classifying sex. Furthermore, the main difference between Popencoder and Baseline and GCN is that Popencoder takes a population graph as input, in addition to the brain graphs for all subjects. One explanation of why including the population graph does not improve performance could be that our chosen similarity measure does not introduce any extra information relevant for sex classification. Since the similarity measure is calculated from each subject's brain graph, it is possible that the information encoded by the similarity measure is only a subset of all the information contained in the individual graphs. Another explanation is that the similarity measure adds some extra information, but that the amount of information is small. In the case of either explanation, the similarity measure does not introduce enough information to improve the prediction of a subject's sex. That the similarity measure is not very informative is further supported by the poor performance of Poptoy, since Poptoy bases its prediction solely on the population graph. However, Poptoy still performs better than random guessing, indicating that some valuable information resides in the population graph.

\subsection{Age}
To evaluate the model performance for age regression, the three metrics calculated from cross-validation are presented in \cref{tab:age_model_results}. From \cref{tab:age_model_results}, the three metrics clearly indicate that, just as for sex classification, Baseline, GCN and Popencoder all perform within the uncertainty of each other, whilst Poptoy performs significantly worse.  \cref{tab:age_final_model_results} presents the performance of the final models trained on all data and evaluated on an external test set. The results are within one standard deviation of the results in \cref{tab:age_model_results}, which indicates that the models generalise well to external data. One possible exception is Popencoder, which performs slightly better on the test set than during cross-validation, however, the difference in performance is small.

\begin{table}[!htbp]
    \centering
    \caption{\acrfull{mse}, \acrfull{mae} and Pearson correlation coefficient ($r$) for each of the four models, evaluated using ten-fold cross validation, with the mean and standard deviation calculated over the ten folds.}
    \begin{tabular}{c|c|c|c}
         &  MSE [years$^2$]& MAE [years] & $r$ \\ \hline
        Baseline &$52\pm1$& $5.9\pm0.1$&$0.52\pm0.01$\\
        GCN & $53\pm1$& $5.96\pm 0.09 $& $0.52\pm0.01$\\
        Poptoy &$71\pm 1$ & $7.24\pm0.07$ &$ 0.11\pm 0.01$\\
        Popencoder &$53\pm1$& $5.93\pm 0.09$ & $0.52\pm0.02$\\
    \end{tabular}
    \label{tab:age_model_results}
\end{table}

The age prediction results for the different models are in line with the two main conclusions for sex classification in the previous section. Firstly, Baseline, GCN and Popencoder perform similarly which indicates that increasing the model complexity beyond Baseline is unnecessary. Secondly, the poor performance of Poptoy compared to the other models, combined with Popencoder not performing better than Baseline and GCN, indicates that the similarity measure is not very informative with regards to age either.

\begin{table}[!htbp]
    \centering
    \caption{\acrfull{mse}, \acrfull{mae} and Pearson correlation coefficient ($r$) for each of the four models evaluated on the test set.}
    \begin{tabular}{c|c|c|c}
         &  MSE [years$^2$]& MAE [years] & $r$ \\ \hline
        Baseline & $51 $& $5.9 $&$0.53 $\\
        GCN & $51 $& $5.9  $& $0.53 $\\
        Poptoy &$71 $ & $7.18 $ &$ 0.09 $\\
        Popencoder &50 & $5.7 $ & $0.55 $\\
    \end{tabular}
    \label{tab:age_final_model_results}
\end{table}

To set the poor performance of Poptoy into perspective, consider a naive age prediction model that always outputs the average age of the population when predicting a subject's age. The performance of such a model on the test set would yield an \acrshort{mse} of $71\rm\,years^2$ and an MAE of $7.3\rm\,years$. The correlation for constant prediction with the actual ages is undefined. Comparing this with the results for Poptoy, one can conclude that Poptoy only performs slightly better, demonstrating Poptoy's poor performance.

Turning to the results on the test set for the three other models, all have an \acrshort{mse} loss of around 50--$51\rm\,years^2$ , an \acrshort{mae} of 5.7--$5.9\rm\,years$ and a correlation of around 0.53--0.55. The fact that the correlation is much lower than 1 indicates that the prediction is not perfect. In fact, it turns out that all these models are somewhat biased in predicting the mean of the age distribution in the data set. This can be seen clearly in \cref{fig:age_regression}, where a prediction with Baseline on the test set is performed. The figure suggests that the model to some extent can determine if a subject is old or young, but that the error in the age prediction is much larger for younger and older subjects than for subjects close to the mean age. This is a form of underfitting, indicating either that the model is not complex or general enough to better fit the data, or that the data does not contain enough information for a better prediction of age.

\begin{figure}[!htbp]
    \centering
    \begin{center}
        \resizebox {0.6\linewidth} {!} {
            \input{chapters/images_results/predict_example.pgf}
        }
    \end{center}
    \caption{A plot of the Baseline predicted ages for the subjects in the test set, versus the target ages. The dots are the predictions for individual subjects, the orange line is a linear fit to the individual predictions, and the black dashed line is what the perfect predictions (no error) would look like. Note that the error in the prediction is the largest for the youngest and the oldest subjects.}
    \label{fig:age_regression}
\end{figure}

\section{Saliency maps of functional brain networks}
The saliency mapping consisted of two methods: naive node removal and Zorro; both applied for sex and age prediction on Baseline and GCN. Poptoy was not analysed because of its low performance, and Popencoder because of its high complexity. Including Popencoder would probably also be redundant, because of its similar performance to Baseline and GCN.

Naive node removal was performed with the difference in loss ($\Delta$\acrshort{bce} for sex prediction and $\Delta$\acrshort{mse} for age prediction) evaluated on the test set. The naive analysis was repeated ten times with different model initialisations to estimate the impact of model uncertainty on node importance. Zorro was performed only for the final models presented in \cref{sec:model_pred}, and was run with a fidelity threshold of $\tau=0.9$. The tolerance for an age prediction to be considered correct was set to be similar to the MAE of the final models, at $t=6\rm\,years$. The results for all subjects in the test set were aggregated into groups of 200 subjects, and the mean importance score for each node in each group was calculated. Then, the average and standard deviation over the importance scores in each group was calculated. The standard deviations of the Zorro results over these sub-groups represent the uncertainty in the importance for each node when varying subjects. Ideally, Zorro should also be evaluated over different model intialisations. However, it would require repeating Zorro evaluated on all subjects in the test set for several different models. Due to the computational complexity of Zorro, this was not possible because of time constraints. A smaller investigation into the model uncertainty for Zorro was performed for a few subjects, presented in \cref{app:zorro_model_uncertainty}, from which it was concluded that the model uncertainty is similar, but generally smaller than the subject uncertainty.

\subsection{Sex}
\label{sec:results_analysis_sex}
As a measure of node importance, $\Delta$\acrshort{bce} when performing naive node removal for Baseline and GCN is presented in \cref{fig:naive_sex}.

\begin{figure}[!htbp]
    \centering
    \begin{center}
    \resizebox {0.7\linewidth} {!} {
        \input{chapters/images_results/node_masking/shared_x_sex.pgf}
    }
    \end{center}
    \caption{Results from performing the naive node removal analysis for Baseline and GCN, for sex prediction. The analysis was repeated for ten different model initialisation, over which the dots and error bars in the figures represent the mean and standard deviation, respectively.}
    \label{fig:naive_sex}
\end{figure}

From the figures it is observed that the effect of removing a node for both models is on the order of $\Delta \text{BCE} \sim 0.01$, which is small compared to the absolute performance of the reference models, $\text{BCE} \approx 0.45$. It is also observed that removing any node has a negative effect on performance, $\Delta\text{BCE}>0$. These two observations indicate two things. Firstly, no node seems to be crucial for the prediction, since the change in performance is small for all nodes. Secondly, all nodes are to some extent important, since removing any node has a negative impact on the performance. Despite the small absolute change in performance, there are clear differences in the relative importance between nodes. The results for both models indicates that \acrshort{smm}, \acrshort{cb2}, \acrshort{pl} and \acrshort{pmc} are more important than the other nodes. Further, observe that the uncertainties are much larger for GCN than for Baseline. This could be due to GCN not converging to the same degree as Baseline, either due to overfitting, early stopping or because of it being a more complex model. The two models, however, give roughly the same result, even if the uncertainties for GCN are large.

\begin{figure}[!htbp]
    \centering
    \begin{center}
        \resizebox {0.7\linewidth} {!} {
            \input{chapters/images_results/zorro/shared_x_sex.pgf}
        }
    \end{center}
    \caption{Zorro analysis results for the Baseline and GCN models. The analysis results were grouped into 23 different groups of 200 subjects for each model, to yield a mean and standard deviation in importance for each node.}
    \label{fig:zorro_sex}
\end{figure}

The result from the Zorro analysis for Baseline and GCN is presented in \cref{fig:zorro_sex}. The uncertainties in the result for both models are small, but note that they do not include potential uncertainties regarding the model variability, as previously discussed. Generally, it is clear that the results for Baseline and GCN are to a large extent in agreement: for both models \acrshort{smm} is pointed out to be the most important node. Other nodes that may be regarded to be somewhat important according to both models are \acrshort{cb2}, \acrshort{pl}, \acrshort{ts} and \acrshort{pmc}. It is also interesting to note that \acrshort{vv1m} seems to be more important when analysing Baseline than GCN. One possible interpretation could be that this is an artefact of the method, but this inconsistency will be discussed more in-depth in \cref{chap:discussion}.

\begin{figure}[H]
    \centering
    \begin{center}
    \resizebox {0.7\linewidth} {!} {
        \input{chapters/images_results/thesis_naive_zorro_sex.pgf}
    }
    \end{center}
    \caption{Comparison of the results for naive node removal and Zorro for sex prediction, from \cref{fig:naive_sex} and \cref{fig:zorro_sex}, respectively. Note that the error bars are omitted for visibility.}
    \label{fig:comparison_sex}
\end{figure}

To more easily compare the result of naive node removal and Zorro for both models, \cref{fig:comparison_sex} is presented, without error bars for visibility reasons. The comparison of the result reveal that the methods are generally in agreement, but some clear differences exist. For instance, both methods agree that \acrshort{smm} is important but disagree on the degree of importance for \acrshort{cb2} and \acrshort{pl}. By comparing the methods and models, \acrshort{smm} seems to be most important node for classifying sex, and \acrshort{cb2}, \acrshort{pl}, \acrshort{ts} and \acrshort{pmc} may to some extent be important.

\subsection{Age}

As a measure of node importance, $\Delta$\acrshort{mse} when performing naive node removal for Baseline and GCN is presented in \cref{fig:naive_age}.

\begin{figure}[!htbp]
    \centering
    \begin{center}
        \resizebox {0.7\linewidth} {!} {
            \input{chapters/images_results/node_masking/shared_x_age.pgf}
        }
    \end{center}
    \caption{Results from performing the naive node removal analysis for Baseline and GCN, for age prediction. The analysis was repeated for ten different model initialisation, over which the dots and error bars in the figures represent the mean and standard deviation, respectively.}
    \label{fig:naive_age}
\end{figure}

The general change in loss is observed to be small, $\Delta\text{MSE}\sim1\rm\,years^2$ relative to $\text{MSE}\sim50\rm\,years^2$. As was the case for sex prediction, this indicates that no node is crucial and that all nodes are to some extent important for predicting age. Furthermore, the model uncertainty is larger for GCN than for Baseline in the case of age prediction as well. This could be due to GCN not fully converging, as discussed in \cref{sec:results_analysis_sex}. Observe that the most important nodes for both models are \acrshort{smm}, \acrshort{cb2} and \acrshort{pmc}, where \acrshort{cb1} is additionally important for Baseline. Overall, the models are generally in agreement with some small exceptions.

\begin{figure}[!htbp]
    \centering
    \begin{center}
    \resizebox {0.7\linewidth} {!} {
        \input{chapters/images_results/zorro/shared_x_age.pgf}
    }
    \end{center}
    \caption{Zorro analysis results for the Baseline and GCN models for age prediction. The analysis results were grouped into 15 different groups of 200 subjects for each model, to yield a mean and standard deviation in importance for each node.}
    \label{fig:zorro_age}
\end{figure}

The result from the Zorro analysis for Baseline and GCN is presented in \cref{fig:zorro_age}. Observe that the algorithm finds \acrshort{cb1}, \acrshort{dmn}, \acrshort{smm}, \acrshort{sn}, \acrshort{cb2} and \acrshort{pl} important for Baseline, and \acrshort{smm} and \acrshort{cb2} important for GCN. Another observation is that generally the importance scores for Baseline are higher than for GCN, especially for \acrshort{cb1}, \acrshort{dmn} and \acrshort{sn}. This means that more nodes are required in the explanations for Baseline than for GCN in order to reach a fidelity of $\tau=0.9$.

\begin{figure}[H]
    \centering
    \begin{center}
    \resizebox {0.7\linewidth} {!} {
        \input{chapters/images_results/thesis_naive_zorro_age.pgf}
    }
    \end{center}
    \caption{Comparison of the results for naive node removal and Zorro for age prediction, in \cref{fig:naive_age} and \cref{fig:zorro_age} respectively. Note that the error bars are omitted for visibility.}
    \label{fig:comparison_age}
\end{figure}

In order to more easily compare the result for the naive node removal and Zorro for both models, \cref{fig:comparison_age} is presented. By comparing the results for both methods and models, \acrshort{smm} and \acrshort{cb2} stand out, since they are deemed important in all cases. In addition to \acrshort{smm} and \acrshort{cb2}, other nodes that might be important, but not consistently for all methods and models, are \acrshort{cb1}, \acrshort{dmn}, \acrshort{sn}, \acrshort{pl} and \acrshort{pmc}. Most of these are nodes that are only considered important by Zorro for the Baseline model. However, since they are only deemed important in one out of the four cases, it might suggest that they are artefacts of the method or model.
There are also some differences in the results for naive node removal compared with Zorro. For example, \acrshort{pmc} may be deemed more important by the naive method. However, the differences between the two analysis methods seem to be smaller than the discrepancy between Baseline and GCN for Zorro. These differences and discrepancies will be discussed in more detail in \cref{chap:discussion}.


\section{High energy physics applications}
\label{sec:hep}

\subsection{B physics}

\subsubsection{Data sample}

In order to demonstrate the functionality of the toolkit, data samples generated
from the RapidSim package~\cite{rapid} are used. The interesting signal is chosen
to be the $\Bs\to\jpsi(\to\mu\mu )\phi (\to\PK\PK )$ decay, and the background is
the $\Dz\to\pi\pi\pi\pi$ decay. A total of 10000 candidates is generated for each decay.

\subsubsection{Training of the original classifier}
\label{sec:orig_training}

%The machine learning classifier chosen is the Multi-layer perceptron of SciKit-Learn,
%which is constructed as
The machine learning classifier, using the Keras framework~\cite{keras},
is constructed as
which is constructed as
\begin{lstlisting}
classifier = Sequential()
classifier.add(LocallyConnected1D(
filters = 90, kernel_size = 2,
activation = 'sigmoid',
input_shape = (len(setTrain[0]), 1)))
classifier.add(GlobalMaxPooling1D())
classifier.add(Dense(30, activation = 'sigmoid'))
classifier.add(Dense(1, activation = 'sigmoid'))
classifier.compile(optimizer = 'adam',
loss = 'binary_crossentropy'
, metrics = ['accuracy'])
\end{lstlisting}
%\begin{lstlisting}
%classifier = MLPClassifier(activation='relu',
%    batch_size='auto', beta_1=0.9, beta_2=0.999,
%    early_stopping=False, epsilon=1e-08,
%    hidden_layer_sizes=(3, 3),
%    learning_rate='constant',
%    learning_rate_init=0.001, max_iter=200,
%    nesterovs_momentum=True, power_t=0.5,
%    random_state=1, shuffle=True,
%    solver='lbfgs', tol=0.0001, momentum=0.9,
%    validation_fraction=0.1, verbose=False,
%    warm_start=False, alpha=1e-05)
%\end{lstlisting}

The neural network is trained using kinematic properties of the respective decays.
These include the pseudorapidity, $\eta$, and momentum transverse to the direction of the
input proton beams, \pt, of the decaying particle. In addition, the minimum and maximum \pt and $\eta$
of the final state particles is used. The signal and background distributions of the input variables
are shown in Fig.~\ref{fig:inputs}.
%
\begin{figure*}[t]
\centering
\includegraphics[width=0.33\textwidth]{pt_comp}
\includegraphics[width=0.33\textwidth]{eta_comp}
\includegraphics[width=0.33\textwidth]{minpt_comp}
\includegraphics[width=0.33\textwidth]{maxpt_comp}
\includegraphics[width=0.33\textwidth]{mineta_comp}
\includegraphics[width=0.33\textwidth]{maxeta_comp}
\caption{\small Comparison of the signal and background distributions
used to train the Keras B decay classifier.}
\label{fig:inputs}
\end{figure*}

In the training of the original classifier, half of the data is
reserved in order to test for overtraining.
%The output probability distributions of the signal and background samples
%after the training are shown in Fig.~\ref{fig:output}.
%It can be seen that the test and training samples are in good agreement,
%showing that the original SciKit-Learn classifier is not significantly overtrained.
%\begin{figure*}[t]
%\centering
%\includegraphics[width=0.45\textwidth]{event_probability}
%\caption{\small
%Output distributions of the signal and background training and
%test samples from the classifier after training.
%}
%\label{fig:output}
%\end{figure*}

\subsection{Jet separation}
\label{sec:hepGPD}

\subsubsection{Data sample}

A further demonstration is provided demonstrating a classifiers ability to separate different
kinds of jets. The data sample to show this has been generated from Pythia~\cite{Sjostrand:2007gs}
simulating pp collisions at 14\tev.
The jets themselves are reconstructed in the Rivet analysis framework~\cite{Buckley:2010ar}
and are created using the FastJet~\cite{Cacciari:2011ma} package using the $K_t$ algorithm~\cite{Salam:2007xv}
(the definition
of the $K_t$ variable and a review of jet reconstruction algorithms
may be found in Ref.~\cite{Atkin:2015msa}).
A jet \pt requirement of 20\gev is imposed on all jets.
All other parameters remain at the default values for Rivet version 2.5.4.
The signal sample is chosen to correspond to a $qg\to qg$ type of interaction,
whereas the background is chosen to correspond to a $gg \to gg$ type.
Jets that originate from gluons in the final state form a background to many
analyses, therefore efficient rejection of such processes is important in making
measurements~\cite{Komiske:2016rsd}.

\subsubsection{Training of the original classifier}

The machine learning classifier chosen is also a Keras-based convolutional neural net,
constructed in an similar way as described in Sec~\ref{sec:orig_training}.
\begin{lstlisting}
classifier = Sequential()
classifier.add(LocallyConnected1D(
filters = 32, kernel_size = 2,
activation = 'relu', input_shape = sig_data[0].shape))
classifier.add(MaxPooling1D(pool_size = 3,
strides = 1))
classifier.add(Dropout(0.25))
classifier.add(Conv1D(filters = 32, kernel_size = 3,
activation = 'relu'))
classifier.add(MaxPooling1D(pool_size = 2,
strides = 2))
classifier.add(Dropout(0.25))
classifier.add(Conv1D(filters = 32, kernel_size = 2,
activation = 'relu'))
classifier.add(MaxPooling1D(pool_size = 2,
strides = 2))
classifier.add(Dropout(0.5))
classifier.add(Flatten())
classifier.add(Dense(50, activation = 'relu'))
classifier.add(Dense(1, activation = 'sigmoid'))
classifier.compile(optimizer = 'adam',
loss = 'binary_crossentropy'
, metrics = ['accuracy'])
earlystop = EarlyStopping(patience = 3)
model.fit(setTrain, labels, batch_size = batchSize,
epochs = epochNum, validation_data = (setTest, labels),
callbacks = [earlystop])
\end{lstlisting}

The training data is prepared as described in Sec. 3.1 of~\cite{Komiske:2016rsd}. Four images
in two dimensions (azimuthal angle, $\phi$, and rapidity, $\eta$) are created from the multiplicity and
transverse energy of charged and neutral particles. The resulting images are centred and
cropped in a region $\eta$, $\phi$ $\in (-0.4, 0.4)$. Finally the images are normalised
(pixel intensities sum to 1, $\sum_{ij} I_{ij} = 1$), zero-centred (normalised mean subtracted
from pixel intensity, $I_{ij}^{'} = I_{ij} - \mu_{ij}$) and standardised (divide pixel intensity
by the standard deviation, $I^{''}_{ij} = I^{'}_{ij} / (\sigma_{ij} + r)$, $r = 10^-5$).
Finally, a further step is added where the images are projected in two 1-D projections each and
four channels are considered: charged \& neutral particle transverse energy and charged \& neutral
particle multiplicity. The resulting 1-D feature vector is appended with some
total kinematic properties such as the $K_t$ of the jet, its momentum, energy, mass,
multiplicity, etc. - producing a total of 140 individual features.
% The neural network is trained using 4 jet properties consisting of the energy,
% the combined mass of the particles in the jet, the pseudorapidity, and the jet $K_t$.
The signal and background distributions of the input variables
are shown in Fig.~\ref{fig:inputsGPD}.
%
\begin{figure*}[t]
\centering
\includegraphics[width=0.33\textwidth]{et_comp_gpd}
\includegraphics[width=0.33\textwidth]{eta_comp_gpd}
\includegraphics[width=0.33\textwidth]{m_comp_gpd}
\includegraphics[width=0.33\textwidth]{kt_comp_gpd}
\caption{\small Comparison of the signal and background distributions
used to train the Keras classifier .}
\label{fig:inputsGPD}
\end{figure*}

\subsection{Drone conversions}

The drone neural networks are trained following the procedure outlined in Sec.~\ref{sec:dlearn},
In total, 1500 epochs are used with
the learning rate of the stochastic gradient descent set to 0.05.
The value of $\kappa$ is chosen to be 0.01.

The loss history of the drone approximations are shown in Fig.~\ref{fig:loss}
as a function of epoch number.
The convergence is also shown in Fig.~\ref{fig:iterdiff}, which shows
the difference in the value of the loss function with respect to the previous
epoch. The epochs that trigger an increase in the number of hyperparameters
are also overlaid.
In total for the case of B decays, an increase was triggered 38 times compared to 67 times for the
jet separation classifier. The total number
of parameters in the final drone neural networks are therefore 302 and 10152 for the B decay drone
and the jet separation drone, respectively. It is interesting
to note that with the algorithm design of Sec.~\ref{sec:dlearn}, the introduction
of the new parameter space causes the drone networks to learn faster, as evidenced by
increases in Fig.~\ref{fig:iterdiff} with continuing descent of the loss functions.
%
The performance of the original classifiers compared to the drone classifiers are shown in Figure~\ref{fig:roc}.
\begin{figure*}[t]
\centering
\includegraphics[width=0.45\textwidth]{loss_history}
\includegraphics[width=0.45\textwidth]{loss_history_gpd}
\caption{\small
Convergence of the loss function during the drone training
  for the case of the B
  decay (left) and jet separation (right) examples.
}
\label{fig:loss}
\end{figure*}
\begin{figure*}[t]
\centering
\includegraphics[width=0.45\textwidth]{diff_history}
\includegraphics[width=0.45\textwidth]{diff_history_gpd}
\caption{\small
Difference in the loss function with respect to the previous iteration
  for the case of the B
  decay (left) and jet separation (right) examples.
  The green triangles
depict the epoch number in which the number of hyperperameters was increased.
}
\label{fig:iterdiff}
\end{figure*}
\begin{figure*}[t]
\centering
\includegraphics[width=0.45\textwidth]{roc}
\includegraphics[width=0.45\textwidth]{roc_gpd}
\caption{\small
  Signal efficiency versus background rejection of the original classifier (red) and drone
  approximation (blue)
  for the case of the B
  decay (left) and jet separation (right) examples.
}
\label{fig:roc}
\end{figure*}

\section{Drone storage and transferability and suitability
for low-latency environments}
\label{sec:storage}

The hyperparameters and structure of the drone are required to be
portable and easily stored for later usage. For this the {\tt JSON} format was chosen as
mediator. It is human-readable and easily accessible in the {\tt Python} and {\tt C++}
environments commonly used in HEP. Thus, it is readily deployable in both personal and production environments.

Provided is a tool to export and save a drone neural network to a {\tt JSON}
formatted file which preserves the input \& output structure,
the layers and nodes, all hyperparameters and activation functions.
The drone configuration is later read in by an equivalent tool into the production software framework,
which then constructs a class object based on the Keras model. The {\tt C++} class implements
a flexible member structure that is capable of completely reproducing the original drone. The production
implementation may be used for all data reduction levels, be it in the form of a low-latency trigger
for example up to the latest stages of data handling and output.

A major advantage of this method is that analysts and users have the full freedom of latest developments
of industry standards, but need only to support a more manageable implementation in the low-latency
software. This is further aided by projects such as ONNX~\cite{ONNX}, which enable classifiers from a wider
range of software packages to be converted to a framework in which an approximation converter
is available.

The identical performance show in Fig.~\ref{fig:roc} is clearly the ideal scenario, even though
such good agreement is not always required to give better results than other low-latency methods.
However it is worth noting that the drones created in the examples of Sec.~\ref{sec:hep} are faster to
evaluate. The comparison of the time taken for each model evaluation, determined from a desktop
using a Intel Core i7-4770 processor is shown in Table~\ref{tab:comp}.
\begin{table}[t]
  \centering
  \caption{Hyperparameter number comparisons of the original models and drone
  approximations for the HEP examples. \label{tab:comp_param}}
  \begin{tabular}{l|rr}
                   & original model                  & drone \\
    \hline
    B decay        & 4,111 & 302 \\
    jet separation & 71,429 & 10152 \\
  \end{tabular}
\end{table}

\begin{table}[t]
  \centering
  \caption{Processing time comparisons of the original models and drone
  approximations for the HEP examples. \label{tab:comp}}
  \begin{tabular}{l|rr}
                   & original model                  & drone \\
    \hline
    B decay        & $19.3 \pm 0.2 \times 10^{-5}$ s & $2.7 \pm 0.2 \times 10^{-5}$ s \\
    jet separation &  $3.2 \pm 0.2 \times 10^{-3}$ s & $4.3 \pm 0.2 \times 10^{-4}$ s \\
  \end{tabular}
\end{table}