\documentclass[fleqn]{goose-article}

\title{Energy barrier}
\author{Tom de Geus}
\hypersetup{pdfauthor={T.W.J. de Geus}}

\begin{document}

\maketitle

\section*{Protocol}

The protocol is as follows.
\begin{enumerate}
    \item An element is selected for triggering
    (in the example below chosen in the center of the system).
    Its location is denoted by $\vec{r}'$.

    \item A perturbation around a stress- and strain-free configuration is considered.
    To this end, the selected element (only) is subjected to an eigen stress
    $\bm{\sigma}'$.
    The corresponding equilibrium configuration then constitutes to
    the perturbation that will be used.
    It is characterised by the stress field $\delta \vec{u} (\vec{r})$, and corresponding
    stress $\delta \bm{\sigma} (\vec{r})$
    and strain $\delta \bm{\varepsilon} (\vec{r})$ fields.

    \item Two types of perturbations are considered:
    \begin{itemize}
        \item Simple shear:
        $\bm{\sigma}' = \bm{\sigma}'_s = \vec{e}_x \vec{e}_y + \vec{e}_x \vec{e}_y$.
        Gives: $\delta \vec{u}_s (\vec{r})$, $\delta \bm{\sigma}_s (\vec{r})$, and
        $\delta \bm{\varepsilon}_s (\vec{r})$.

        \item Pure shear:
        $\bm{\sigma}' = \bm{\sigma}'_p = \vec{e}_x \vec{e}_x - \vec{e}_y \vec{e}_y$.
        Gives: $\delta \vec{u}_p (\vec{r})$, $\delta \bm{\sigma}_p (\vec{r})$, and
        $\delta \bm{\varepsilon}_p (\vec{r})$.
    \end{itemize}

    For the triggered element the strain (and) stress are empirically
    of the following structure:
    \begin{itemize}
        \item Simple shear perturbation:
        $\delta \bm{\varepsilon}_s (\vec{r}') = \delta \gamma (\vec{e}_x \vec{e}_y + \vec{e}_x \vec{e}_y)$
        \item Pure shear perturbation:
        $\delta \bm{\varepsilon}_p (\vec{r}') = \delta \mathcal{E} (\vec{e}_x \vec{e}_x - \vec{e}_y \vec{e}_y)$
    \end{itemize}

    \item A perturbation $\Delta \vec{u}(\vec{r}) = s \delta \vec{u}_s (\vec{r}) + p \delta \vec{u}_p (\vec{r})$
    is then applied such that the yield surface is reached in the triggered element in such
    a way that the change in potential energy introduced by the perturbation is minimal.

\end{enumerate}

\begin{figure}[htp]
    \centering
    \captionsetup[subfigure]{justification=centering}
    \begin{minipage}[t]{.49\textwidth}
        \centering
        \includegraphics[width=\textwidth]{perturbation_simple-shear_pos.pdf}
        \subcaption{
            Simple shear:
            $\delta \vec{u}_s (\vec{r})$
        }
        \label{fig:perturbation:simple-shear:pos}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.49\textwidth}
        \centering
        \includegraphics[width=\textwidth]{perturbation_pure-shear_pos.pdf}
        \subcaption{
            Pure shear:
            $\delta \vec{u}_p (\vec{r})$
        }
        \label{fig:perturbation:pure-shear:pos}
    \end{minipage}
    \\
    \begin{minipage}[t]{.49\textwidth}
        \centering
        \includegraphics[width=\textwidth]{perturbation_simple-shear_neg.pdf}
        \subcaption{
            Simple shear:
            $- \delta \vec{u}_s (\vec{r})$
        }
        \label{fig:perturbation:simple-shear:neg}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.49\textwidth}
        \centering
        \includegraphics[width=\textwidth]{perturbation_pure-shear_neg.pdf}
        \subcaption{
            Pure shear:
            $- \delta \vec{u}_p (\vec{r})$
        }
        \label{fig:perturbation:pure-shear:neg}
    \end{minipage}
    \caption{
        Perturbation modes.
        The shown colour is the energy change resulting from the perturbation.
    }
    \label{fig:perturbation}
\end{figure}

\begin{figure}[htp]
    \centering
    \begin{minipage}[t]{.49\textwidth}
        \centering
        \includegraphics[width=\textwidth]{perturbation_phase-diagram_energy.pdf}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.49\textwidth}
        \centering
        \includegraphics[width=\textwidth]{perturbation_phase-diagram_energy-contour.pdf}
    \end{minipage}
    \caption{
        Change of internal energy, $\Delta E$, for a perturbation:
        $\Delta \vec{u}(\vec{r}) = s \delta \vec{u}_s (\vec{r}) + p \delta \vec{u}_p (\vec{r})$.
        A contour plot is also shown.
    }
    \label{fig:energy}
\end{figure}

\begin{figure}[htp]
    \centering
    \captionsetup[subfigure]{justification=centering}
    \begin{minipage}[t]{.49\textwidth}
        \centering
        \includegraphics[width=\textwidth]{perturbation_phase-diagram_sig.pdf}
        \subcaption{
            Equivalent stress.
        }
        \label{fig:phase-diagram:sig}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.49\textwidth}
        \centering
        \includegraphics[width=\textwidth]{perturbation_phase-diagram_eps.pdf}
        \subcaption{
            Equivalent strain.
        }
        \label{fig:phase-diagram:eps}
    \end{minipage}
    \caption{
        Resulting
        \subref{fig:phase-diagram:sig} equivalent stress and
        \subref{fig:phase-diagram:eps} equivalent strain
        for a perturbation:
        $\Delta \vec{u}(\vec{r}) = s \delta \vec{u}_s (\vec{r}) + p \delta \vec{u}_p (\vec{r})$.
    }
    \label{fig:phase-diagram}
\end{figure}

\clearpage

\section*{Exploring the yield surface}

\paragraph{Yield surface}

Initially the strain deviator in the triggered element reads
\begin{equation}
    \bm{\varepsilon}_\mathrm{d}(\vec{r}') =
    \begin{bmatrix}
        \mathcal{E} & \gamma \\
        \gamma & - \mathcal{E}
    \end{bmatrix}
\end{equation}
After triggering the strain deviator is
\begin{equation}
    \bm{\varepsilon}_\mathrm{d}^*(\vec{r}') =
    \begin{bmatrix}
        \mathcal{E} + p \delta \mathcal{E} & \gamma + s \delta \gamma \\
        \gamma + s \delta \gamma & - \mathcal{E} - p \delta \mathcal{E}
    \end{bmatrix}
\end{equation}
To reach the yield surface one thus needs to solve
\begin{equation}
    (\mathcal{E} + p \delta \mathcal{E})^2 +
    (\gamma + s \delta \gamma)^2 =
    \varepsilon_y^2
\end{equation}
for $(s, p)$ (with $\varepsilon_y$ the relevant yield strain).

\paragraph{Change of energy}

The energy in the system reads
\begin{equation}
    E = \frac{1}{2} \int_\Omega
        \bm{\sigma}(\vec{r}) : \bm{\varepsilon}(\vec{r})
    \; \mathrm{d} \Omega
\end{equation}
After triggering:
\begin{equation}
    E^* = \frac{1}{2} \int_\Omega
        (\bm{\sigma}(\vec{r}) + \Delta \bm{\sigma}(\vec{r})) :
        (\bm{\varepsilon}(\vec{r}) + \Delta \bm{\varepsilon}(\vec{r}))
    \; \mathrm{d} \Omega
\end{equation}
where
$\Delta \bm{\sigma}(\vec{r}) = s \delta \bm{\sigma}_s(\vec{r}) + p \delta \bm{\sigma}_p(\vec{r})$
and
$\Delta \bm{\varepsilon}(\vec{r}) = s \delta \bm{\varepsilon}_s(\vec{r}) + p \delta \bm{\varepsilon}_p(\vec{r})$.
It is straightforward to show that the change of energy
\begin{equation}
    \Delta E = E^* - E =
    \int_\Omega
        \big(\bm{\sigma}(\vec{r}) + \tfrac{1}{2} \Delta \bm{\sigma}(\vec{r}) \big) :
        \Delta \bm{\varepsilon}(\vec{r})
    \; \mathrm{d} \Omega
\end{equation}
whereby in practice integration is performed numerically, e.g.\
\begin{equation}
    \Delta E = E^* - E =
    \sum\limits_q
        \delta \Omega_q \;
        \big(\bm{\sigma}_q + \tfrac{1}{2} \Delta \bm{\sigma}_q \big) :
        \Delta \bm{\varepsilon}_q
\end{equation}

\clearpage

\section*{Example}

Two examples are included:
A homogeneous medium that is subjected to shear in \cref{fig:example:shear}, and
the same problem additionally subjected to a vertical perturbation
of the top and bottom boundaries \cref{fig:example:prestress}.

\begin{figure}[htp]
    \centering
    \captionsetup[subfigure]{justification=centering}
    \begin{minipage}[t]{.40\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_shear_config.pdf}
        \subcaption{Initial configuration.}
    \end{minipage}
    \hspace{0.01\textwidth}
    \begin{minipage}[t]{.40\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_shear_config-perturbed.pdf}
        \subcaption{After perturbation.}
    \end{minipage}
    \\
    \begin{minipage}[t]{.31\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_shear_phase-diagram_eps.pdf}
        \subcaption{$\varepsilon$}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.31\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_shear_phase-diagram_energy.pdf}
        \subcaption{$\Delta E$}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.31\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_shear_phase-diagram_energy-contour.pdf}
        \subcaption{$\Delta E$}
    \end{minipage}
    \caption{
        (a--b) Starting and perturbed configuration for a homogeneous sheared system.
        (c--e) Phase diagram of a perturbation
        $\Delta \vec{u}(\vec{r}) = s \delta \vec{u}_s (\vec{r}) + p \delta \vec{u}_p (\vec{r})$
        of the configuration in (a).
        The perturbation is applied based on $(s, p)$ that lie on the yield surface and
        that minimise the increase in potential
        energy, as shown using a red dot.
    }
    \label{fig:example:shear}
\end{figure}

\begin{figure}[htp]
    \centering
    \captionsetup[subfigure]{justification=centering}
    \begin{minipage}[t]{.40\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_prestress_config.pdf}
        \subcaption{Initial configuration.}
    \end{minipage}
    \hspace{0.01\textwidth}
    \begin{minipage}[t]{.40\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_prestress_config-perturbed.pdf}
        \subcaption{After perturbation.}
    \end{minipage}
    \\
    \begin{minipage}[t]{.31\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_prestress_phase-diagram_eps.pdf}
        \subcaption{$\varepsilon$}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.31\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_prestress_phase-diagram_energy.pdf}
        \subcaption{$\Delta E$}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.31\textwidth}
        \centering
        \includegraphics[width=\textwidth]{example_prestress_phase-diagram_energy-contour.pdf}
        \subcaption{$\Delta E$}
    \end{minipage}
    \caption{
        (a--b) Starting and perturbed configuration for a homogeneous sheared system.
        (c--e) Phase diagram of a perturbation
        $\Delta \vec{u}(\vec{r}) = s \delta \vec{u}_s (\vec{r}) + p \delta \vec{u}_p (\vec{r})$
        of the configuration in (a).
        The perturbation is applied based on $(s, p)$ that lie on the yield surface and
        that minimise the increase in potential
        energy, as shown using a red dot.
    }
    \label{fig:example:prestress}
\end{figure}

\end{document}


\documentclass{article}

\usepackage{mathrsfs, amsmath}    % need for subequations
\usepackage{verbatim}   % useful for program listings
\usepackage{color}      % use if color is used in text
\usepackage{hyperref}   % use for hypertext links, including those to external documents and URLs

\allowdisplaybreaks

\begin{document}
\section{Decision Trees}
Decision tree learning is a type of supervised learning algorithm, whose goal is to take an object $O$ and assign it a prediction $y$ based on a vector of $M$ features $x_m$. The prediction $y$ can be drawn from a set of discrete classes (classification tree) or a set of continuous numbers (regression tree). A decision tree is a type of graph, in which each node represents an element of the prediction process. Assigned to each node is a feature $x_m$. The local decision process at each node is to decide which child node to travel to based on the value of $x_m$. The terminal nodes of the tree are known as leafs. The leafs are labeled with the possible values of the prediction $y$. Thus by traversing the decision tree from the root node to a terminal leaf each object $O$ can be assigned a prediction. The question becomes how do we train a decision tree to best predict the properties of a given dataset? Another way of formulating this question is, when growing the tree, how can we decide which feature to select at each node for the decision process?

\begin{lstlisting}[language=Python]

class DecisionNode:
    def __init__(self, feature_index=None, threshold=None,
                 leaf_value=None, left_child=None, right_child=None):
        self.feature_index = feature_index
        self.threshold = threshold
        self.leaf_value = leaf_value
        self.left_child = left_child
        self.right_child = right_child
\end{lstlisting}

\section{Splitting Algorithms}
The id3 algorithm is used
\end{document}


\chapter{\GP Performance Testing}
\label{chap:GPtesting}

Before installation all of the \GP fibers were tested for throughput
performance using the Wisconsin Test Stand
\citep{Bershady04,Crause08,Eigenbrot12}. This stand is a
double-differential imaging comparator. It consists of an input stage
that reimages an illuminated aperture through a controllable aperture
at an intermediate pupil, and an output stage that consists of a
collimator that places the output pupil from the reimager or fiber
output onto a CCD detector. The experiment consists of measuring the
input beam differentially between a straight-through configuration and
the collimated fiber output. During the entire process the stability
of the filtered input beam is monitored with a photo diode.

Tests were performed in the Johnson $V$ band with an input beam set to
match the WIYN input beam of \f6.3 without the 17\% central
obstruction of the telescope. The total throughput ($T_{\rm tot}$) is
defined as all of the fiber-output light captured by the CCD (roughly
corresponding to \f2.2, compared with the fiber numerical aperture
of \f2.3)
%From 54mm L3 / 1024px * 0.024mm/px. NA = 0.22 and N = (2*arctan(NA))^-1
divided by the all of the light from the input beam captured by the
same CCD. This gives a good indication of the total transmission
through the fiber, but ignores the effects of FRD on the delivered
throughput on the Bench Spectrograph due to the optical stops
therein. FRD describes the tendency for fibers to increase the entropy
in an optical beam; light injected into a fiber at a particular
$f$-ratio emerges at a smaller (faster) $f$-ratio \citep{Angel77}.

The primary impact of FRD is from light loss from obstructions inside
the Bench Spectrograph as detailed in \cite{Bershady04} and
\cite{Bershady05}.  With the upgrade \citep{Bershady08} the low-order
gratings and camera objective are sufficiently near the pupil and are
of sufficient size that the limiting stop is from the collimator. The
camera objective does begin to vignette for off-axis fields point in
wavelength and pseudo-slit position, but for operational purposes we
consider the on-axis field point for defining throughput losses due
to FRD.  The collimator accepts light up to \f4 with only minimal
obstruction, and is completely unobstructed at \f4.4, while the
optical design (in terms of aberrations) is optimized for \f5.

To characterize the impact of FRD on the the delivered throughput we
define the quantity
\begin{equation}
\label{GPtesting:eq:T_FRD}
  T_{\mathrm{4}} = \frac{F_{\mathrm{out}}(f<\f4)}{F_{\mathrm{in}}(f<\f6.3)},
\end{equation}
where $F_\mathrm{in}$ and $F_\mathrm{out}$ represent flux from the the
input and fiber output beams, respectively. $T_4$ is essentially a
throughput measurement that accounts for the impact of FRD, and should
be representative of how the fibers will perform as part of the
WIYN/Bench system.  We compute comparable quantities for output
f-ratios of \f4.5 and \f5.  The throughput in each of these apertures,
as well as the total throughput are included in Table
\ref{GPtesting:tab:GP_cal_full} as $T_{\rm tot}$, $T_4$, $T_{4.4}$,
$T_{5}$.

\begin{figure*}[htb]
  \centering
  \includegraphics[width=0.4\textwidth]{Appendix/figs/gradpak_map.pdf}
  \includegraphics[width=0.4\textwidth]{Appendix/figs/gradpak_L_map.pdf}
\vskip -0.25in
\caption[\GP throughput and and FRD
losses]{\label{GPtesting:fig:TL_FRD}\fixspacing Maps of laboratory
  measurements of the \GP IFU performance. Throughput
  ($T_{\mathrm{FRD}}$, Equation \ref{GPtesting:eq:T_FRD}) is shown in
  the left-hand panel, while throughput losses ($L_{\mathrm{FRD}}$,
  Equation \ref{GPtesting:eq:L_FRD}), is shown in the right-hand
  panel. Performance values are given in the color scale at the top of
  each panel.}
\end{figure*}

\begin{figure}
  \centering
  \includegraphics[width=0.8\textwidth]{Appendix/figs/gradpak_facefig.pdf}
  \caption[\GP face and polishing
  detail]{\label{GPtesting:fig:gradpak_face}\fixspacing Detail of \GP
    fiber face
    after polishing. The \val{25.4}{\mu m} (0\farcs24) shims between each
    block fiber-size group are visible in the central array. The hole
    in the 5th fiber row from the bottom is a fiber that was broken
    during polishing. The two sky-fiber groups, not shown to scale,
    have locations marked in Figure \ref{891_1:fig:GradPak}.  The
    \val{200}{\mu m} (1\farcs87) sky fibers are not visible in this image
    due to imperfect illumination conditions at the slit end when this
    picture was taken.}
\end{figure}

Figure \ref{GPtesting:fig:TL_FRD} contains throughput measurements for all of
the active \GP fibers. Throughput losses caused by FRD are spatially
coherent and are larger on the top and left (North and East) side of
the IFU. This is likely due to surface scattering at the IFU face
\citep{Eigenbrot12} caused by an uneven polish. Figure
\ref{GPtesting:fig:gradpak_face} shows evidence of this variable polish in the
two sky fiber groups; the SW sky group show significantly worse polish
than the NE group and has a correspondingly lower throughput. It is
important to note that the FRD losses do \emph{not} appear to be
caused by edge fibers pushing against the aluminum structure, as
evidenced by the relatively high throughput seen on the left side of
the IFU. This is consistent with previous studies \citep{Bershady04}
that suspected removal from an IFU molding fixture to be the primary
cause of stress-induced FRD. Variations in polish quality appears to
be caused by detritus from the aluminum fixture.

As a check on the lab measurements of $T_4$ we also compare total
fiber transmission recorded during the observing program described in
\S\ref{891_1:sec:obs}. For these measurements a stitched dome flat (see
\S\ref{891_1:sec:flats} was used as a good approximation of a uniform
illumination at the fiber input. The total light transmitted by each
fiber is computed by adding together all wavelength channels for each
fiber after the data were spectrally extracted. Figure
\ref{GPtesting:fig:count_tput} shows are comparison between lab
($T_4$) and on-telescope performance. ``Counts'' in this figure are
from dome-flats combined as described in \S\ref{891_1:sec:flats}), and
are the sum across all wavelengths of the extracted fiber traces.  As
expected from Figure \ref{GPtesting:fig:TL_FRD} the highest
throughputs are found in the middle of the array, with a gradual drop
off in performance towards the end of the slit. The right panel of
Figure \ref{GPtesting:fig:count_tput} shows a tight correlation
between our lab measurements and the on-sky performance. This shows
that stresses during installation and the performance of the Bench
Spectrograph only cause a $\pm$5\% rms modulation in the throughput
compared to what was measured in the lab.

We also measure the magnitude of FRD experienced by each
fiber. Because FRD represents a scattering of input light to larger
output angles a comparison between throughput at two different output
$f$-ratios gives an approximation of the severity of FRD in each
fiber. We define
\begin{equation}
\label{GPtesting:eq:L_FRD}
  L_\mathrm{FRD} = 1 - \frac{T_5}{T_4},
\end{equation}
which quantifies the amount of light scattered to smaller $f$-ratios
(larger angles) than \f5 as a measure of the severity of FRD
experienced by each fiber.

\begin{figure*}
  \centering
  \includegraphics[width=\textwidth]{Appendix/figs/gradpak_count_plots.pdf}
  \caption[\GP on-bench throughput
  performance]{\label{GPtesting:fig:count_tput}\fixspacing Left:
    Relative fiber
    transmission measured \emph{in-situ} on the WIYN Bench
    Spectrograph. Vertical lines demark transition between different
    fiber sizes, as labeled. Right: Comparison between the
    \emph{in-situ} performance and $T_4$, as measured in the lab after
    construction. The dashed line represents a linear regression to
    the data with given correlation coefficient and scatter. Points
    are color-coded by fiber number (slit position), and sky fibers
    are marked with black squares.}
\end{figure*}

\begin{figure*}
  \centering
  \includegraphics[width=\textwidth]{Appendix/figs/gradpak_Lplots.pdf}
  \caption[\GP on-bench FRD
  losses]{\label{GPtesting:fig:FRD_loss}\fixspacing Performance
    metrics for \GP. $L_\mathrm{FRD}$ (Equation
    \ref{GPtesting:eq:L_FRD}) as a function of slit location (right)
    and $T_4$ (transmission through an \f4 aperture). Points are
    color-coded by fiber number (slit position), and sky fibers are
    marked with black squares.}
\end{figure*}

Table \ref{GPtesting:tab:GP_cal_full} contains measurements and Figure
\ref{GPtesting:fig:TL_FRD} shows a map of $L_\mathrm{FRD}$ for each
\GP fiber. Figure \ref{GPtesting:fig:FRD_loss} compares this quantity
with $T_4$. We find that fibers with low $T_4$ also tend to have high
FRD losses ($L_\mathrm{FRD}$), which indicates that FRD is a
significant source of throughput loss in the \GP and Bench
Spectrograph system.  However this is relatively more pronounced for
smaller fiber sizes, as seen in the bifurcation in the right-hand
panel of Figure \ref{GPtesting:fig:FRD_loss}. Smaller fibers tend to
suffer from larger amounts of FRD, which may have been caused in \GP
due to handling-induced stresses; these fibers were more likely to
bend and tangle during construction.  The corollary is that lower
throughput in larger fibers isn't always the result of increased FRD.

A complete set of measurements showing FRD losses as a function of
output $f$-ratio for each fiber can be found in the supplemental
materials online at \url{www.astro.wisc.edu/~eigenbrot/PAK}.

% \input{gradpak_lab_table}

\bibliographystyle{thesis}
\bibliography{ms_n891_paper}

\chapter{Grating Optimization}
\label{chap:grating}

\begin{figure*}[htb]
\centering
\vskip -1.25in
  \includegraphics[width=\textwidth]{Appendix/figs/blaze_comp_land.pdf}
\vskip -1.25in
\caption[NGC 891 observing program grating
optimization]{\label{fig:grating_comp}\fixspacing Efficiency
  comparison between 400@4.2 and 600@10.1 gratings based on dome-flat
  exposures using the same fibers, spectrograph camera-collimator
  angle, and lamp temperature and intensity. Details are provided in
  text. The top panel shows counts for each grating, while the bottom
  panel shows their ratio and the prediction (line) based on the blaze
  functions for idealized gratings.}
\end{figure*}

% inferring camera fl. of 277.1mm,
% 400@4.2 with alpha=21.8 covers 3597-7867 A; blaze wave is 3496 A.
% 400@4.2 with alpha=21.53 covers 3372-7640 A; blaze wave is 3496 A.
% 600@10.1  with alpha=24.33 covers 3795-6657; blaze wave is 5666 A.

% Notes: effective camera fl at central waves of 5524 (g600) and 5733
% (g400) is 277.1 mm compared to nominal value of 285 mm. This is due to
% chromatic behvior of all-refractive camera and the ned to
% significantly modify focus for good image-quality across our primary
% bandpass.

% The band-pass in the plots can be shifted redward or bluerward with a
% commensurate shift (or offset) in the camera-collimator angle
% w.r.t. what is plotted here.

We chose the 400@4.2 grating out of the library of gratings available
on the WIYN Bench Spectrograph because it allows us to capture
simultaneously spectra from Ca H\&K to \Ha while still maintaining
relatively high efficiency at the blue end of the spectrum.  To
optimize our grating choice we compared the 400@4.2 grating to the
600@10.1 grating. The latter provides a narrower wavelength range but
at higher resolution, and, most importantly, the covered range is
marginally sufficient to meet our scientific objectives.  The 600@10.1
grating is often the ``go to'' grating for low-resolution programs
centered around \val{5500}{\AA}, particularly because it is the newest
reflection grating and purportedly has the highest diffraction
efficiency.

For testing during engineering time we compared the 400@4.2 grating
set to 21.8$^{\circ}$ and the 600@10.1 grating set to 24.33$^{\circ}$,
both for a fixed camera-collimator angle of 30$^{\circ}$ (this is the
nominal configuration for low-order gratings).\footnote{At these
  wavelengths the effective camera focal-length for this
  all-refractive compound optic is 277.1 mm not the nominal 285 mm
  quoted in reference manuals.} These grating incidence angles gave
wavelength ranges of \val{3600}{\AA}$< \lambda <$ \val{7867}{\AA} and
\val{3794}{\AA}$< \lambda <$ \val{6655}{\AA}, respectively. The blue
Hydra cable (300 $\mu$m core fibers) was used to observe dome flats
illuminated with identical lamp intensity (and temperature)
settings. The dome lamps are known to be stable to better than 10\%
over a broad wavelength range. Although we were concerned that
temperature instability might be a factor at the blue end of our
spectral range, our results are consistent with a highly stable
illumination over our full spectral range.

The fiber flux in the dome-flat spectra was measured on the raw
two-dimensional images before extraction. This was done in order to
exclude defocus effects from the fractional flux extracted along the
trace in wavelength, and between the two grating configurations for
which the detailed focus changes with wavelength are different.
Identical fibers and extraction regions were measured in both
configurations. The regions account for a small lateral shift along
the slit due to a slight difference in the alignment angle between
gratings orthogonal to the dispersion axis (this variance is just a
mechanical tolerance in the grating mount). Taking advantage of the
numerous broken Hydra fibers, we identified well-separated
transmitting fibers that had ample separation for extracting ``on''
and ``off'' signal regions (or apertures) at all wavelengths.  These
apertures were 10-11 pixels wide, and were adjacent on the CCD.  The
resulting counts were differenced and then scaled for the
corresponding exposure time and linear dispersion.

Figure \ref{fig:grating_comp} shows the result of this experiment. It
is evident from the top panel that the 400@4.2 has greater efficiency
compared to the 600@10.1 grating blueward of 4700\AA. Since the
spectrograph configurations were identical except for the gratings,
under the assumption that the dome-flat illumination was constant, the
ratio of the two curves is equivalent to the ratio of the grating
blaze functions. As the bottom panel shows, this is very close to what
would be expected from simply computing the theoretical blaze
functions for idealized versions of these two gratings. If anything,
the 400@4.2 appears to have 10\% higher efficiency across all
wavelengths than the idealized case.

\begin{figure*}[htb]
  \centering
\vskip -1.25in
  \includegraphics[width=\textwidth]{Appendix/figs/blaze_plot_land.pdf}
\vskip -1.25in
\caption[Comparison of coverage and blaze for 400 and 600 l/mm
gratings]{\label{fig:spec_config}\fixspacing Wavelength blaze and
  coverage for the Bench Spectrograph and the 400 l/mm grating blazed
  at 4.2 deg (top panel) and the 600 l/mm grating blazed at 10.1 deg
  (bottom panel) as a function of grating incidence angle and
  camera-collimator angle with the central wavelength held
  constant. Upper and lower wavelength limits and the blaze peak are
  marked with the red, blue, and thick-dashed lines, respectively. The
  minimal desired wavelength range between the most blue-shifted Ca-K
  line and most redshifted H$\alpha$ lines (3937-6480\AA; 300-800
  \kms) is shown as the grey shaded region The camera-collimator angle
  is marked with the thin dotted line, and corresponds to the
  right-hand vertical scale; the nominal value of 30 deg is marked
  with a dot.}
\end{figure*}

Since we are working with a bench-mounted spectrograph that in
principle is highly configurable, we also considered if additional
spectrograph layout modification might further optimize
performance. In particular, by altering both the grating (incidence)
angle and the camera-collimator angle, it is possible to change the
blaze wavelength while keeping the wavelength coverage on the detector
roughly constant. The concept is illustrated in \ref{fig:spec_config}.
The effect of increasing the camera-collimator angle for low-blaze
gratings shifts the blaze wavelength to the blue. This is not
desirable for the 400@4.2 grating which already has a very blue blaze
wavelength at the nominal camera-collimator angle of 30$^{\circ}$, but
this is potentially relevant for the 600@10.1 grating. Unfortunately,
significant shifts of the blaze wavelength require very large
camera-collimator angles that are both geometrically impractical on
the existing optical bench and lead to an unacceptable decrease in
spectral coverage. The exercise does conclude that a larger
camera-collimator angle of roughly 40$^{\circ}$ would be preferable
for the 600@10.1 grating, but its performance in the far blue would
still fall short of the 400@4.2 grating.


\section{An Introduction to Isabelle}
\label{subsect.an.overview.of.isabelle}

We now provide a brief introduction to the key concepts and syntax of Isabelle/HOL.
Familiar readers may skip to Section~\ref{sect.abstract.convergence}.
A more detailed introduction can be found in the standard tutorial material~\cite{DBLP:books/sp/NipkowK14}.

\paragraph{Syntax of expressions.}

Isabelle/HOL is a logic with a strict, polymorphic, inferred type system.
\emph{Function types} are written $\tau_1 \Rightarrow \tau_2$, and are inhabited by \emph{total} functions, mapping elements of $\tau_1$ to elements of $\tau_2$.
We write $\tau_1 \times \tau_2$ for the \emph{product type} of $\tau_1$ and $\tau_2$, inhabited by pairs of elements of type $\tau_1$ and $\tau_2$, respectively.
In a similar fashion to Standard ML and OCaml, \emph{type operators} are applied to arguments in reverse order, and therefore $\tau\ \isa{list}$ denotes the type of lists of elements of type $\tau$, and $\tau\ \isa{set}$ denotes the type of mathematical (i.e., potentially infinite) sets of type $\tau$.
Type variables are written in lowercase, and preceded with a prime: ${\isacharprime}a \Rightarrow {\isacharprime}a$ denotes the type of a polymorphic identity function, for example.
\emph{Tagged union} types are introduced with the $\isacommand{datatype}$ keyword, with constructors of these types usually written with an initial upper case letter.

In Isabelle/HOL's term language we write $\isa{t} \mathbin{::} \tau$ for a \emph{type ascription}, constraining the type of the term $\isa{t}$ to the type $\tau$.
We write $\lambda{x}.\: t$ for an anonymous function mapping an argument $\isa{x}$ to $\isa{t(x)}$, and write the application of term $\isa{t}$ with function type to an argument $\isa{u}$ as $\isa{t\ u}$, as usual.
Terms of list type are introduced using one of two constructors: the empty list $[\,]$ or `nil', and the infix operator $\isa{\#}$ which is pronounced ``cons'', and which prepends an element to an existing list.
We use $[t_1, \ldots, t_n]$ as syntactic sugar for a list literal, and $\isa{xs} \mathbin{\isacharat} \isa{ys}$ to express the concatenation (appending) of two lists $\isa{xs}$ and $\isa{ys}$.
We write $\{\,\}$ for the empty set, and use usual mathematical notation for set union, disjunction, membership tests, and so on: $\isa{t} \cup \isa{u}$, $\isa{t} \cap \isa{u}$, and $\isa{x} \in \isa{t}$.
We write $t \longrightarrow s$ for logical implication between formulae (terms of type $\isa{bool}$).
Strictly speaking Isabelle is a logical framework, providing a weak meta-logic within which object logics are embedded, including the Isabelle/HOL object logic that we use in this work.
Accordingly, the implication arrow of Isabelle's meta-logic, $\isa{t} \Longrightarrow \isa{u}$, is required in certain contexts over the object-logic implication arrow, $t \longrightarrow s$, already introduced.
However, for purposes of an intuitive understanding, the two forms of implication can be regarded as equivalent by the reader, with the requirement to use one over the other merely being an implementation detail of Isabelle itself.
We will sometimes use the shorthand ${\isasymlbrakk}\isa{H}_1{\isacharsemicolon}\ \ldots{\isacharsemicolon}\ \isa{H}_n{\isasymrbrakk}\ {\isasymLongrightarrow}\ C$ instead of iterated meta-logic implications, i.e., $H_1\ {\isasymLongrightarrow}\ \ldots\ {\isasymLongrightarrow}\ H_n\ {\isasymLongrightarrow}\ C$.

\paragraph{Definitions and theorems.}

New non-recursive definitions are entered into Isabelle's global context using the $\mathbf{definition}$ keyword.
Recursive functions are defined using the $\mathbf{fun}$ keyword, and support pattern matching on their arguments.
All functions are total, and therefore every recursive function must be provably terminating.
The termination proofs in this work are generated automatically by Isabelle itself.

Inductive relations are defined with the $\mathbf{inductive}$ keyword.
For example, the definition
\begin{isabelle}
\isacommand{inductive} only-fives\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}nat\ list\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}\ \isakeyword{where}\\
~~~~{\isachardoublequoteopen}only-fives\ {\isacharbrackleft}{\isacharbrackright}{\isachardoublequoteclose}\ {\isacharbar}\\
~~~~{\isachardoublequoteopen}{\isasymlbrakk}\ only-fives\ xs\ {\isasymrbrakk}\ {\isasymLongrightarrow}\ only-fives {\isacharparenleft}5\#xs{\isacharparenright}{\isachardoublequoteclose}
\end{isabelle}
\noindent
introduces a new constant $\isa{only-fives}$ of type $\isa{nat list} \Rightarrow \isa{bool}$.
The two clauses in the body of the definition enumerate the conditions under which $\isa{only-fives}\ \isa{xs}$ is true, for arbitrary $\isa{xs}$: firstly, $\isa{only-fives}$ is true for the empty list; and secondly, if you know that $\isa{only-fives}\ \isa{xs}$ is true for some $\isa{xs}$, then you can deduce that $\isa{only-fives}\ (5\#\isa{xs})$ (i.e., $\isa{xs}$ prefixed with the number 5) is also true.
Moreover, $\isa{only-fives}\ \isa{xs}$ is true in no other circumstances---it is the \emph{smallest} relation closed under the rules defining it.
In short, the clauses above state that $\isa{only-fives}\ \isa{xs}$ holds exactly in the case where $\isa{xs}$ is a (potentially empty) list containing only repeated copies of the natural number $5$.

Lemmas, theorems, and corollaries can be asserted using the $\isacommand{lemma}$, $\isacommand{theorem}$, and $\isacommand{corollary}$ keywords, respectively.
There is no semantic difference between these keywords in Isabelle.
For example,
\begin{isabelle}
~~~~\isakeyword{assumes}\ \=\kill
\isacommand{theorem} only-fives-concat{\isacharcolon}\\
~~~~\isakeyword{assumes}\>only-fives\ xs \isakeyword{and}\ only-fives\ ys\\
~~~~\isakeyword{shows}\>only-fives (xs \isacharat ys)
\end{isabelle}
\noindent
conjectures that if $\isa{xs}$ and $\isa{ys}$ are both lists of fives, then their concatenation $xs \mathbin{\isacharat} ys$ is also a list of fives.
Isabelle then requires that this claim be proved by using one of its proof methods, for example by induction.
Some proofs can be automated, whilst others require the user to provide explicit reasoning steps.
The theorem is assigned a name, here $\isa{only-fives-concat}$, so that it may be referenced in later proofs.

\paragraph{Locales.}

Lastly, we use \emph{locales}---or local theories~\cite{DBLP:conf/tphol/KammullerWP99,DBLP:conf/types/HaftmannW08}---extensively to structure the proof, as shown in Figure~\ref{fig.proof.structure}.
In programming terms, Isabelle's locales may be thought of as an interface with associated laws that implementations must obey.
In particular, a declaration of the form
\begin{isabelle}
~~~~\isakeyword{assumes}\ \=\kill
\isacommand{locale} semigroup =\\
~~~~\isakeyword{fixes}\>f\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequoteclose}\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequoteclose}\\
~~~~\isakeyword{assumes}\>{\isachardoublequoteopen}f\ x\ (f\ y\ z)\ =\ f\ (f\ x\ y)\ z{\isachardoublequoteclose}
\end{isabelle}
\noindent
introduces a locale, with a fixed, typed constant $\isa{f}$, and a law asserting that $\isa{f}$ is associative.
Functions and constants may now be defined, and theorems conjectured and proved, within the context of the $\isa{semigoup}$ locale, i.e. definitions may be made ``generic'' in a semigroup.
This is indicated syntactically by writing $(\isacommand{in}\ \isa{semigroup})$ before the name of the constant being defined, or the theorem being conjectured, at the point of definition or conjecture.
Any function, constant, or theorem, marked in this way may make reference to $\isa{f}$, or the fact that $\isa{f}$ is associative.
\emph{Interpreting} a locale---such as $\isa{semigroup}$ above---involves providing a concrete implementation of $\isa{f}$ coupled with a proof that the concrete implementation satisfies the associated law, and is akin to implementing an interface.
Once interpreted, all functions, definitions, and theorems made within the $\isa{semigroup}$ locale become available to use for that concrete implementation.
Like interfaces, locales may be extended with new functionality, and may be specialised, by other ``sublocales'', forming a hierarchy.


\documentclass[11pt]{amsart}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{fp}  % Prevents issues with arithmetic overflow.
\usepackage{pgfplots}
\usepackage{xcolor}
\usepackage[hidelinks]{hyperref}
\usepackage[section]{placeins}  % Prevents figure placement outside of section.
\usetikzlibrary{arrows, fixedpointarithmetic}

\newcommand{\shaft}{\mathrm{shaft}}

\definecolor{matlab1}{rgb}{0, 0.4470, 0.7410}
\definecolor{matlab2}{rgb}{0.8500, 0.3250, 0.0980}
\definecolor{matlab3}{rgb}{0.9290, 0.6940, 0.1250}
\definecolor{matlab4}{rgb}{0.4940, 0.1840, 0.5560}
\definecolor{matlab5}{rgb}{0.4660, 0.6740, 0.1880}
\definecolor{matlab6}{rgb}{0.3010, 0.7450, 0.9330}
\definecolor{matlab7}{rgb}{0.6350, 0.0780, 0.1840}

\title{MEKF}
\author{Makani Technologies LLC}
\date{October 2016\; (DRAFT)}

\begin{document}
\maketitle

\section{States}

\begin{equation}
  C_g^b \approx \hat C_g^b (I + [\psi_{gb}^g]_{\times})
\end{equation}

\begin{equation}
  \vec{b} \approx \hat{b} + \delta \vec{b}
\end{equation}

\section{Propagate}

\begin{equation}
  \delta \vec{\theta} = (\vec{\omega} - \vec{b}) \cdot \Delta t
\end{equation}

\begin{equation}
  \delta q = q(\delta \vec{\theta})
\end{equation}

\begin{equation}
  {q_g^b}_{k|k-1} = {q_g^b}_{k-1|k-1} \star \delta q
\end{equation}

\begin{equation}
  \delta \vec{x} = [\delta \vec{\theta}, \delta \vec{b}]^T
\end{equation}

\begin{equation}
  \mathbf{F} = \begin{bmatrix}
    \mathbf{C}(\delta q) & \Delta t \cdot \mathbf{I} \\
    \mathbf{0}           & \mathbf{I} \\
  \end{bmatrix}
\end{equation}

\begin{equation}
  \mathbf{\hat{x}}_{k+1|k} = \mathbf{F} \mathbf{\hat{x}}_{k|k} +
                             \mathbf{B} \mathbf{w}_{k}
\end{equation}

\begin{equation}
  \mathbf{P} = \mathbf{U} \mathbf{D} \mathbf{U}^T
\end{equation}

\begin{equation}
  \mathbf{F}_k = \frac{\partial \mathbf{f}}{\partial \mathbf{x}} \bigg|_{\mathbf{\hat{x}}_{k-1|k-1}}
\end{equation}

\begin{eqnarray}
  P_{k+1|k} &=& F_k P_{k|k} F_k^T + Q_k \\
            &=& F_k U_{k|k} D_{k|k} U_{k|k}^T F_k^T + B Q_k B^T \\
            &=& W_{k|k} D_{k|k} W_{k|k}^T
\end{eqnarray}

\begin{equation}
  \mathbf{D}_w = \begin{bmatrix}
    \mathbf{D}_{k|k} & \mathbf{0} \\
    \mathbf{0}       & \mathbf{D}_q \\
  \end{bmatrix}
\end{equation}

\begin{equation}
  \mathbf{W} = [\mathbf{F} \mathbf{U}, \mathbf{B}]
\end{equation}

\section{Correct}

\begin{equation}
  h(\mathbf{x}) \equiv C_g^b \vec{v}_g
                \approx \hat{C}_g^b (\mathbf{I} + \delta \vec{\theta}_{\times}) \vec{v}_g
\end{equation}

\begin{equation}
  \frac{\partial h}{\partial \delta \vec{\theta}} = -[\hat{C}_g^b \vec{v}_g]_{\times}
\end{equation}

\end{document}


The \eslmod{histogram} module is for collecting scores, fitting
them to expected distributions, and displaying them.

The histogram automatically reallocates its bins as data points
arrive, so the caller only needs to provide some initial guidance
about bin size and ``phase'' (offset of the bins relative to the real
number line).  It accumulates counts in 64-bit unsigned integers, so
it can handle over $10^19$ total counts.  Optionally (and provided
that the caller knows it has enough memory to support this), a
``full'' histogram can be created and used to collect a sorted vector
of raw (unbinned) values.

Various different ways of fitting histogram data to different sorts of
expected distributions are supported, with interfaces to all of
Easel's statistical distribution modules. Data fitting is oriented
toward the case where the values are scores, with high scores being of
the most interest; for instance, routines for obtaining and fitting
the right (high-scoring) tail are provided, but not for the left tail.

Several of the output functions output data as XY data files suitable
for input into the popular and freely available \prog{xmgrace}
graphing program [\url{http://plasma-gate.weizmann.ac.il/Grace/}].

The API for the \eslmod{histogram} module is summarized in
Table~\ref{tbl:histogram_api}.

\begin{table}[hbp]
\begin{center}
{\small
\begin{tabular}{|ll|}\hline
    \apisubhead{Collecting data in an \ccode{ESL\_HISTOGRAM}}\\
\hyperlink{func:esl_histogram_Create()}{\ccode{esl\_histogram\_Create()}} & Create a new \ccode{ESL\_HISTOGRAM}.\\
\hyperlink{func:esl_histogram_CreateFull()}{\ccode{esl\_histogram\_CreateFull()}} & A \ccode{ESL\_HISTOGRAM} to keep all data samples.\\
\hyperlink{func:esl_histogram_Destroy()}{\ccode{esl\_histogram\_Destroy()}} & Frees a \ccode{ESL\_HISTOGRAM}.\\
\hyperlink{func:esl_histogram_Add()}{\ccode{esl\_histogram\_Add()}} & Add a sample to the histogram.\\
    \apisubhead{Declarations about binned data, before fitting}\\
\hyperlink{func:esl_histogram_DeclareCensoring()}{\ccode{esl\_histogram\_DeclareCensoring()}} & Collected data were left-censored.\\
\hyperlink{func:esl_histogram_DeclareRounding()}{\ccode{esl\_histogram\_DeclareRounding()}} & Declare collected data were no more accurate than bins.\\
\hyperlink{func:esl_histogram_SetTail()}{\ccode{esl\_histogram\_SetTail()}} & Declare only tail $>$ some threshold is considered "observed".\\
\hyperlink{func:esl_histogram_SetTailByMass()}{\ccode{esl\_histogram\_SetTailByMass()}} & Declare only right tail mass is considered "observed".\\
    \apisubhead{Accessing raw data samples}\\
\hyperlink{func:esl_histogram_GetRank()}{\ccode{esl\_histogram\_GetRank()}} & Retrieve n'th high score.\\
\hyperlink{func:esl_histogram_GetData()}{\ccode{esl\_histogram\_GetData()}} & Retrieve vector of all raw scores.\\
\hyperlink{func:esl_histogram_GetTail()}{\ccode{esl\_histogram\_GetTail()}} & Retrieve all raw scores above some threshold.\\
\hyperlink{func:esl_histogram_GetTailByMass()}{\ccode{esl\_histogram\_GetTailByMass()}} & Retrieve all raw scores in right tail mass.\\
    \apisubhead{Setting expected counts}\\
\hyperlink{func:esl_histogram_SetExpect()}{\ccode{esl\_histogram\_SetExpect()}} & Set expected counts for complete distribution.\\
\hyperlink{func:esl_histogram_SetExpectedTail()}{\ccode{esl\_histogram\_SetExpectedTail()}} & Set expected counts for right tail.\\
    \apisubhead{Output}\\
\hyperlink{func:esl_histogram_Write()}{\ccode{esl\_histogram\_Write()}} & Print a "pretty" ASCII histogram.\\
\hyperlink{func:esl_histogram_Plot()}{\ccode{esl\_histogram\_Plot()}} & Output a histogram in xmgrace XY format.\\
\hyperlink{func:esl_histogram_PlotSurvival()}{\ccode{esl\_histogram\_PlotSurvival()}} & Output $P(X>x)$ in xmgrace XY format.\\
\hyperlink{func:esl_histogram_PlotQQ()}{\ccode{esl\_histogram\_PlotQQ()}} & Output a Q-Q plot in xmgrace XY format.\\
\hyperlink{func:esl_histogram_Goodness()}{\ccode{esl\_histogram\_Goodness()}} & Evaluate fit between observed, expected. \\
\hline
\end{tabular}
}
\end{center}
\caption{The \eslmod{histogram} API.}
\label{tbl:histogram_api}
\end{table}

\subsection{Example of using the histogram API}

The example code below stores 10,000 samples from a Gumbel
distribution in a histogram, retrieves a vector containing the sorted
samples, fits a Gumbel distribution to that dataset, sets the expected
counts in the histogram, prints the observed and expected counts in an
ASCII histogram, and evaluates the goodness-of-fit.

\input{cexcerpts/histogram_example}

Some points of interest:

\begin{itemize}
\item When the histogram is created, the arguments \ccode(-100, 100, 0.5)
      tell it to bin data into bins of width 0.5, initially
      starting at -100 and ending at 100. This initialization
      is described below (see ``Specifying binning of data values'').

\item Samples are collected one at a time with
  \ccode{esl\_histogram\_Add()}.

\item After the data have been collected in a \emph{full} histogram, a
   vector of sorted raw data values can be retrieved using functions
   like \ccode{esl\_histogram\_GetData()}, and used to fit parameters
   of an expected distribution to the data.

\item In addition to the observed binned counts, you can optionally
   set \emph{expected} binned counts in the histogram by calling
   \ccode{esl\_histogram\_SetExpect()} and providing pointers
   to an appropriate distribution function and its parameters.

\item The \ccode{esl\_histogram\_Print()} function shows an ASCII text
   representation of the observed counts (and expected counts, if set)
   that looks a lot like FASTA's nice histogram output.

\item The \ccode{esl\_histogram\_Goodness()} function compares the
   observed and expected binned counts, and calculates two goodness of
   fit tests: a G-test, and a $\chi^2$ test.
\end{itemize}

\subsection{Specifying binning of data values}

The histogram collects data values into bins. When the histogram is
created, the bin width and the relative offset of the bins is
permanently set, and an initial range is allocated.

For example, the call \ccode{esl\_histogram\_Create(-10, 10, 0.5)}
creates 40 bins of width 0.5 from -10 to 10, with the first bin
collecting scores from $-10 < x \leq -9.5$, and the last bin
collecting scores $9.5 < x \leq 10.0$.

The lower bound of the initialization permanently sets the relative
offset of the bins. That is, \ccode{esl\_histogram\_Create(-10, 10,
0.5)} makes the first bin $-10 < x \leq -9.5$, whereas
\ccode{esl\_histogram\_Create(-10.1, 9.9, 0.5)} makes the first bin
$-10.1 < x \leq -9.6$.

Aside from that, the initial range is only a suggestion. You can add
any real-valued $x$ to the histogram. The histogram will silently
reallocate itself to a wider range as needed.  The ability of a
histogram to store data is effectively unlimited. Up to $2^{64}-1$
(more than $10^{19}$) counts can be collected. The histogram requires 16
bytes of storage per bin, and the number of bins it allocates scales
as $x_{\mbox{max}} - x_{\mbox{min}} / w$.

\subsection{Optional collection of raw data values: full histograms}

Normally a histogram would store only binned counts, so it can
efficiently summarize even very large numbers of samples.

In some cases it is useful to keep a list of the raw data values --
for instance, for more accurate parameter fitting to expected
distributions. This can be done by creating a ``full'' histogram with
\ccode{esl\_histogram\_CreateFull()} instead of
\ccode{esl\_histogram\_Create()}. (The example code above did this,
because it did parameter fitting to the raw data.) After data have
been collected in a full histogram, individual raw values or pointers
to sorted arrays of raw values can be retrieved using the
\ccode{esl\_histogram\_Get*} functions.

A full histogram may require much more memory: about 4 bytes per data
point. You may not want to use full histograms if your problem
involves collecting many ($> 10^9$, say) data points.

\subsection{Different parameter fitting scenarios}

By default, the data you collect are assumed to be \emph{complete}.
You observed all samples; if you fit to any expected distribution, the
expected distribution is assumed to describe the complete data; the
parameters of the expected distribution are to be fitted to an array
of the complete raw data samples; and any goodness of fit test is to
be applied to the complete data. This is the simplest, most obvious
case.

Other situations may arise. In addition to complete data, Easel is
designed to deal with four other cases:

\begin{enumerate}
\item The collected data are complete, and they are fit to a
      distribution that describes the complete data, but parameter
      fitting is done only in the right (highest-scoring) tail. This
      makes parameter fitting focus on the most important,
      high-scoring region of a score distribution, and ignore
      low-scoring outliers.

\item The collected data are complete, but they are fit to a
      distribution that only describes the right (highest scoring)
      tail, and the goodness-of-fit test is only performed on that
      tail. This case arises when we don't know the form of the
      expected distribution for the complete data, but the tail
      follows a predictable decay (an exponential tail, for example).

\item The collected data are left-censored such that no values $<
      \phi$ were recorded in the histogram, but the data are fit to a
      complete distribution that predicts the probability even of the
      censored (unobserved) values. Goodness of fit is only evaluated
      in the observed data. (This case is what is actually meant by
      left-censored data.)

\item The high-scoring right tail of the collected data are fit as the
      \emph{binned} counts in the histogram (not raw sample values) to
      a distribution that describes the tail, such as an
      exponential. This case becomes useful when the raw data values
      have limited precision (because of rounding, for example), which
      can cause numerical problems with parameter fitting to tails.
      Another case where this is useful is when there are so many data
      points that the data must be binned just as a matter of
      practicality (not enough memory to hold a full histogram).
\end{enumerate}

A variety of other situations can be dealt with by using different
combinations of the function calls that deal with these four cases.

\subsubsection{Focusing parameter fitting on the highest scores}

An example of focusing a Gumbel parameter fit on the right half of an
observed distribution:

\input{cexcerpts/histogram_example2}

The key differences from the complete data case are:

\begin{itemize}
\item Only the high-scoring 50\% of the data samples are
      retrieved, by calling
      \ccode{esl\_histogram\_GetTailByMass(h, 0.5, \&xv, \&n, \&z)}.
      This returns \ccode{z}, the number of samples that
      were \emph{censored}.

\item These data are fit to a Gumbel distribution
      as a \emph{left-censored} dataset by calling
      \ccode{esl\_gumbel\_FitCensored(xv, n, z, xv[0], \&mu, \&lambda)}.
\end{itemize}

The expected counts and the goodness of fit tests are still evaluated
for the complete data, even though the fit was performed only on the
highest scores.

\subsubsection{Fitting to a tail distribution}

An example of fitting an exponential tail to the high-scoring 10\% of
a Gumbel-distributed dataset:

\input{cexcerpts/histogram_example3}

The differences to note are:

\begin{itemize}
\item The tail is fit as if it is \emph{complete} data as far
      as the exponential distribution is concerned.

\item As a result, to use the exponential tail to predict expected
      data, we have to keep in mind how much probability mass the tail
      is supposed to predict (here, 10\%), and that
      is provided to
      \ccode{esl\_histogram\_SetExpectedTail()}, which specifically
      calculates expected counts for a tail.
\end{itemize}

\subsubsection{Fitting left-censored data}

Fitting a Gumbel distribution to data that are \emph{truly} left
censored looks a lot like the case where we extracted the high scoring
data for a censored fit:

\input{cexcerpts/histogram_example4}

\subsubsection{Fitting binned data to a tail distribution}

Normally, you want to fit parameters to the actual individual data
samples, not to binned data, because you'll get more accurate results.
An exception can arise when the data samples have limited precision
because they've been rounded off. Most distributions are not sensitive
to this, but some tail densities are, especially those with
singularities ($P(X=x) \rightarrow \infty$) at their origin. In such a
case, a fit to binned data may be superior, especially if you can
match the histogram's bins to the rounding procedure that was used.

The following code shows an example of fitting for samples that were
already rounded up to the nearest integer before adding them to the
histogram:

\input{cexcerpts/histogram_example5}

Issues to note:

\begin{itemize}
\item The \ccode{esl\_histogram\_Create(-100, 100, 1.0)} call
      defined bins that exactly match the rounding procedure
      defined by \ccode{ceil(x)} -- all $x$ that are rounded
      to the same value by \ccode{ceil(x)} would also go in
      the same bin of the histogram.

\item The \ccode{esl\_histogram\_SetTailByMass()} function sets flags
      in the histogram to demarcate the desired tail.  However,
      because the data have been binned, and we can only define the
      tail by a range of bins, it will generally be impossible to
      match the requested tail mass with adequate accuracy; the actual
      tail mass is $\geq$ the requested tail mass. It is returned
      to the caller, and it is the actual mass, not the requested mass,
      that should be used when setting expected counts.

\item The \ccode{esl\_histogram\_SetRounding()} declaration
      sets a flag in the histogram that tells binned parameter
      fitting functions that the origin of the fitted
      density ($\mu$) should be set at the lower bound of the smallest bin,
      rather than the smallest raw data value observed in that
      bin.
\end{itemize}


\documentclass[fleqn]{anstrans}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Inception Neural Networks for Isotope Identification}
\author{Samuel Dotson, Mark Kamuda, and Kathryn D. Huff}

\institute{
Dept. of Nuclear, Plasma and Radiological Engineering, University of Illinois at Urbana-Champaign \\
sgd2@illinois.edu
}

%%%% packages and definitions (optional)
\usepackage{graphicx} % allows inclusion of graphics
\usepackage{booktabs} % nice rules (thick lines) for tables
\usepackage{microtype} % improves typography for PDF
\usepackage{xspace}
\usepackage{tabularx}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage{placeins}
\usepackage{amsmath}
\include{acros}
\newcolumntype{c}{>{\hsize=.56\hsize}X}
\newcolumntype{b}{>{\hsize=.7\hsize}X}
\newcolumntype{s}{>{\hsize=.74\hsize}X}
\newcolumntype{f}{>{\hsize=.1\hsize}X}
\newcolumntype{a}{>{\hsize=.45\hsize}X}
\usepackage{titlesec}
\titleformat*{\subsection}{\normalfont}

\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Introduction}
The development of algorithms that can accurately identify the isotopic sources of low-resolution gamma-ray
spectra is an advancement in current spectroscopy workflows \cite{rawool-sullivanStepsAutomatedGamma2010}.
Previous work shows how isotope identification can be performed using
artificial neural networks
\cite{kamudaAutomatedIsotopeIdentification2018,kamudaComparisonMachineLearning2018a,kamudaAutomatedIsotopeIdentification2017b}.
This paper introduces a new feature to the existing architecture of the Artificial Neural Network for Spectroscopic Analysis (\texttt{annsa}) package, known as an Inception Neural Network (INN).
An INN implements inception layers that consist of wide convolution layers with several filters, rather than the typical single-filter layer found in simple convolutional neural networks (CNN).
This paper also demonstrates improved methods for simulating spectra to better emulate the background radiation found in real measurements.
The features of a gamma-ray spectrum vary depending on the full width at half max (FWHM) of the photopeaks.
Simultaneously applying multiple filters of different sizes allows an INN to capture more features during a single layer than a CNN.
We hypothesize that an INN will also be robust to changes in background radiation thereby generalizing the \texttt{annsa} framework to more scenarios.
We compare the accuracy of an INN to a simple CNN to determine if the improvement in accuracy warrants the increased computational complexity.
Finally, new training data will be obtained through simulations with the GADRAS-DRF software \cite{mitchellGADRASIsotopeID2014}.

\section{Theory -- Artificial Neural Networks}

An artificial neural network (ANN) maps values from ${\mathbb{R}}_{N}$ to ${\mathbb{R}}_{K}$ by mimicking biological
neurons. Examples of an arbitrary neural net and a single neuron are shown in Figures $\ref{fig:dense-nn}$ and $\ref{fig:neuron}$.

\begin{figure}[ht]
\centering
\includegraphics[width=0.5\textwidth]{../figures/dense-layer-figure.png}
\caption{An arbitrary neural network that maps values with weights (arrows) \cite{kamudaComparisonMachineLearning2018a}.}
\label{fig:dense-nn}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[width=0.5\textwidth]{../figures/neuron-figure.png}
\caption{A single neuron being passed through an activation function, $\textit{f}$ \cite{kamudaComparisonMachineLearning2018a}.}
\label{fig:neuron}
\end{figure}

The sum of the inputs times the weights, $x$, pointing to a neuron are passed through an activation function.
In this paper we used a rectified linear unit ($\textit{relu}$),
	\begin{align}
                x &= \sum_{n=1}^{N}A_i w_{ij} [-],
	\end{align}

	\begin{align}
		relu = argmax(0, x) [-],
	\end{align}

The $\textit{relu}$ function will turn $on$ a neuron if $x$ is greater than 0, otherwise the neuron stays off.
This result becomes the input for the next layer, as shown in Figure $\ref{fig:neuron}$
An artificial neural network may be trained by iteratively updating the weights of a network by minimizing an error function, $E$.
The weights are updated through back propagation by taking the derivative of $E$ with respect to the weights.
The error function minimized during training of the INN is cross-entropy,

	\begin{align}
		E = -\sum_{c}^{M}y_{o,c}\ln{p_{o,c}} [-].
	\end{align}

Eq. 2 shows the cross-entropy for multiclass classification for cases with more than two possible labels
for a given input. $M$ is the total number of labels for a given model, in this case it corresponds to 29
radionuclides \cite{nationalcommitteeonradiationinstrumentationn42AmericanNationalStandard2016}. Variable $y_{o,c}$ is binary, indicating whether observation, $o$, has the correct label, $c$.
Variable $p_{o,c}$ is the probability that $o$ is a member of $c$. The complete INN model is shown in Figure $\ref{fig:inn-layer}$ and Figure $\ref{fig:inn-full}$
The input for the INN is a 3$"$x3$"$ NaI spectrum of 1024 channels and the final output is a softmax given by,

	\begin{align}
		softmax(z_j) = \frac{e^{z_j}}{\sum_{k=1}^{k}} [-].
	\end{align}

\begin{figure}[ht]
    \centering
    \includegraphics[width=0.5\textwidth]{../figures/inn_layer_improved.png}
    \caption{A gamma spectrum shown as the input for the first inception layer.}
    \label{fig:inn-layer}
\end{figure}
\begin{figure}[ht]
    \centering
    \includegraphics[width=0.5\textwidth]{../figures/inn-full-figure.png}
    \caption{A zoomed out example of a full inception neural network.}
    \label{fig:inn-full}
\end{figure}

The input data is passed through three inception layers and, after flattening, the output is passed to a dense layer which gives the final softmax output.
Each inception layer typically has a bottleneck, a convolution, and a
concatenation \cite{szegedyGoingDeeperConvolutions2014,szegedyRethinkingInceptionArchitecture2015}.
The input spectra are a one-dimensional array with length equal to the number of channels in the detector. The purpose of the bottleneck is to reduce dimensionality without losing information. The bottleneck layer is ignored in this research because spectra are already 1D arrays.
The convolution layer uses filters to select features of a spectrum with local spatial significance and lack long-range relationships.
Once the convolution has been done with several filters in parallel, the outputs of each of those convolutions are concatenated into a single tensor and passed to the next inception layer, or dense layer if the last layer has been reached.
Just like a typical CNN, shown in Figure $\ref{fig:cnn}$, the final step after feature identification is classification.
Classification is performed by using a dense, or fully connected, layer with weights corresponding to a probability for a certain label.
In this case, the corresponding labels are radionuclides.

\begin{figure}[ht]
	\centering
	\includegraphics[width=0.5\textwidth]{../figures/cnn-figure.png}
	\caption{An example of a typical convolutional neural network \cite{kamudaComparisonMachineLearning2018a}.}
	\label{fig:cnn}
\end{figure}

\section{Methods}
\subsection{$\textit{Training Set Creation}$}
It is infeasible to obtain enough real gamma spectrum measurements to properly train a neural network.
Thus all of the datasets used to train the neural network were simulated using GADRAS-DRF \cite{mitchellGADRASIsotopeID2014}.
The 29 isotopes in the dataset are based on the American National Standards Institute performance criteria for handheld instruments for the detection and identification of radionuclides, ANSI N42-34-2015 \cite{nationalcommitteeonradiationinstrumentationn42AmericanNationalStandard2016}.
Previous work \cite{kamudaComparisonMachineLearning2018a} used a uniform distribution of background isotopes and a constant average count of 65 counts per second (cps) for the background.
Simulating background radiation in this manner fails to capture the variability of real background spectra.
We are updating the simulation protocol to include variations in background conditions. New simulated data will include random noise in a range of 40 to 200 cps.
We believe this range is realistic for background radiation.

\subsection{$\textit{Network Structure and Hyperparameters}$}
A neural network can memorize training sets resulting in overtraining and a misidentification of novel data.
This is especially true for an INN, whose weights are difficult to tune with simple back propagation.
To solve this problem during training, we include an intermediate softmax output allowing for error corrections before the entire forward pass is complete.
This branch is ignored during prediction, but offers a way to prevent overtraining.
In the fully connected layer, dropout regularization forces the neural network to learn new pathways.
Hyperparameters can be used to optimize performance and prevent overfitting of the model.
There is no way to know which hyperparameters will influence the model before training, so a random hyperparameter search is performed to find a set of hyperparameters close to the ideal set\cite{bergstraRandomSearchHyperParameter2012}.
For CNN structures, like the INN, hyperparameters include the sizes of convolutional filters, the output size (how many filters of each size), the number of nodes in a dense layer, and dropout rate \cite{kamudaComparisonMachineLearning2018a} shown in Table \ref{tab:hyper}. We also include two INN-specific hyperparameters: Number of inception layers and number of filters per layer. Having a choice in the number of filters exemplifies the benefit of using an INN. Instead of convolving an input with filters of only a single size we can convolve many filter sizes and then concatenate the result as in Figure \ref{fig:inn-layer}.

\begin{table}[ht]
\caption{Hyperparameter Space for INN}
\centering
\begin{tabular}{l r}
\hline\hline
Hyperparameter & {Values}\\
\hline
\#inception layers & {1,2,3}\\
\#filters & {3,4,5}\\
output size & {3,5,7,9,11}\\
kernel size & {5, 10, 15, 20, 25, 30, 35,}\\
			& {40, 45, 50, 55, 60}\\
dropout rate & {{0.0, 0.1, 0.2, 0.3, 0.4, 0.5}}\\
dense layer size & {32, 64, 128, 256}\\
\hline
\end{tabular}
\label{tab:hyper}
\end{table}

\subsection{$\textit{Benchmark Techniques}$}

In order to compare the efficiency of an INN to a traditional CNN we will use the data and results from \cite{kamudaComparisonMachineLearning2018a} to train and benchmark the INN. Then we will retrain the CNN and the INN using new and varied data. These comparisons will allow us to determine if, and by how much, an INN is an improvement over a CNN. It will also show us how dataset creation affects the robustness of the models.
The INN will be considered superior to CNN performance if equivalent training reduces prediction variance.
For concreteness, a 10$\%$ increase in training time should correspond to a 10$\%$, or greater, decrease in the variance for the INN when compared with the training time and variance of the CNN.

\section{Conclusion}

In this study, we compare the accuracy of two neural networks, a convolutional neural network with two convolutional layers and an inception neural network with three inception layers, for identifying radioactive isotopes in low-resolution gamma-ray spectra.
We hypothesize that an INN will exhibit an increase in robustness commensurate to its computational complexity and training the neural networks with larger and varied datasets will also improve their robustness.
Improvements to the identification of isotopes present in a sample of radioactive material will have implications for national security and nuclear nonproliferation.

\section{Acknowledgments}

This work was funded by the Consortium for Verification Technology under Department of Energy National Nuclear Security Administration award number
DE-NA0002534.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bibliographystyle{ans}
\bibliography{bibliography.bib}
\end{document}