\documentclass[11pt]{article}
\usepackage[
top    = 2.50cm,% presumably you don't want it to be 0pt as well?
bottom = 2.50cm,
left   = 2cm,
right  = 2cm,
marginparsep = 0pt,
marginparwidth=0pt,
]{geometry}

\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{tikz, tikz-3dplot}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{multicol}
\pagestyle{fancy}
\fancyhead[l]{Gravitation - Abridged edition}
\fancyhead[r]{Giorgio Grigolo {\textcopyright}}
\newcommand\textcenter[1]{
	\begin{center}
		#1
	\end{center}
}
\begin{document}

\section{Newton's Law of Gravitation}

\textcenter{\textit{Any two masses in the universe attract  one another with a force that is proportional
	to the product of the two masses and inversely proportional to the square of the distance between them.}}

\begin{equation}
	F= \frac{GMm}{r^2}\tag{\si\newton}
\end{equation}

\textcenter{Where G is the \textbf{Universal Gravitational Constant}\footnote{$6.67\times10^{-11}\,\si{\newton\meter\squared\per\kilogram\squared}$}, $M$ and $m$ are two \textbf{masses} (\si{\kilogram}) of two different bodies and $r$ the \textbf{radius} (\si{\meter}) between the primary and secondary bodies respectively.}

\section{Gravitational field strength: }

\begin{equation}
	g=\frac{GM}{R^2}\tag{\si{\newton\per\kilogram}}
\end{equation}

\textcenter{Where G is the \textbf{Universal Gravitational Constant}\footnotemark[1], $ M $ is the \textbf{mass} (\si{\kilogram}) of a body and $ R $ the \textbf{distance} (\si{\meter}) between the center of the body to the point where the field strength is to be measured\footnote{Most of the time this is the radius of a planet, where the field strength is measured at its surface.}. }

\section{Velocity of Orbit: }
\begin{equation}
	v=\sqrt{\frac{GM}{r}}\tag{\si{\meter\per\second}}
\end{equation}
\begin{center}
		\tdplotsetmaincoords{70}{110}
	\begin{tikzpicture}[tdplot_main_coords,scale=6]
		\pgfmathsetmacro{\r}{.8}
		\pgfmathsetmacro{\O}{45} % right ascension of ascending node [deg]
		\pgfmathsetmacro{\i}{30} % inclination [deg]
		\draw[<->] (0,-0.035,0) -- node[below]{r} ++ (0,-0.75,0) ;

		\tdplotdrawarc[dashed]{(0,0,0)}{\r}{0}{360}{}{}

		\tdplotsetrotatedcoords{\O}{0}{0}

		\node[circle,fill, inner sep=2pt, label=$m$] (c) at (0,-0.8,0) {};
		\node[circle,fill, inner sep=4pt, label=$M$] (c) at (0,0,0) {};
	\end{tikzpicture}\\
\textcenter{Where G is the \textbf{Universal Gravitational Constant}\footnotemark[1], $ M $ is the \textbf{mass} (\si{\kilogram}) of the priamry body.}
\end{center}

\section{Kepler's Third Law}

\begin{equation}
	T^2 = \frac{4\pi^2r^3}{GM}
\end{equation}

\textcenter{Where $T$ is the \textbf{time of orbit} (\si{\second}), $r$ is the \textbf{distance} (\si\meter) between the center primary body and the center of the secondary body.}
\end{document}


\documentclass[10pt]{article}
\input{crtdefs}
\afourSetup{}
\title{Optimal Resource Allocation for Search \& Rescue}
\author{dwa, crt, AGM}

\begin{document}
%\abstract{\textsc{draft} An optimal solution to the problem of
%  allocating multiple search resources to multiple areas, where each
%  resource may have a different effectiveness in each area. We assume
%  all resources use the random (exponential) detection function, as
%  is appropriate for ground searchers.}
\maketitle

In searching for a lost person, we usually have far fewer resources
than needed to search the whole possibility area thoroughly. And it is
important that we find the person as quickly as possible. In order to
do this, we need not to waste any effort. We need to find an
\emph{optimal} allocation of various resources at hand to the area at
hand. A crucial first step is to divide the whole possibility area
into a number of smaller areas or regions of known size, and assign to
each region a probability of containing the subject. Ideally we have
divided the possibility area finely enough so that each region denotes
one particular type of terrain and vegetation, and all parts of that
region have the same probability density. The solution presented here
assumes this has been done.

Once the area has been divided into regions, we need to look at our
resources. For each type of resource we need the amount of effort
available (in resource-hours, for example). We also need to know how
effective each type of resource is in each region. To this end, most
likely what we will have is a set of travel speeds and sweep widths
for each resource in standard conditions, and some modifying factors
which can be applied given the terrain, vegetation, weather, etc.

Given this information a computer may quickly find an optimal
allocation of resources to areas. Because we have represented our
effort abstractly in terms of resource-hours, and because we are doing
our allocation as a block, our optimal solution is what has been
called ``T-optimal'' \cite{}: no other allocation of \emph{all
  available} effort will yield a greater total probability of success.

\section{Previous solutions}
\label{sec:Previous-solutions}

Two restricted problems have been solved. The \emph{Charnes-Cooper
  algorithm} (\cite{}) solves the case of
allocating the effort of one single kind of resource across many
areas, where the effectiveness of the resource varies by area. The
solution is to sort the areas by a quantity known as the probable
success rate $(PSR)$.

Alternatively, if we ignore the fact that resource effectiveness
changes with region, then we can solve the problem for any number of
resources using a slight simplification of the Charnes-Cooper
algorithm: we sort the areas by probability-density.

Both such solutions are very efficient. They run in O$(A^2)$ time,
meaning that the time to compute the solution goes up as the square of
the number of areas. Since we probably never have more than 1000 areas and
1000 resources, any computer can solve the problem quite quickly.

In the general problem, however, we have multiple resources, all of
which may vary in effectiveness across regions. One way to approach
the problem is to divide all of our resources into teams ahead of
time, and then to find that assignment of teams to areas which
maximizes our probability of success. In essence we just try all
combinations. This is the approach taken by CASIE III (\cite{}).

However, even if we add the restriction that we may have precisely one
resource to one area, the problem has a complexity of O$(A^R)$: the
time goes up as the exponential of the number of resources. Even a
moderate search of say 10 areas and 10 resources requires
10,000,000,000 steps. Even if solved, this solution is not an optimum
allocation of effort! It is merely an optimum given how we divided
up the available resource pool. Faced with that kind of combinatorial
explosion, the general problem of optimum resource allocation for
search has resisted solution.

However, if we allow the idealization that the available effort can be
divided arbitrarily finely, then we can use some optimization
techniques from linear algebra and linear programming to solve the
problem. It appears that a solution can be found with a complexity of
O$R(A+1)$ which is basically the number of resources times the number
of areas, or 100 in the previous example.

The key is to find the proper global function to optimize, and
conceptually to perform the optimization all at once, rather than
combinatorially.

\section{Deriving the Function}
\label{sec:Deriving-Function}

In order to derive the function we need to optimize, we have to
transform the problem from the language of search-and-rescue to a more
convenient notation. In this section we do this twice. First, using
the traditional phrasing and notation of the search community. Second,
using the same ideas but with the cleaner notation of conditional
probability, which is really what the search problem is about. First
we define our variables.

\subsection{Background}
\label{sec:Background}

The basic equation governing search probability theory\footnote{There
  is no new material in this section. We are merely laying out search
  theory, as can be found in \cite{}, in a convenient manner for
  subsequent derivations.} states that the probability of success
$(POS)$ of any search assignment is equal to the product of two other
probabilities: the probability that the subject is in the area $(POA)$
and the probability of detecting the subject if they are in that area
$(POD)$.
\begin{equation}
  \label{eq:POS}
  POS = POA \times POD
\end{equation}
For now we shall just accept this. It can be derived from a few simple
considerations about search and Bayes' theorem, but we leave that to
the section on conditional probabilities.

Once an area is searched (without
success), the subject is less likely to be there, in proportion to how
well the area was search. In other words, after a search, the $POA$ of
the region searched decreases. It can also be shown that the usual
formula is correct:
\begin{equation}
  \label{eq:POA_new}
  POA_{new} = POA_{old} - POS
\end{equation}

It is easy to understand $POA$. Each region has a known area (in
square meters, for example), and a probability of area $POA$, the
probability that the subject is in that area.\footnote{Sometimes
  called the probability of containment, $POC$ since it is the
  probability that the area in question contains the subject.} The
$POA$ is usually determined by a Mattson consensus (a fancy name for
``average'') from case histories, known facts, and probable scenarios.
Here we will just assume that it is given and correct. Often we
combine these two items to define the \emph{probability density}:
\begin{equation}
  \label{eq:2}
  Pden = \frac{POA}{area}
\end{equation}
Sometimes $Pden$ is written as greek letter $\rho$, since it looks
like a funny `p'.

It is a little more involved to get the $POD$ of a resource in an
area. Although search managers usually use various crude estimation
techniques (``If there were 100 milk jugs in the area, how many do you
think you would have found?''), search theory provides a better way to
measure $POD$ based on how much effort was applied.

First, every resource can move with a certain speed $v$ in a certain
region and at that speed (in those conditions) have a certain
\emph{effective sweep-width}, usually denoted capital $W$.  $W$ is a
measure of how far that resource can expect to see and detect objects.
There are tables of sweep widths for many resources in many
conditions. We shall presume we have them available.\footnote{Alas,
  there are few or none for ground searchers yet. Until as a community
  we can conduct some experiments, one of the authors will attempt to
  make reasonable estimates available perhaps using the testing data
  from SARTECH exams.}

Together $W$ and $v$ make up the \emph{effective sweep-rate}, $ESR = W
v$. $ESR$ measures how quickly the resource can sweep areas. We let
$x$ be our measure of how much effort (resource-hours) has been put in
the region.

To get $POD$ we need to know how well the region has been
\emph{covered}. \emph{Coverage} is a measure of how thoroughly a given
amount of effort was able to search an area of a certain size. Higher
coverage means higher $POD$. For a given amount of a particular
resource's effort, a bigger area means less coverage. Likewise, for a
given amount of effort in a given area, a resource with a bigger $ESR$
will have more coverage. And finally, the longer we leave the resource
in a region (or the more of it we put there), the more area it sweeps,
and the higher the coverage. So, if we let $x$ be a measure of how
much of the resource's effort we put in an area, we may define a
resource's \emph{coverage}:
\begin{equation}
  \label{eq:C}
  C = \frac{ESR x}{area}
\end{equation}

And $POD$ must be a function of coverage. It must be such that $POD$
starts at zero when we have zero coverage, and $POD$ can
never exceed 1 no matter how much we cover the area. One function
which can do this is a negative exponential function. But we're not
just picking functions out of the air. It turns out that this is the
proper function for what is called \emph{random search}, and that
almost any real ground search is best modeled by the random-search
curve. \cite{} Therefore,
\begin{equation}
  \label{eq:3}
  POD = 1 - e^{-C}
\end{equation}
which can also be written
\begin{equation}
  \label{eq:9}
  POD = 1 - exp(-C)
\end{equation}
(Since later on we will have many things in the exponent, it will be
easier to read if we use the `$exp$' form.)

\subsection{Derivation 1: SAR notation}
\label{sec:SAR-notation}

We have $R$ resources available for searching. Together, they give us
the total amount of available effort, $X$. The effort due to any
resource $r$ is $x_r$. It follows that
\begin{equation}
  \label{eq:10}
  X = \sum_{r=1}^N x_r
\end{equation}

We also have $A$ areas to search. Each area $a$ has a certain
probability of area $POA_a$. Usually all probabilities initially sum
to 1, but since they do not really have to be normalized, the only
constraint is that: $(0 < \sum_{a=1}^A POA_a \leq 1)$.

Our problem is to figure out the best way to allocate all available
effort among the many areas. The effort  $x_r$ from any resource
may be split among any number of areas, but $r$ will always be used
completely, so $\sum_{a=1}^A x_{r,a} = x_r$.

Conversely, several resources may combine their efforts in any one
area. But while there may be many areas left unsearched, we will never
fail to use a resource fully.

Coverage is defined in terms of resources and areas. If $ESR_{r,a}$ is the
ESR for resource $r$ in area $a$, then the coverage in area $a$ by
resource $r$ is:

\begin{equation}
  \label{eq:C_ra}
  C_{r,a} = \frac{ESR_{r,a}}{A_a} x_{r,a}
\end{equation}

However, because the area sizes and the $ESR_{r,a}$ remain fixed,
rather than continuing to write $\frac{ESR_{r,a}}{A_a}$, we will
just define a new variable $w_{r,a} = \frac{w_{r,a}}{A_a}$ and write:
\begin{equation}
  \label{eq:C_ra}
  C_{r,a} = w_{r,a} x_{r,a}
\end{equation}

Once we know the coverage, we can find the $POD$.
\begin{equation}
  \label{eq:POD_ra}
  POD_{r,a} = 1 - exp(-C_{r,a}) = 1 - exp(-w_{r,a} x_{r,a})
\end{equation}

Now in the background section, we wrote the governing equation of
search theory $POS = POA \times POD$, and the associated equation for
updating the $POA$ of a region after an unsuccessful search:
$POA_{new} = POA_{old} - POS$.

Since the second equation is just subtraction, we can apply the
formula repeatedly, and define the $POA$ for any sortie in terms of
the original $POA$ and the sum of all the $POS$ from all previous
searches. If we number our searches with an index $i$:
\begin{equation}
  \label{eq:POA2'}
  POA_{i+1} = POA_0 - \sum_1^i POS_i
\end{equation}

This generalizes quite easily to our notation. If the initial $POA$
for area $a$ is just $POA_a$, then to compute the current $POA$ facing
our next resource $r$ in area $a$, we sum over the
previously-allocated resources (up to resource $r-1$)\footnote{
  The order in which we consider resources for assignment is
  immaterial: all we want in the end is the right global allocation.
  So we might as well pick the resources straight off the list in
  order $1 \ldots r$. Which is how we have done it here.}
:
\begin{equation}
  \label{eq:POA_ra}
  POA_{r,a} = POA_a - \sum_{i=1}^{r-1}POS_{i,a}
\end{equation}

Using the basic identity from equation \ref{eq:POS} ($POS =
POA \times POD$), we can
rewrite \ref{eq:POA_ra} in terms of products (see the appendix for derivation):
\begin{eqnarray}
  \label{eq:15}
  \nonumber POA_{r,a} &=& POA_a \left[(1-POD_{1,a})\cdots(1-POD_{r-1,a})\right]\\
                   & & \\
  \nonumber &=& POA_a \left[exp(w_{1,a}x_{1,a}) \cdots exp(w_{r-1,a}x_{r-1,a})\right]\\
  \nonumber &=& POA_a \left[exp\left(\sum_{i=1}^{r-1}w_{i,a}x_{i,a}\right)\right]
\end{eqnarray}
At this point we are almost done.

Putting the $POS_{r,a}$ and the $POA_{r,a}$ together:
\begin{equation}
  \label{eq:POS2_ra}
  POS_{r,a} = POA_{r,a} \cdot POD_{r,a}
\end{equation}
which again comes from equation \ref{eq:POS}.

And, in the end, we want to \emph{maximize} the \emph{total}
$POS$. The total $POS$ is just the sum over both $r$ and $a$. Writing
this out and substituting for $POA_{r,a}$ we find:
\begin{eqnarray}
  \label{eq:POS_tot}
  POS &=& \sum_{a=1}^A \sum_{r=1}^R POS_{r,a}\\
  \nonumber &=& \sum_{a=1}^A POS_{1,a} + POS_{2,a} + \cdots + POS_{R,a}\\
  \nonumber &=& \sum_{a=1}^A \left[
    POA_a POD_{1,a} +
    POA_a exp(-w_{1,a}x{1,a}) POD_{2,a} + \cdots +
    POA_a exp\left(-\sum_{i=1}^{R-1}w_{i,a}x_{i,a}\right) POD_{R,a}
    \right]\\
   &=& \sum_{a=1}^A POA_a \left[
     POD_{1,a} +
     exp(-w_{1,a}x{1,a}) POD_{2,a}+ \cdots +
     exp\left(-\sum_{i=1}^{R-1}w_{i,a}x_{i,a}\right) POD_{R,a}
     \right]
\end{eqnarray}

Finally, if we expand the $POD_{r,a}$ terms we find that many of the
exponents cancel, leaving us with a much simpler form.

\fbox{
  \parbox{6in}{
  \begin{eqnarray}
    \label{eq:pos-final}
    \nonumber POS &=& \sum_{a=1}^A POA_a \left[
      (1-exp(-w_{1,a}x_{1,a})) +
      exp(-w_{1,a}x{1,a}) (1-exp(-w_{2,a}x_{2,a}))+ \cdots +\right. \\
    & & \left. exp\left(-\sum_{i=1}^{R-1}w_{i,a}x_{i,a}\right)
      \left(1-exp(-w_{R,a}x_{R,a})\right)
    \right]\\
    &=& \sum_{a=1}^APOA_a \left[
      1 - exp\left(-\sum_{i=1}^Rw_{i,a}x_{i,a}\right)
    \right]
  \end{eqnarray}
  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Conditional Probability Notation}
\label{sec:Cond-Prob-Notat}

The initial probability (before we get new evidence) for anything is
called its \emph{prior probability}. For example, we know from the
start that we will use all of our resources. Therefore the prior
probability for any resource is 1:
\begin{equation}
  \label{eq:p(r)}
  \Pr(R) = 1
\end{equation}

Each area has an initial (prior) probability of containing the
subject, which is usually called the $POA$ in search terms. We will
call is $\Pr(A)$.
\begin{equation}
  \label{eq:p(a)}
  \Pr(A) = POA
\end{equation}

The probability of something given that we know something else is
called the \emph{conditional probability}. For example, we might wish
to know the conditional probability of an area $A$, given that we have
chosen a particular resource $R$. This one is easy: the probability of
an area does not depend upon which resource we use
to search it, so it equals its initial probability:
\begin{equation}
  \label{eq:p(a|r)}
  \Pr(A|R) = P(A)
\end{equation}

For a resource searching in the area containing the subject, the
probability of detecting the subject is given by search
theory\footnote{This is the correct formula for the ``random'' or
  ``exponential'' detection profile, which is shown in \cite{} to be
  the most appropriate model for ground search.}
as $1 - e^{-C}$. Keeping with our notation in the previous section, we
use $x_{r,a}$ to denote the amount of effort from resource $r$ used in
area $a$, and $w_{r,a}$ to denote the effectiveness of the resource in
that area. So:
\begin{equation}
  \label{eq:4}
  \Pr(D|R,A) = 1 - e^{-w_{r,a} x_{r,a}}
\end{equation}

So what is the \emph{posterior} probability of an area? It is the
probability that the subject is in the area given that we have
searched but \emph{not detected} ($\no{D})$ the subject. If we have
$N$ resources, then by Bayes'
theorem (without renormalization):
\begin{eqnarray}
  \label{eq:a|-d}
  \Pr(A|\no{D}) &\propto& \Pr(A) \cdot \Pr(\no{D}|A)\\
  \nonumber     &=& \Pr(A) \cdot \left[\Pr(\no{D}|R_1,A) \ldots
                   P(\no{D}|R_N,A)\right] \\
  \nonumber     &=& \Pr(A) \left[\Pr(\no{D}|R_1,A) \ldots
                   P(\no{D}|R_N,A)\right] \\
  \nonumber     &=& \Pr(A) \left[e^{-w_{1,a} x_{1,a}} \ldots
                   e^{-w_{N,a} x_{N,a}} \right]\\
  \nonumber     &=& \Pr(A) exp\left(-\sum_{k=1}^N w_{k,a} x_{k,a}\right)
\end{eqnarray}

That gives us the updated probability for one area. And to get the
total probability that we have \emph{not} detected the subject up
until now, we just sum over the areas. By definition, this is just the
sum over areas of the \emph{joint probability} of being in each area
and being not-detected:
\begin{equation}
  \label{eq:6}
  \Pr(\no{D}) = \sum_A \Pr(\no{D},A)
\end{equation}
But the joint probability of $\no{D}$ and $A$ is by definition:
\begin{equation}
  \label{eq:8}
  \Pr(\no{D},A) =  \Pr(A) \Pr(\no{D}|A)
\end{equation}
which is just the right-hand-side of Equation \ref{eq:a|-d}. We
infer that:
\begin{equation}
  \label{eq:-d|a}
  \Pr(\no{D}|A) = exp\left(-\sum_{k=1}^N w_{k,a} x_{k,a}\right)
\end{equation}

Of course, in the end we want to maximize our chances of \emph{actually
  detecting} the subject, for the \emph{whole set of
  assignments}. Usually called the ``probability of success,'' this is
really just the overall $\Pr(D)$.

\fbox{
  \parbox{6in}{
    \begin{eqnarray}
      \label{eq:p(d)}
      \nonumber \Pr(D) &=& \sum_A \Pr(A) \Pr(D|A)\\
      \nonumber  &=& \sum_A \Pr(A) \left[ 1 - \Pr(\no{D}|A) \right]\\
      & & \\
      \nonumber  &=& \sum_A \Pr(A) \left[ 1 - exp\left(-\sum_{i=1}^N w_{i,a}
          x_{i,a}\right) \right]
    \end{eqnarray}
    }
  }

Note that this agrees with Equation \ref{eq:pos-final}, the overall
$POS$ derived using conventional notation, except that we have
replaced the letter $R$ with the letter $N$. In the rest of the paper
we will go back to using $R$.

\fbox{actually it wd be better to replace `R' with `r' and `N' with `R'}

\section{Optimizing the Allocation}
\label{sec:Optim-Alloc}

\fbox{ Need to update this section.}

But since $\Pr(D) = 1 - \Pr(\no{D})$, it follows that we
should \emph{minimize} our overall chance of missing the subject:
$\Pr(\no{D})$.

    \begin{eqnarray}
      \label{eq:7}
      \Pr(\no{D}) &=& \sum_A P(\no{D},A)\\
      \nonumber &=& \sum_A \Pr(A) e^{-\sum_{k=1}^N S_{k,a} x_{k,a}}
    \end{eqnarray}

Another way to get the same answer is to maximize the cumulative
$POS_A = P(A) - P(A|\no{D})$. It comes out to the same thing, and is
more familiar to search managers.

Fine, now we know what function we need to optimize. How do we do it?

I have some very good news. To find the solution to your problem only
requires solving $R + RA = R(A+1)$ linear equations, where $R$ is the
number of resources and $A$ is the number of areas.

I will give you details on Friday, if you are interested (I will not be in
tomorrow). However, an outline goes as follows.

Your problem can be stated as find $x_{i,j} >= 0$ which minimize

\begin{equation}
f = \sum_{i=1}^A p_i*g_i
\end{equation}
where

\begin{equation}
  g_i = exp(-\sum_{k=1}^R w_{i,k}*x_{i,k}), \;\; i=1,\ldots,A
\end{equation}

and we also know that:

\begin{equation}
  \sum_{i=1}^A x_{i,j} = T_j, \;\; j=1,\ldots,R
\end{equation}

Now, let

\begin{equation}
   L = \sum_{i=1}^A p_i*g_i + \sum_{j=1}^R L_j*(\sum_{i=1}^A x_{i,j}-T_j)
\end{equation}

Then the problem can be reformulated as find the critical points of $L$ (ie
those values of $x_{i,j}$ and $L_j$ where the partial derivatives of $L$ are
zero), where $x_{i,j}$ are positive.

However, the partial derivative of $L$ with respect to $x_{i,j}$ is zero when
\begin{equation}
         p_i*g_i*w_{i,j} = L_j
\end{equation}

Taking logs, and letting $c_j = log(L_j), j = 1,\ldots,R$, we get
\begin{equation}
         c_j + \sum_{k=1}^R w_{i,k}*x_{i,k} = log(p_i) + log(w_{i,j})
\end{equation}

for $i = 1,\ldots,A$ and $j = 1,\ldots,R$. Also, we have the equations
\begin{equation}
         \sum_{i=1}^A x_{i,j} = T_j, j=1,\ldots,R
\end{equation}

So, all we need to do is solve these $R(A+1)$ linear equations for $c_j$ and
$x_{i,j}$.

Which of course we are now working on.

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


\begin{refsection}
\chapter{The Carey Foster Bridge}

\section*{Objectives}

\begin{enumerate}
\item To understand how a Carey Foster bridge works.
\item To find the value of an unknown low resistance using the Carey Foster bridge.
\end{enumerate}

\section*{Introduction}
\subsection*{Measurement of low resistance}
Ohm's law, $V=IR$, states that the current flowing through a resistor with resistance $R$ varies linearly with the potential difference across it.
To measure the resistance, one method involves studying the IV characteristics of a resistor, i.e looking at the variation in the current, $I$, flowing through the resistor for a range of applied potential differences, $V$ and then extracting the value of the resistance, $R$, from the resulting graph/data. This direct application of Ohm's law usually works well for resistances in the range $1-100 \Omega$.

\begin{figure}[!htb]
    \centering
    \includegraphics[width=0.5\textwidth]{figs/wheatstone.png}
    \caption{Schematic diagram of a Wheatstone bridge.}
    \label{fig:wheatstone}
\end{figure}

For the measurement of low resistances, it is preferable to use methods that work on comparison of resistances (so you would need, in the first place, some precisely known, standard resistances). Such methods are based on the principle of a Wheatstone's bridge. A Wheatstone bridge is shown in Figure (\ref{fig:wheatstone}). A current measuring device, the galvanometer, registers current flowing in the arm $BD$. However, when the nodes $B$ and $D$ are at the same potential, no current flows in the arm $BD$. This happens when the following relation between the resistances is satisfied
\begin{equation}
    \frac{P}{Q}  =\frac{R}{S}
    \label{balanceofthebridges}
\end{equation}
In such a situation, the Wheatstone bridge is said to be \textit{balanced}.
To find out the resistance of an unknown resistor, two standard resistors are wired in arms $AB$ and $BC$. The value of the (variable) resistor, $R$, is varied until the point of zero/null deflection/display is found on the galvanometer. Since, the bridge is now balanced, Equation (\ref{balanceofthebridges}) holds good, and we can infer the value of an unknown resistance, $S$.

We note here that this null method, which hinges on balancing the Wheatstone bridge, is useful because by not measuring a finite value of the current, the galvanometer does not have any role to play in the accuracy of the resistance measurement, our measurement of an unknown low resistances is limited only by the precision of other resistors in the experimental setup. In this experiment, we will use a form of modified Wheatstone bridge called a Carey Foster bridge, which is useful to measure low resistances while eliminating end corrections.

% \section*{Description}

% In \textbf{Part A}, you will determine the apparent value of a small resistance.

% In \textbf{Part B}, you will determine a small correction.

%In \textbf{Part C},

\section*{Theory}

\begin{figure}[!htb]
    \centering
    \includegraphics[width=\textwidth]{figs/carey.png}
    \caption{Schematic diagram of the Carey Foster bridge.}
    \label{fig:carey}
\end{figure}

The Carey Foster bridge with a circuit around it is illustrated in Figure (\ref{fig:carey}).
%The shaded part is a copper strip
The bridge consists of a copper strip with four gaps (these act as four arms of a Wheatstone’s bridge). Two known resistances $P$ and $Q$ (equal and small) are connected in the inner gaps, $VV^{\prime}$ and $WW^{\prime}$. A null detector (galvanometer) is attached between the terminal $B$ and the jockey at $D$. A variable resistance box, $R$, with fractional resistances is placed in the outer gap at $UU^{\prime}$. The unknown (low) resistance, $S$, which is to be determined, is put in the
outer gap at $XX^{\prime}$. A battery, a key, and a resistance box (if necessary) are connected between the terminals $A$ and $C$. A one metre long wire $MN$ of uniform resistance per unit length is mounted alongside a metre rod, and is soldered to the two ends of the copper strip. Since the jockey can be slid along the wire $MN$, the point $D$ can be anywhere between $M$ and $N$. It represents the position at which the null detector would register a value of 0. To locate this point, we tap the jockey over the wire.

The wire, $MN$, is uniform and therefore, we may assume that it has a constant resistance per unit length, say, $r$ $\Omega$cm$^{-1}$. When the point $D$, located at some distance, $l_1$, from the end $M$ is chosen such that the null detector displays $0$, from the condition of a balanced Wheatstone bridge, we have, for the Carey Foster bridge
\begin{equation}
\frac{P}{Q}=\frac{R+\delta_{1}+l_{1}r}{S+\delta_{2}+(100-l_{1})r}
\label{careyconfig1}
\end{equation}

Here, $\delta_{1}$ is the value of the resistance at the soldered junction, $M$, and $\delta_{2}$ is the value of the resistance at the junction $N$. These are end/contact resistances, which are unknown. Their presence would introduce an error in our measurement of $S$ if used the CF bridge directly as a Wheatstone bridge. So we would like to eliminate them. Notice that if we interchange $R$ and $S$ (the resistor $R$ is placed in gap $XX^{\prime}$, while the unknown resistance is now connected in gap $UU^{\prime}$), then, because $\delta_1$ and $\delta_2$ correspond to the same physical contacts, the balance equation becomes

\begin{equation}
\frac{P}{Q}=\frac{S+\delta_{1}+l_{2}r}{R+\delta_{2}+(100-l_{2})r}
\label{careyconfig2}
\end{equation}

Equations (\ref{careyconfig1}) and (\ref{careyconfig2}), together, yield the \textit{nice} (independent of end corrections) relation

\begin{equation}
S = R + (l_1-l_2)r
\label{CF}
\end{equation}

Clearly, by measuring $l_1$ and $l_2$ for an appropriate range of resistances, $R$, one can deduce the value of the unknown resistance, $S$ and also the resistance per unit length of the bridge wire.

\begin{question}
\paragraph{Question:} Can we exchange the position of battery and the galvanometer? Which is the preferred arrangement and why?
\paragraph{Question:} Why does the procedure involve interchanging $R$ and $S$?
\paragraph{Question:} Draw the equivalent Wheatstone Bridge.
\paragraph{Question:} How is the Carey Foster an improvement over a standard Wheatstone bridge?
\paragraph{Question:} What is the largest unknown resistance that can be measured using a Carey Foster bridge?
\paragraph{Question:} In the derivation of the Equation (\ref{CF}), we eliminated $\delta_1$ and $\delta_2$ in favour of a relationships between $R$ and $S$. We can also use the two preceding balance equations to eliminate R and S, yielding an equation for $\delta_1 - \delta_2$. Derive this, explain why it might be useful.
\end{question}

\section*{Experimental Setup}

\subsection*{Apparatus}

\begin{enumerate}
\item A low voltage DC power supply
\item A Carey Foster bridge
\item Two fixed standard resistances (1 or 2 $\Omega$)
\item A fractional resistance box
\item A one-way key
\item A thick copper strip
\item An unknown low resistance ($S$)
\item A null detector (galvanometer)
\item Connecting wires.
\end{enumerate}

\subsection*{Precautions}
\begin{itemize}
    \item Clean all contacts thoroughly including %the battery terminals
    the teeth of the alligator clips with sand paper.
    \item Make sure that enough wire is exposed while making connections, so that insulation does not come in between.
    \item Check each contact by tugging on the wire and ensuring that it does not loosen or come undone.
    \item Arrange the elements of the circuit, so that it resembles your circuit diagram.
    \item While making the circuit think in terms of loops, not in terms of terminals.
    \item Make sure there is a finite resistance in the circuit, \textit{before} the key is closed.
    \item Measure all balance lengths from the same side and on same scale.
\end{itemize}

\section*{Procedural Instructions}

\begin{imp}
Before starting observations, \textit{test} and \textit{debug} your circuit. Some common methods of debugging include checking the DC supply potential, checking continuity of your circuit using a multimeter. If there is no potential drop across a passive element, then check for continuity.
\end{imp}

\subsection*{Part A}

In this part, you will determine the apparent value of a small resistance.

\begin{enumerate}
    \item Make the connections as shown in the circuit diagram and connect the DC source. $S$ is the unknown resistance.
    \item Take out the zero resistance key from the resistance box ($R$) and note down the balance length ($l_1$). When determining the balance point, approach it from both sides and determine the range, if any, over which you get a null deflection.
    \item Change the resistance in the box and find the new balance length.
    \item Interchange the position of the unknown resistance and the resistance box and repeat steps 1 to 3 to determine $l_2$.
    \item Tabulate $l_1 + l_2$.
    \item Plot a graph between $R$ and $l_1 -l_2$.
    \item Use this graph to determine the the resistance per unit length of the wire, and the apparent value of the unknown resistance.
\end{enumerate}

\subsection*{Part B}

In this part, you will determine a small correction to the above value.
\begin{enumerate}
    \item Make the connections as shown in the circuit diagram and connect the DC source. ($S$ is a copper strip.)
    \item Take out the zero resistance plug from the resistance box ($R$) and note down the balance length ($l_1$). Approach the balance point from both sides, and if there is a range of readings corresponding to the null deflection, note the entire range.
    \begin{tip}
        To make sure you are indeed at the balance point, infinitesimally moving the jockey, \textit{on either side}, should correspond to a small but finite current value on the galvanometer.
    \end{tip}
    \item Vary the resistance in the resistance box and find the new balance length.
    \item Interchange the position of the copper strip and the resistance box and repeat steps 1 to 3 to determine $l_2$.
    \item Tabulate $l_1 + l_2$. This is connected to the formula for $\delta_1 - \delta_2$ that you derived earlier.
    \begin{question}
    \paragraph{Question:} Why have you been asked to tabulate $l_1 + l_2$ even though it is not used in the calculations?
    \end{question}
    \item Plot a graph between $R$ and $l_1 -l_2$ on the same graph sheet as the one on which you plotted the readings in part A.
    \item Examine the two lines carefully and check (i) whether they are parallel and (ii) what the apparent resistance of the copper strip is.
    \item The unknown resistance in part A is not equal to the intercept but the difference between the intercepts of the lines in parts A and B.

\end{enumerate}

\begin{question}
\paragraph{Question:} Why do the two lines -- from \textbf{Parts A} and \textbf{B} -- need to be parallel?
\paragraph{Question:} Explain the correction factor determined in \textbf{Part B}.
\paragraph{Question:} Why is the graph with the unknown resistance alone enough to determine both the resistance per unit length and the unknown resistance?
\end{question}

\section*{References}

% \begin{enumerate}
% \item B. L. Worsnop, and H. T. Flint, \textit{Advanced Practical Physics for Students}.
% \item Experiment 6, Measurement of Low Resistance using the Carey Foster Bridge, National Digital Repository (\textit{eGyanKosh})
% \end{enumerate}

\nocite{worsnop_advanced_1951}

\printbibliography[heading=none]

\newpage

\end{refsection}


\section{Pooling (max pooling, average pooling, subsampling)}


\section{~Governing equations} \label{chapt:eq}
\newcounters

\input{eqs/intro}
\input{eqs/prop}
\input{eqs/source}
\input{eqs/NL1}
\input{eqs/NL2}
\input{eqs/NL3}
\input{eqs/NL4}
\input{eqs/NLS}
\input{eqs/ST1}
\input{eqs/ST2}
\input{eqs/ST3}
\input{eqs/ST4}
\input{eqs/ST6}
\input{eqs/LN1}
\input{eqs/BT1}
\input{eqs/BT4}
\input{eqs/BT8}
\input{eqs/BT9}
\input{eqs/DB1}
\input{eqs/TR1}
\input{eqs/BS1}
\input{eqs/UOST}
\input{eqs/XXn}
\input{eqs/sourceice}
\input{eqs/ICE1}
\input{eqs/ICE2}
\input{eqs/ICE3}
\input{eqs/ICE4}
\input{eqs/ICE5}
\input{eqs/IS1}
\input{eqs/IS2}
\input{eqs/REF1}
\input{eqs/IG1}
\vspace{\baselineskip}
\input{eqs/airseaprocesses}
\input{eqs/FLD1}
\input{eqs/FLD2}
\vspace{\baselineskip}
\input{eqs/output}
\input{eqs/derived}

\bpage


\setlength{\abovedisplayskip}{2pt}
\setlength{\belowdisplayskip}{2pt}
\section{Hierarchical Models}
\label{sec:hierachical_modeling}
In the following we consider hierarchical models and when they are applicable.
We begin by presenting the idea of hiearchical data and modeling.
We then show the general structure of hierarchical models and end this section by introducing the most widely used subclass, hierarchical linear models.

\subsection{Hierarchical Data and Modeling}
Here we consider what makes data \emph{hierarchical} and how we can use this further component to model additional structure.

Hierarchical data is present if the data can be clustered on some level; e.g. children in schools, survey responses in different years in different states, or experiments in multiple labs.
From the examples we see that there must not be a clear \emph{hierarchy} defined on the data.
This is why some authors nowadays prefer the more general terms \emph{multi-level data} and \emph{multi-level model}, see for instance \citet{GelmanHill2007}.

We categorize hierarchical models by the number of levels they incorporate and their use of \emph{nested} or \emph{non-nested} data.
In this paper we consider two-level models for nested data and refer (again) to \citet{GelmanHill2007} and \citet{snijders1999} for a treatment of more general settings.

%In practice we can store hierarchical data very efficiently using normalized relational dataframes.
Let us continue with the first example of children in schools.
Assume we observe, say, test results, parental income and number of teachers per child per school.
Figure \ref{fig:relational_table} portrays how multi-level data in this case may be stored.
\begin{figure}[!ht]
\begin{center}
\begin{tabular}{l l l l}
child & result & income & school\\
\hline
1 & 10 & 500 & 1\\
2 & 9 & 450 & 1\\
3 & 12 & 520 & 2
\end{tabular}
\quad
\begin{tabular}{l l}
school & teacher\\
\hline
1 & 0.5\\
2 & 0.7
\end{tabular}
\end{center}
\caption{Two tables containing fictional hierarchical data. Left: Data on the \emph{child-level} (test results, parental income, school id). Right: Data on the \emph{school-level} (number of teachers per child).}
\label{fig:relational_table}
\end{figure}

\vspace{-10pt}
To introduce formal notation, assume we observe data on $i=1,\mydots,n$ individuals which are clustered among $j=1,\mydots,J$ groups.
Naturally we consider outcomes $y_i$ on the individual-level.
Following the idea of different relations for different levels, we write $x_i$ for covariates that vary by individual and $u_j$ for covariates that only vary by group.
We link the two by writing $j[i]$ for the index of the group to which individual $i$ belongs, i.e. the full set of covariates from individual $i$ is given by $(x_i, u_{j[i]})$.
How can we utilize this hierarchical structure?

The main idea of hierarchical modeling is to build (simple) models on different levels, where the outcomes are modeled on the individual-level and we connect the levels by modeling on all higher levels the parameters used in the previous level.
The level structure is given by the hierarchical structure of the data and we use features from level $\ell$ only in the modeling process of level $\ell$.

For a general two-level case we may write a model as
\begin{align}
  y_i \mid \theta_{j[i]} &\sim p(y_i \mid x_i, \theta_{j[i]}) \,,\tag{Individual Level}\\
  \theta_j \mid \phi &\sim p(\theta_j \mid u_j, \phi) \,,\tag{Group Level}\\
  \phi &\sim p(\phi \mid \zeta) \text{ with } \zeta \text{ fixed } \,, \tag{Prior}
\end{align}
where we suppress the dependence on $x_i$ and $u_j$.
On the individual-level the outcomes $y_i$ are modeled depending on the unit-level features $x_i$ and parameters $\theta_{j[i]}$.
As in a classical Bayesian model we continue by modeling the parameters $\theta_j$, however, in contrast to section 2 we do not assume a prior distribution but we explicitly model the parameter on the group-level using the group-level features $u_j$.
From a Bayesian point of view this can be seen as a generalization of prior modeling.
Despite this Bayesian interpretation, the first two equations define a proper non-Bayesian hierarchical model.
We will see that in the linear case these models are well known in the frequentist world as \emph{mixed effects models} or \emph{random coefficient models}.
To produce a Bayesian model we assign a prior distribution on all (hyper)parameters that are not explicitly modeled (here $\phi$).

\begin{figure}[!ht]
\begin{center}
\begin{tikzpicture}%
  [vertex/.style={circle,draw=black,fill=white, minimum size=1cm},
  node distance=2.5cm,
  >=latex,
  on grid]
  \node[vertex] (phi) {$\phi$};
  \node[vertex,right=of phi] (theta) {$\theta_{j[i]}$};
  \node[vertex,below right= 1cm and 2.5cm of theta] (y) {$y_i$};
  \node[rectangle, draw=black, minimum size=0.9cm,left= of phi] (zeta) {$\zeta$};
  \node[rectangle, draw=black, minimum size=0.9cm,above=2cm of y] (u) {$u_{j[i]}$};
  \node[rectangle, draw=black, minimum size=0.9cm, above right=1cm and 2.5cm of y] (x) {$x_i$};
  \draw[->]
    (phi) edge (theta)
    (theta) edge (y)
    (zeta) edge (phi)
    (u) edge (theta)
    (x) edge (y);
\end{tikzpicture}
\end{center}
\caption{A generic two-level Bayesian hierarchical model depicted as a directed acyclical graph modeling a single generic observation. Circled parameters denote random quantities while parameters contained in squares denote fixed quantities.}
\label{fig:general_sem}
\end{figure}

Figure \ref{fig:general_sem} illustrates the structure of modeling a generic observation $y_i$ using the general model from above.
In contrast, figure \ref{fig:group_sem} in the appendix illustrates the conditional dependence structure when modeling a generic observation $y(j)$ in group $j$.
We depict random quantities in circles and fixed quantities in squares.

How do we solve for the posterior in these models?
Owing to the hierarchical nature we can derive the joint posterior as $p(\phi, \theta \mid y) \propto p(y \mid \phi, \theta) p(\phi, \theta) = p(y \mid \theta) p(\theta \mid \phi) p(\phi)$ where we use that $y$ is independent of $\phi$ conditional on $\theta$ ---this can be seen immediatly from figure \ref{fig:general_sem}.
We note that all factors on the right-hand side are known, hence, we can directly apply the methods discussed in the previous section.

%Not only do these graphical representations help with understanding the structure of the model, but we will see that when solving for the posterior they give an immediate way to check which parameters are conditionally independent.

%\subsection{Solving for the Posterior}\label{sec:hierachical_solving}
%In this section we present the complexities of deriving the (marginal) posterior in hierarchical models by considering the steps necessary to fully solve an example model.
%We will not embark on this in as much detail as in the non-hierarchical case, as this should only provide an idea on how hierarchical models can be estimated.
%
%Say we observe $i=1,\mydots,n$ individuals which fall in $j=1,\mydots,J$ groups with groupsize $n_j$.
%Assume $y_i \mid \theta_{j[i]} \sim \normal{\theta_{j[i]}, \sigma^2}$ with known variance $\sigma^2$ and that $\theta_j \overset{\text{iid}}{\sim} \normal{\mu, \tau^2}$.
%Let us write $\bar{y}$ for the sample mean of all observations and $\bar{y}_j$ for the sample mean in group $j$.
%Then we get $\bar{y}_j \mid \theta_j \sim \normal{\theta_j, \sigma_j^2}$ with $\sigma_j^2 := \sigma^2 / n_j$.
%
%We can write the joint posterior as $p(\theta, \mu, \tau^2 \mid y) = p(\theta \mid \mu, \tau^2, y) p(\mu \mid \tau^2, y) p(\tau^2 \mid y)$.
%In fact, even for this simple setup the posterior has no known form, so we have to return to sampling methods.
%Say we are able to derive the factored distributions (on the right side) to the extent that we are able to draw samples, via e.g. the Metropolis-Hastings algorithm.
%In this case we can use the topological structure of the conditional dependencies in the model to apply \emph{forward sampling}, that is, first draw $\tau^0 \sim p(\tau^2 \mid y)$, then draw $\mu^0 \sim p(\mu \mid \tau^2=\tau^0, y)$ and at last draw $\theta^0 \sim p(\theta \mid \mu=\mu^0, \tau^2=\tau^0, y)$, which concludes one draw from the posterior (see figure \ref{fig:example_model} in the appendix).
%In more complex settings we might be unable to derive the densities with the appropriate conditioning set for forward sampling ---In these cases one can often apply \emph{Gibbs sampling} (see \citet{geman1984}) or if needed \emph{Metropolis-within-Gibbs sampling} (see \citet{gilks1995}).
%We conclude this section by providing a result stating that the joint posterior and its factors are all proper given that we assume a flat prior for $p(\mu \mid \tau^2)$.
%
%\begin{proposition}\label{prop:hierarchical_posterior}
%    Under the above setup, and the additional assumption that $p(\mu \mid \tau^2) \propto 1$ and $p(\tau^2)$ is a proper probability distribution, we get
%    \begin{center}
%      \begin{enumerate}[i.)]
%        \item $p(\theta \mid \mu, \tau^2, y) =  \prod_j p(\theta_j \mid \mu, \tau^2, y)$, with $\theta_j \mid \mu, \tau^2, y \sim \normal{\mu_j, \tau_j^2}$
%        \item $\mu \mid \tau^2, y \sim \normal{\bar{\mu}, \sigma_\mu^2}$
%        \item $p(\tau \mid y)$ is proper,
%      \end{enumerate}
%    \end{center}
%    where $\sigma_\mu^{-2} = \sum_j \frac{1}{\sigma_j^2 + \tau^2}\,,\,\, \tau_j^{-2}=\frac{1}{\sigma_j^2} + \frac{1}{\tau^2}\,,\,\, \mu_j=\tau_j^2(\frac{1}{\sigma_j^2} \bar{y}_j + \frac{1}{\tau^2}\mu)$ and $\bar{\mu} = \tau_j^2 \sum_j \frac{1}{\sigma_j^2 + \tau^2} \bar{y}_j$.
%\end{proposition}
%\textcolor{red}{\hrule}
%\begin{proof}
%See appendix.
%\end{proof}
%\textcolor{red}{\hrule}
%
%We refrain from a similar analysis of the results as was done before in the non-hierarchical case and only recommend the interested reader to perform one themself as an understanding of analytical Bayesian results can be especially rewarding.
%To end this section we remark that in this model we have to apply sampling methods as well; however, if we find a way to sample exactly from $p(\tau \mid y)$ we will be able to draw exact samples from the posterior.
%This is of course more accurate than using the MCMC methods introduced above.
%Unfortunately in more complex models this is not possible in the general case.

\subsection{Hierarchical Linear Models}
We end our segment on theory with the introduction of hierachical linear models, the class of models we will be using exclusively in our Monte Carlo and application part.

As in classical statistics, linear models are usually simpler to estimate and easier to interpret, which can explain their widespread use in practice.
Standard critiques on linear models, e.g. model misspecification issues, also apply here, however, we will see that due to the hiearchical nature we are able to model complex structure, even under a linearity assumption.
Being more precise, linearity in a hierarchical context means that on each level parameters enter the \emph{level-model} linearly.
Let us formalize this.

\paragraph{General Definition.}
As before, we consider outcomes $y_i$ for individuals $i=1,\mydots,n$ in groups $j=1,\mydots,J$, with individual-level characteristics $x_i$ and group-level characteristics $u_{j[i]}$.
A general two-level hierarchical linear model can then be written as
\begin{align}
  y_i &= \alpha_{j[i]} + x_i^{\intercal} \beta_{j[i]} + \epsilon_i \,, \tag{Individual Level}\\
  \beta_j &= \gamma_0 + u_j^{\intercal} \gamma + \eta_j \, \tag{Group Level},
\end{align}
where $\epsilon_i$ and $\eta_j$ denote error terms on the respective level.
Commonly the group-level errors are modeled as independent and identical, and the individual-level errors are modeled as independent and identical in their respective group.
Note that this can be extended for the heteroscedastic or autocorrelated case.
Just like in the previous section, this model does not define a Bayesian model per se.
We make the model Bayesian by imposing a prior distribution on all paramters that are not explicitly modeled themself.
In the above case this would be $\gamma_0, \gamma, \epsilon$ and $\eta$.

%\paragraph{Varying Slopes Model with one Predictor in each Level.}
%To finish this section we will showcase the \emph{varying slopes model}, on which we rely heavily in the monte carlo study and which is closely related to the model considered in the application part.
%In particular we consider the case where each level features one regressor.
%Written formally we have
%\begin{align}
%  y_i = \alpha + \beta_{j[i]} x_i + \epsilon_i \,,
%\end{align}
%for the individual level, with $\epsilon_i \overset{\text{iid}}{\sim} \normal{0, \sigma_\epsilon^2}$.
%And for the group-level we get
%\begin{align}
%  \beta_j &= \gamma_0 + \gamma_1 u_j + \eta_j \,,
%\end{align}
%with $\eta_j \overset{\text{iid}}{\sim} \normal{0, \sigma_\eta^2}$.
%In a classicist interpretation we would call $\gamma_0$ and  $\gamma_1$ the \emph{fixed effects} as they do not vary group and the $\eta_j's$ the \emph{random effects} as they do vary by group.
%As \citet{GelmanHill2007} note, in a Bayesian interpretation this nomenclature is unfortunate as everything in a Bayesian setting is assumed to be random.
%
%Were we to let $\alpha$ vary by group and instead fix $\beta$ we would get a \emph{varying intercept model} as will be used in the application part.
%A justified question is if these comparably simple models have any sensible application.
%Using the example from \citet{GelmanHill2007}, consider modeling $J$ different experiments where in each experiment the baseline conditions were the same.
%In this setting we would like to measure the effect of some treatment (with treatment status $T_i$) on some outcome $y_i$.
%In this case we could model the outcomes as $y_i \mid \theta_{j[i]} \sim \normal{\alpha + \theta_{j[i]} T_i, \sigma^2}$,
%that is as a varying slopes model.
%Similar examples can be found to justify the use of varying intercept models.
%In a real application we usually combine varying intercept and varying slope models; however,
%this does not mean that every parameter must vary by group.
%Domain level knowledge can be used to guide the probabilistic modeler in choosing which parameters should vary and how many levels should be build.


\XtoCBlock{AdaptivePT1}
\label{block:AdaptivePT1}
\begin{figure}[H]\includegraphics{AdaptivePT1}\end{figure}

\begin{XtoCtabular}{Inports}
In & Input In(k)\tabularnewline
\hline
fc & Cutoff frequency\tabularnewline
\hline
\end{XtoCtabular}

\begin{XtoCtabular}{Outports}
Out & Output Out(k)\tabularnewline
\hline
\end{XtoCtabular}

\begin{XtoCtabular}{Mask Parameters}
V & Gain\tabularnewline
\hline
fmax & Maximum frequency [Hz]

(not used in floating point implementations)\tabularnewline
\hline
ts\_fact & Multiplication factor of base sampling time (in integer format)\tabularnewline
\hline
method & Discretization method\tabularnewline
\hline
\end{XtoCtabular}

\subsubsection*{Description:}
First order low pass with adaptive cut off frequency:

    G(s) = V/(s/(2*pi*fc) + 1)

% include optional documentation file
\InputIfFileExists{\XcHomePath/Library/Control/Doc/AdaptivePT1_Info.tex}{\vspace{1ex}}{}

\subsubsection*{Implementations:}
\begin{tabular}{l l}
\textbf{FiP8} & 8 Bit Fixed Point Implementation\tabularnewline
\textbf{FiP16} & 16 Bit Fixed Point Implementation\tabularnewline
\textbf{FiP32} & 32 Bit Fixed Point Implementation\tabularnewline
\textbf{Float32} & 32 Bit Floating Point Implementation\tabularnewline
\textbf{Float64} & 64 Bit Floating Point Implementation\tabularnewline
\end{tabular}

\XtoCImplementation{FiP8}
\index{Block ID!3408}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP8 \tabularnewline
\textbf{ID} & 3408 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & AdaptivePT1\_FiP8.c \tabularnewline
\textbf{H filename} & AdaptivePT1\_FiP8.h \tabularnewline
\end{tabular}
\vspace{1ex}

8 Bit Fixed Point Implementation

\begin{XtoCtabular}{Controller Parameters}
w\_scale & Calculation base for wc: -2*pi*Ts*fmax\tabularnewline
\hline
gain & Gain\tabularnewline
\hline
sfr & Shift factor for gain\tabularnewline
\hline
in\_old & In(k-1)\tabularnewline
\hline
\end{XtoCtabular}

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int8          *In;
     int8          *fc;
     int8          Out;
     int8          w_scale;
     int8          gain;
     uint8         sfr;
     int8          in_old;
} ADAPTIVEPT1_FIP8;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Control/Doc/Test_AdaptivePT1_FiP8.tex}{}{}
\fi
\XtoCImplementation{FiP16}
\index{Block ID!3409}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP16 \tabularnewline
\textbf{ID} & 3409 \tabularnewline
\textbf{Revision} & 1 \tabularnewline
\textbf{C filename} & AdaptivePT1\_FiP16.c \tabularnewline
\textbf{H filename} & AdaptivePT1\_FiP16.h \tabularnewline
\end{tabular}
\vspace{1ex}

16 Bit Fixed Point Implementation

\begin{XtoCtabular}{Controller Parameters}
w\_scale & Calculation base for wc: -2*pi*Ts*fmax\tabularnewline
\hline
gain & Gain\tabularnewline
\hline
sfr & Shift factor for gain\tabularnewline
\hline
in\_old & In(k-1)\tabularnewline
\hline
\end{XtoCtabular}

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int16         *In;
     int16         *fc;
     int16         Out;
     int16         w_scale;
     int16         gain;
     uint8         sfr;
     int16         in_old;
} ADAPTIVEPT1_FIP16;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Control/Doc/Test_AdaptivePT1_FiP16.tex}{}{}
\fi
\XtoCImplementation{FiP32}
\index{Block ID!3410}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & FiP32 \tabularnewline
\textbf{ID} & 3410 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & AdaptivePT1\_FiP32.c \tabularnewline
\textbf{H filename} & AdaptivePT1\_FiP32.h \tabularnewline
\end{tabular}
\vspace{1ex}

32 Bit Fixed Point Implementation

\begin{XtoCtabular}{Controller Parameters}
w\_scale & Calculation base for wc: -2*pi*Ts*fmax\tabularnewline
\hline
gain & Gain\tabularnewline
\hline
sfr & Shift factor forgain\tabularnewline
\hline
in\_old & In(k-1)\tabularnewline
\hline
\end{XtoCtabular}

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     int32         *In;
     int32         *fc;
     int32         Out;
     int32         w_scale;
     int32         gain;
     uint8         sfr;
     int32         in_old;
} ADAPTIVEPT1_FIP32;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Control/Doc/Test_AdaptivePT1_FiP32.tex}{}{}
\fi
\XtoCImplementation{Float32}
\index{Block ID!3411}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & Float32 \tabularnewline
\textbf{ID} & 3411 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & AdaptivePT1\_Float32.c \tabularnewline
\textbf{H filename} & AdaptivePT1\_Float32.h \tabularnewline
\end{tabular}
\vspace{1ex}

32 Bit Floating Point Implementation

\begin{XtoCtabular}{Controller Parameters}
w\_scale & Calculation base for wc: -2*pi*Ts*fmax\tabularnewline
\hline
gain & Gain\tabularnewline
\hline
in\_old & In(k-1)\tabularnewline
\hline
\end{XtoCtabular}

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     float32       *In;
     float32       *fc;
     float32       Out;
     float32       w_scale;
     float32       gain;
     float32       in_old;
} ADAPTIVEPT1_FLOAT32;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Control/Doc/Test_AdaptivePT1_Float32.tex}{}{}
\fi
\XtoCImplementation{Float64}
\index{Block ID!3412}
\nopagebreak[0]
% Implementation details
\begin{tabular}{l l}
\textbf{Name} & Float64 \tabularnewline
\textbf{ID} & 3412 \tabularnewline
\textbf{Revision} & 0.1 \tabularnewline
\textbf{C filename} & AdaptivePT1\_Float64.c \tabularnewline
\textbf{H filename} & AdaptivePT1\_Float64.h \tabularnewline
\end{tabular}
\vspace{1ex}

64 Bit Floating Point Implementation

\begin{XtoCtabular}{Controller Parameters}
w\_scale & Calculation base for wc: -2*pi*Ts*fmax\tabularnewline
\hline
gain & Gain\tabularnewline
\hline
in\_old & In(k-1)\tabularnewline
\hline
\end{XtoCtabular}

% Implementation data structure
\XtoCDataStruct{Data Structure:}
\begin{lstlisting}
typedef struct {
     uint16        ID;
     float64       *In;
     float64       *fc;
     float64       Out;
     float64       w_scale;
     float64       gain;
     float64       in_old;
} ADAPTIVEPT1_FLOAT64;
\end{lstlisting}

\ifdefined \AddTestReports
\InputIfFileExists{\XcHomePath/Library/Control/Doc/Test_AdaptivePT1_Float64.tex}{}{}
\fi


    \filetitle{detrend}{Remove a linear time trend}{tseries/detrend}

	\paragraph{Syntax}\label{syntax}

\begin{verbatim}
X = detrend(X)
X = detrend(X,Range)
\end{verbatim}

\paragraph{Input arguments}\label{input-arguments}

\begin{itemize}
\item
  \texttt{X} {[} tseries {]} - Input time series.
\item
  \texttt{Range} {[} numeric \textbar{} \texttt{Inf} {]} - The date
  range on which the trend will be computed; \texttt{Inf} means the
  entire range available will be used.
\end{itemize}

\paragraph{Output arguments}\label{output-arguments}

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  \texttt{x} {[} tseries {]} - Output time series with a trend removed.
\end{itemize}

\paragraph{Options}\label{options}

See \href{tseries/trend}{\texttt{tseries/trend}} for options available.

\paragraph{Description}\label{description}

\paragraph{Example}\label{example}


\section{Optimization of the experiment}

Optimal measurement conditions are one of the requirements for high-quality
scientific results.
Many adjustable parameters can influence the measurement quality, and their
optimal values highly depend on the samples under investigation.
The further analysis focuses on optimizing measurement parameters of nucleic
acids using 244 and 257\,nm excitation wavelengths.
PolyU was chosen as the sample for these experiments because uracil is known to
be the most susceptible base for photodecomposition, and our further
experiments were conducted on oligo and polynucleotides, and thus polyU is a
better model molecule than, for example, mononucleotide UMP.
The main parameters which needed to be determined were excitation laser power,
length of accumulation, sample volume, and concentration.
Moreover, the optimal sample rotation speed needed to be found for the
experiments using the spinning cell.

Quality of Raman measurement in dependence on excitation laser power length,
sample concentration, sample volume and rotation speed was quantified by means
of sample lifetimes.
The analysis was performed on the polyU integral intensity represented by
its band at 1231\,\icm{} compared to the intensity of the cacodylate band at
607\,\icm{} to account for the excitation laser power and sample adjustment
variations during the measurement.
The intensity was estimated both from raw spectra and spectra with subtracted
background.

\Figref{power_optim:triplexes_pU}
clearly shows that the polyU band in raw spectrum also contains a shoulder at
1248\,\icm{}, and is overlapping with the cacodylate band at 1276\,\icm.
Therefore, the band was modeled by the shape function
(\eqnref{band_intensities:shape})
with three components, but its intensity was calculated as a sum of the pulyU
bands without the cacodylate one.
The cacodylate band was modeled as having two components, at 607 and 640\,\icm,
but only the first one was used for the integral intensity calculation.

\begin{figure}
	\centering
	\input{results_and_discussion/assets/power_optimization_triplexes/%
		power_optimization_triplexes_pU}
	\caption[%
		Example UV RR spectrum of polyU dissolved in cacodylate buffer.%
	]{%
		\captiontitle{%
			Example UV RR spectrum of polyU dissolved in cacodylate buffer.%
		}
		The fits of shape functions
		(\eqnref{band_intensities:shape})
		to the bands of polyU and cacodylate used in intensity estimation fit are
		marked by green, and red lines, respectively, and the areas used for
		intensity calculation are filled with the corresponding colors.
	}
	\label{\figlabel{power_optim:triplexes_pU}}
\end{figure}

The time dependence of the intensity of polyU band at 1231\,\icm{} (normalized
to the intensity of cacodylate band at 607\,\icm) was modeled by the
exponential decay curve
\begin{equation}
	I = I_0 \text{e}^{-\lambda t} + b,
	\label{\eqnlabel{power_optim:decay}}
\end{equation}
where $I_0$ is initial intensity, $\lambda$ is the decay constant, and $b$ is
the baseline constant.
The normalized results (subtracted by $b$) can be seen in
\figref{power_optim:triplexes}.

\begin{figure}
	\centering
	\input{results_and_discussion/assets/power_optimization_triplexes/%
		power_optimization_triplexes}
	\caption[%
		Decrease of the integral intensity of polyU band at 1231\,\icm{} for
		different excitation laser powers in raw spectra.%
	]{%
		\captiontitle{%
			Decrease of the integral intensity of polyU band at 1231\,\icm{} for
			different excitation laser powers in raw spectra.%
		}
		It was normalized to the integral intensity of the cacodylate band at
		607\,\icm{}, which was used as the internal intensity standard.
		The values were fitted by exponential decay curves
		\eqnref{power_optim:decay}
		and the baseline constant $b$ from the fit was subtracted from the plots.
	}
	\label{\figlabel{power_optim:triplexes}}
\end{figure}

The lifetimes $\tau$ can be calculated from decay constants $\lambda$ from
\eqnref{power_optim:decay}
\begin{equation}
	\tau = \frac{1}{\lambda}.
	\label{\eqnlabel{power_optim:lifetime}}
\end{equation}
We can also calculate total accumulated relative energy from the decay curve
by
\begin{equation*}
	E_{0,\text{r}}
		= \int_0^{\infty}{I_0 \text{e}^{-\lambda t}\text{d}t}
		= \frac{I_0}{\lambda}
\end{equation*}
and energy accumulated from time $T_0$ by
\begin{equation*}
	E_r	= \int_{T_0}^{\infty}{I_0 \text{e}^{-\lambda t}\text{d}t}
		= \frac{I_0}{\lambda} \text{e}^{-\lambda T_0}.
\end{equation*}
Energy fractions can then be calculated by dividing the relative energies by
the maximal total relative energy. The resulting lifetimes, total accumulated
energy fractions $E_0$, and energy fractions $E$ accumulated from time
$T = 60\pm20$\,s, which was regarded as reasonable approximate for the time
needed for adjustment of the sample before measurement could start.

Further investigation of the spectral decay behavior shows that this simple
approach does not reveal that a single decay curve cannot model such a complex
system.
This effect is clearly visible if we subtract the cacodylate buffer background
from the spectra.
The resulting spectrum can be seen in
\figref{power_optim:triplexes2_pU}.

\begin{figure}
	\centering
	\input{results_and_discussion/assets/power_optimization_triplexes2/%
		power_optimization_triplexes2_pU}
	\caption[%
		Example UV RR spectrum of polyU dissolved in cacodylate buffer with
	  the cacodylate buffer background subtracted.%
	]{%
		\captiontitle{%
			Example UV RR spectrum of polyU dissolved in cacodylate buffer with
			the cacodylate buffer background subtracted.%
		}
		The fit of shape function
		(\eqnref{band_intensities:shape})
		to the band of polyU used in intensity estimation fit is marked by a green
		line together with the area used for the intensity calculation.
	}
	\label{\figlabel{power_optim:triplexes2_pU}}
\end{figure}

The polyU band at 1230\,\icm{} can then be modeled directly without the
interference of the cacodylate band at 1276\,\icm{}.
It can be seen from the polyU band intensity dependence plot in
\figref{power_optim:triplexes2}
that the background subtraction process slightly obscures the intensity
normalization so that the fast decay curves cannot be modeled here.
However, we can also see a slower decay trend which is not evident from the fit
to the intensities of the polyU band calculated from the spectra without
subtracted background.
This is caused by the fact that it is harder to reliably decouple
the contribution of the overlapping polyU and cacodylate bands with the
lowering polyU band intensity.

\begin{figure}
	\centering
	\input{results_and_discussion/assets/power_optimization_triplexes2/%
		power_optimization_triplexes2}
	\caption[%
		Decrease of the integral intensity of the polyU band at 1231\,\icm{}
		for different excitation powers in background-corrected spectra.%
	]{%
		\captiontitle{%
			Decrease of the integral intensity of the polyU band at 1231\,\icm{}
			for different excitation powers in background-corrected spectra.%
		}
		The intensity was normalized to the subtracted spectrum of cacodylate
		buffer, which was used as the internal intensity standard.
		The values were fitted by exponential decay curves
		\eqnref{power_optim:decay}.
		The baseline constant $b$ from the fit was subtracted from the plots.
	}
	\label{\figlabel{power_optim:triplexes2}}
\end{figure}

We can see that the system is complex, and our current methods cannot correctly
analyze the underlying processes.
Photoproducts can influence the resulting spectra, and therefore we
decided to use relatively lower excitation powers like 1\,mW or 0.5\,mW even
though the higher excitation power could probably give higher quality spectra.

Next conclusion was that the lifetime seemed to depend almost linearly on
the concentration, proportional to the number of nucleotides in the sample.
This means that in our experimental configuration, all the
excitation laser energy is absorbed in the sample for investigated, and
the number of photodecomposed molecules is proportional to the absorbed
energy in this concentration range.
Only in the samples with extremely low concentrations, all laser power is not
absorbed, and therefore the lifetime is longer.

It also implies that the excitation laser power density does not significantly
influence the photodecomposition process in the used range of the laser powers.

This analysis means that samples can endure longer measurements on higher
concentrations.
On the other hand, higher concentrations are also less cost-effective because
they require larger amounts of samples and it is harder to adjust focus for
them.
The spectra are also more influenced by the signal of the sample cell
because the laser beam needs to be focused closer to the cell wall and floor.
1000\,\g{m}M concentration was the highest practical value; higher
concentrations had excessive absorbance and were hard to set up for the
measurement.
It can also be beneficial for some measurements to measure samples with the
same concentration as in UV absorption measurements so that these two can
complement each other under the same measurement conditions.
Therefore the lower concentrations than 1\,mM were usually chosen in this
study.

The results of sample volume optimization supported the hypothesis that the
sample photodecomposition is inversely proportional to the number of
illuminated molecules with sufficient stirring.
We, therefore, tried to use fully-filled cuvettes by samples (3\,mL in the case
of the thermostated sample cell and 150\,\g{m}L for the spinning cell).

Also, a fast rotation seemed better than the slower rotation with a
stronger signal and no impact on the sample lifetime.
Therefore we decided to use the maximal rotation speed in all the experiments
which used the spinning sample cell.

Lastly, also length of accumulation was optimized.
A Raman spectrum is usually acquired as a consecutive series of spectra,
further called \emph{frames}, taken at the same experimental conditions and
with the constant accumulation time.
We decided to assess the SNR to estimate the quality of the measured spectra.
It was found that longer single-frame accumulation times give better quality
spectra in these experimental conditions.
The difference is larger in the low-frequency SNR even though the
high-frequency SNR difference is also significant.
Regarding the disadvantages of the
longer accumulation discussed in the thesis and the speed of
the sample degradation with lifetimes in the range of minutes, we decided that
the optimal accumulation time is 60\,s.

The spinning cell can be used not only for measurements in the right-angle
geometry, but also for measurements in the backscattering configuration.
We observed two sharp lines at 1555 and 2329\,\icm{} in these measurements
when very small sample volumes were used.
It can be seen, for example, in the spectrum of the samples extracted from alga
amphidinium in
\figref{artefact:artefact_amphidinium}.
50\,\g{m}l of sample was measured in the spinning cell in backscattering
geometry with 10\,mW of 257\,nm excitation laser.

\begin{figure}
	\centering
	\input{results_and_discussion/assets/artefact/%
		artefact_amphidinium}
	\caption[%
		Spectrum of extract from alga amphidinium in the spinning cell in
		backscattering geometry with 257\,nm excitation laser.%
	]{%
		\captiontitle{%
			Spectrum of extract from alga amphidinium in the spinning cell in
			backscattering geometry with 257\,nm excitation laser.%
		}
	}
	\label{\figlabel{artefact:artefact_amphidinium}}
\end{figure}

Further investigation and searching through the databases and atlases of
Raman spectra identified the cause of the spectra as molecules of gas \ch{O2}
at 1556\,\icm{} and \ch{N2} at 2330\,\icm{}.
It means that the signal is also gathered from the central cylinder of the air
inside the spinning cell resulting in the contribution of gas \ch{O2} and
\ch{N2} in the spectra.


\documentclass[12pt letterpaper]{article}

\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{amsmath}

\providecommand{\e}[1]{\ensuremath{\times 10^{#1}}}
\usepackage{gensymb}

\usepackage{float}

\title{Statistics In Counting Experiments}
\author{Johnny Minor \\ Partner: Kayla Mitchell}
\date{\today}

\begin{document}

\maketitle

%abstract should have a very brief overiew of the goals and main results of the experiment.
\begin{abstract}
In this experiment we study the nature of long-lived radioactive sources and their emission. We made 100 counts of the cosmic and background radiation with a scintillator. We then placed a provided radioactive source in from of the scintillation detector and made 100 counts. We also used a Geiger detector to make 100 counts of the period between two successive counts. We created normalized freqeuncy histograms for each experiment and fit a Poisson distribution, Gaussian distribution, and a Gaussian distribution with a calculated standard deviation. We found that in general for low counts the Poisson distribution fits well. For high counts neither Poisson or Gaussian fit our experimental data very well, but the Gaussian fit slightly better.
\end{abstract}

\newpage

\section*{Description of Experiment}

In this experiment we studied randomly occurring events. The event we studied was the emission from a long-lived radioactive source. In order to study this we used a scintillation counter. The active element within it is a 1 x 1 inch NaI crystal.

\begin{figure}[H]
  \caption{Schematic of a scintillation counter.}
  \centering
    \includegraphics[width=.5\textwidth]{scintillation.jpg}
    \label{fig:scintillator}
\end{figure}

For the small average counts we set the the voltage to be 1500 volts to get a frequency count with an average of around 2. In the second part we used the provided radioactive source and increased the voltage to 1900 volts to get an average frequency count of around 100. We recorded this data into Origin. After facing unrivaled technical difficulties using Origin for data analysis was forfeited in favor of different software.

In our third experiment we used a Geiger detector and a time interval counter set to 'period' mode. With this setting it counts the time passed between two detections. A cosmic ray should be detected about once a second using this method. We collected 100 points of data for this method. Once again logging our data in Microsoft Excel.

\begin{figure}[H]
  \caption{A schematic of a Geiger counter.}
  \centering
    \includegraphics[width=.5\textwidth]{geiger.png}
    \label{fig:geiger}
\end{figure}

In our fourth experiment we didn't have a divide-by-n circuit so we just summed pairs of intervals between subsequent pulses, as instructed in the handout. To get a new distribution.

In order to create our plots it was important to choose a bin width that allowed us to see a pattern. Too small a bin width would just make a frequency histogram with either 1 or 0(at least for the higher counts) because the probability of getting the same number between zero and 250 is small. Further, if we chose a bin width too large we wouldn't be able to see any distinguishing features because everything would just be jumbled together.

When we fit our data we first had to normalize our data. In order to do this we took our frequency and then divided by the total number of counts. In all cases we had 100 counts. This leads to the data summing to 1. Furthermore, as we found, the value for Poisson and Gaussian had to be multiplied by the bin width. This makes sense because we need our probability distribution to sum to one in order to make sense. Furthermore, it makes good sense because if we only had one point for an interval that was greater than one (or less than one).

\section*{Data and Analysis}

In order to see how good data is qualitatively we plotted either a Poisson distribution or a Gaussian distribution on top of our histogram. The Poisson distribution is
\begin{equation}
\label{eq:poisson}
P(x) = \frac{\mu^x e^{- \mu}}{x!}
\end{equation}

where $\mu$ is the average of the data set, and $x$ is the bin. As we have learned Poisson is a better distribution when our values are small, but greater than 0. So, we would expect it to be a better fit in the first experiment where the average is around 2, but a poor fit when the average count is around 100. When the average count is higher we would expect a Gaussian distribution to be a much better fit.

A Gaussian distribution is used when we have many independent events that occur. The equation for this distribution is
\begin{equation}
P(x) = \frac{1}{\sigma\sqrt{2\pi} } \; e^{ -\frac{(x-\mu)^2}{2\sigma^2} }
\end{equation}

where $\sigma$ is the variance, $\mu$ is the average, and $x$ is the bin. We know that the Gaussian distribution should be a better fit for numerous independent events.

\subsection*{Small Average Number of Counts}

\begin{figure}[H]
  \caption{A graph of our experimental data with corresponding Poisson distribution.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_1_1.png}
    \label{fig:section1.1.1}
\end{figure}

We can see in \ref{fig:section1.1.1} that our data follows the calculated Poisson distribution fairly well. We found the average to be 2.08 for our experiment with a standard deviation of 1.72. Our standard deviation is relatively close to the expected value with the Poisson distribution of 1.44.

\subsection*{Large Average Number of Counts}

\begin{figure}[H]
  \caption{A graph of our experimental data with corresponding Poisson distribution.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_1_2_poisson.png}
    \label{fig:section1.1.2poisson}
\end{figure}

\begin{figure}[H]
  \caption{A graph of our experimental data with corresponding Gaussian distribution.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_1_2_gaussian.png}
    \label{fig:section1.1.2gaussian}
\end{figure}

Here our data clearly does not fit very well with either a calculated Poisson or Gaussian. In this Gaussian calculation we used the mean of 86.88 and, as instructed, used the standard deviation as the square root of the mean. Which we calculated to be 9.32. It is also important to note that although the two graphs looks identical they are in fact not! The values are very slightly different. We believe this is due to the very poor fit of the Gaussian distribution because of the artificially poor standard deviation. When we calculate the true standard deviation we find it to be 47.93. This is much higher than the 9.32 and it clearly shows when we compare figure \ref{fig:section1.1.2gaussian} and \ref{fig:section1.1.2gaussianstddev}.

\begin{figure}[H]
  \caption{A graph of our experimental data with corresponding Gaussian distribution with calculated standard deviation.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_1_2_gaussian_std_dev.png}
    \label{fig:section1.1.2gaussianstddev}
\end{figure}

Although this fits better than what we found in figure \ref{fig:section1.1.2gaussian}, but it still does not inspire confidence. Clearly our data has too high a frequency from around 40 to 90. We believe that this could be due to selection bias of numbers, or simply that we don't have a higher enough number of counts. Perhaps our data would better resemble a Gaussian distribution if we had 1000 counts.

\subsection*{Distribution of Time Intervals Between Successive Counts}

\begin{figure}[H]
  \caption{A graph of our experimental data with Poisson distribution.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_2_1_poisson.png}
    \label{fig:section1.2.1poisson}
\end{figure}

In this experiment we plotted a Poisson distribution using our calculated mean of 1.45. The Poisson distribution doesn't seem to fit very well because our data seems to be too skewed to the left i.e. towards zero.

\begin{figure}[H]
  \caption{A graph of our experimental data with corresponding Gaussian distribution with calculated standard deviation.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_2_1_gaussian.png}
    \label{fig:section1.2.1gaussian}
\end{figure}

\begin{figure}[H]
  \caption{A graph of our experimental data with corresponding Gaussian distribution with calculated standard deviation.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_2_1_gaussian_std_dev.png}
    \label{fig:section1.2.1gaussianstddev}
\end{figure}

If we fit a Gaussian and also a Gaussian with our calculated standard deviation of 1.51 then we find that it still doesn't fit very well. This could be due to poor data that we collected. Perhaps the instrumentation was not that accurate, or we received more radiation than we had expected. Thus resulting in very short times between successive counts. We could also consider taking more data to get a better fit.

\subsection*{Distribution of Time Intervals Between Every Other Count}

\begin{figure}[H]
  \caption{A graph of our experimental data with corresponding Gaussian distribution with calculated standard deviation.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_2_2_poisson.png}
    \label{fig:section1.2.2poisson}
\end{figure}

As stated earlier we didn't have a divide-by-n circuit so we just summed two intervals together. This lead to these graphs. Which also don't fit very well.

\begin{figure}[H]
  \caption{A graph of our experimental data with corresponding Gaussian distribution with calculated standard deviation.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_2_2_gaussian.png}
    \label{fig:section1.2.2gaussian}
\end{figure}

In figure \ref{fig:section1.2.2poisson} we plotted a Poisson distribution with a calculated average of 2.89. This clearly does not fit well whatsoever.

\begin{figure}[H]
  \caption{A graph of our experimental data with corresponding Gaussian distribution with calculated standard deviation.}
  \centering
    \includegraphics[width=.75\textwidth]{section1_2_2_gaussian_std_dev.png}
    \label{fig:section1.2.2gaussianstddev}
\end{figure}

When we calculate the standard deviation we get 2.02. This is somewhat close to the square root of the average of 1.69. However, this still doesn't lead to a good fit of our data with either of the Gaussian distributions. It seems that there are just some bins that accrue a high probability that throws everything off. Clearly the data is poor and we could perhaps remedy this with a great amount of data.

\section*{Results and Conclusions}

In this experiment we found that the Poisson distribution does seem to fit well with our experimental data when the numbers are small. When the numbers are large the Poisson distribution is a poor fit, and so is the Gaussian distribution when using a the square root of the mean as the standard deviation. When we calculate the actual standard deviation then we get a much better fit of the data with a Gaussian distribution. However, it still does not fit that well, but it's definitely better.

In our experiment measuring the time intervals between counts we found that none of the distributions fit very well in both cases. The Poisson distribution seems to fit poorly, but somewhat close to the experimental data. The Gaussian doesn't fit whatsoever.

\subsection*{Additional Questions}

a. Okay, we won't allow the tube to operate in the continuous discharge region because that would destroy the tube! I don't think the Geiger detector we were using had an option to vary the voltage of the detector. We know that the Geiger detector works with a Geiger-M\"uller tube filled with inert gas that when the gas interacts with the ionizing radiation it creates a pulse that we can then detect.

\medskip
\noindent b. The Geiger counter is best at detecting ionizing radiation such as alpha particles, beta particles, and gamma rays. This is because of the Geiger-M\"uller tube that is central to the Geiger counter has an inert gas inside it that is very sensitive to the impinging radiation. The ionization of the gas paired with the Townsend avalanche phenomena leads to having a good detector.

\medskip
\noindent c. No, the Geiger detector cannot be used to measure the energy of incident radiation. This is because the radiation ionizes the gas and then the gas sends a pulse to to the apparatus. So no energy is measured directly. As Melissino's states: "The disadvantages of the Geiger counter are the loss of all information on the ionizing power of the charged particle that traversed the counter..."

\medskip
\noindent d. We could measure the dead time by using a pulse interval discriminator that triggers the oscilloscope only when the counter is in a fully recovered state. (from J L Putman and E H Cooke-Yarborough). We don't think you would need to take into account the dead time in this experiment because we don't need that level of resolution since we are measuring in seconds. Furthermore, we are counting the period between two successive counts.

\end{document}


\author{Bautrelle Fotso}
\graphicspath{ {./src/chapters/developer/media/}}

\chapter{Artificial Intelligence}
The aim of this part of the project is to build models, which will automatically recognize handwritten characters such as letters and numbers in exam
exercises. This contributes to a faster correction of exams and enables the teacher to be more efficient by saving time.
This task can not be possible without Artificial Intelligence (AI).
In the book \emph{``State-of-the-Art Approach to Artificial Intelligence``}, the autor
Soumyajit Goswani defines Artificial Intelligence as "(...) a computer system, which can accomplish responsibilities
that usually need human acumen."(\cite{[1]}, p.2).
This means, artificial intelligence can help to perform many activities like speech recognition, translation from one language to
another, image classification and more.
The application domain of AI matching with the objective of this project is the image classification based on machine learning.
Machine learning is a subset of AI that requires no human intervention to perform a task related to a given
input data from which it learned.(\cite{[1]}, p.2)
One of the main categories of machine learning is deep learning, used to recognize handwritings. \hfill \break

\section{Datasets}
Datasets are the basic elements in the building process of models.
For the recognition of characters some predefined images are required.
These images are all grouped as one to form a dataset.
Some datasets are already available on websites.
However, it can happen that the datasets found on internet do not match the requirements of a project.
In this case, a custom dataset is needed and must be created.
\noindent
Both types of datasets mentioned above have been used for this project and each of them is explained in the next section of this chapter.

\subsection{Ready-for-use datasets}
The ready-for-use datasets are kaggle A-Z and EMNIST datasets.
They are all available on the website \url{www.kaggle.com}(\cite{[2]}) and stored in a csv format.
Both datasets derives from a larger dataset known as the NIST special
database 19, which contains digits, uppercase and lowercase handwritten letters.
Each dataset has a training and a test set.
The training set is used to train a network to recognize characters.
The test set on the other hand is used after the training of the network to validate his recognition performance against new characters.
The EMNIST and the kaggle A-Z Datasets used in this project can be classified as follows:

\begin{itemize}
    \item Numerical datasets
    \item Alphabetical datasets
    \item Alpha-numerical datasets.
  \end{itemize}

\subsubsection{Numerical datasets}
Numerical datasets are used exclusively to recognize numbers.
This type of dataset provides balanced handwritten digits from 0 to 9.
"Balanced" means each class(from 0 to 9) contains the same number of images in the dataset.
In an example of exercise, the pupil is asked to count and write down the exact number of balls in a box.
The answer should be written in the space provided for this purpose.
This handwritten answer will be predicted by using a particular model, resulting from the training of a built network on the numerical dataset.
To realize this feature, two main datasets of this categorie have been used:
\begin{itemize}
    \item MNIST dataset
    \item EMNIST-digits dataset.
  \end{itemize}

\noindent
The MNIST dataset has fewer data than the EMNIST-digits dataset and is an excellent dataset to get started in
deep learning.
The MNIST dataset contains 60.000 images in its training set and 10.000 images make up its test set.
Each MNIST image has a size of 28x28 pixels and it can be resized according to the requirement of each project.
For this project the image was resized only for a verification purpose, because the size of 28x28 pixels was required. \hfill \break

\noindent
The fact that EMNIST-digits has more data, provides many possibilities
to perform predictions on a wide range of differently handwritten numbers.
It also consists of a training and test set with 240.000 and 40.000 images respectively. \hfill \break

\noindent
A sample of both are shown in figure(\ref{Abb:digits_sample})
\begin{figure}[htb]
	\centering
	\includegraphics[scale=0.4]{digits_dataset}
	\caption[Digits datasets]{MNIST and EMNIST Digits}\label{Abb:digits_sample}
\end{figure}

\subsubsection{Alphabetical dataset}
For the purpose of this project, two datasets were used for the recognition of letters namely the EMNIST-letters and kaggle A-Z datasets.
EMNIST-Letters helps to predict characters in a text which does not contain numbers.
It provides balanced handwritten letters in lower- and uppercase only.
The number of images in its training set and in its test set are 88.800 and 14.800 respectively. \hfill \break
\noindent
The picture (\ref{Abb:emnist_letters}) gives an example of the content of this dataset.

\begin{figure}[htb]
	\centering
	\includegraphics[scale=0.4]{emnist_letters}
	\caption[EMNIST-Letters datasets]{EMNIST-Letters dataset}\label{Abb:emnist_letters}
\end{figure}

The kaggle A-Z dataset has been released by the kaggle user Sachin Patel to an easy to read csv file.
It contains only uppercase letters rescaled to be images with 28x28 pixels.
It has a traning with 362.450 images and a test set with 10.000 images.
The goal of creating this dataset was to help beginners to do their first step in the deep learning.
It is also the reason why it was used at the beginning of this project.
But because it contains only uppercase letters, it was asumed that, in combination with other datasets,
the prediction results of texts with lower and upper case letters will be incorrect due to the randomization of these letters.
In this case, the target of this project could not be fulfilled and other datasets were chosen to move forward.

\subsubsection{Alpha-numerical datasets}
For a handwritten text containing both letters and digits, a recognition can be performed using the following datasets:

\begin{itemize}
    \item EMNIST-balanced dataset
    \item EMNIST-byMerge dataset.
  \end{itemize}

\noindent
The EMNIST-byMerge dataset has more data and an inconstant number of images per class compared to
EMNIST-balanced dataset.
The EMNIST-balanced is made up of 112.800 images in the training set and 18.800 images in the test set.
Likewise the EMNIST-byMerge contains 697.932 images in the training set and 116.323 images in the test set.
Both of them have 47 classes with some lowercase letters missing (for example: c/C, o/O, s/S).
The deletion of this letters avoids the confusion due to the similarity of theirs lower and upper case shapes.
This solves the classification issues while predicting.
\hfill \break

\noindent
The visual breakdown of these two datasets is illustrated in the figure(\ref{Abb:visual_breakdown}).

\begin{figure}[htb]
	\centering
	\includegraphics[width=0.7\textwidth]{visual_breakdown}
	\caption[Text datasets]{Visual breakdown of EMNIST-balanced and byMerge datasets(\cite{[2]})} \label{Abb:visual_breakdown}
\end{figure}

The deletion by both datasets is represented on this figure with a vertically directed arrow.

\noindent
Some example of images in these datasets are shown in the figure(\ref{Abb:balanced_and_byMerge}).

\begin{figure}[htb]
	\centering
	\includegraphics[scale=0.4]{demo_emnist_by_merge}
	\caption[Text datasets]{EMNIST-balanced and byMerge datasets}\label{Abb:balanced_and_byMerge}
\end{figure}

\newpage
\subsection{Own built dataset}
Despite the fact that, ready-for-use datasets provide a big choice of data, a custom dataset was created to fulfill the goal
of this project.
The name given to this dataset is \emph{SWTP-AI dataset}.
It contains diacritical letters, characters and some text ponctuations, written in form of a text paper with
fifteen(15) different handwritings.
Detailed steps on how this dataset was built will be explained in the chapter "training\_guide\_tesseract".
An example of the content of this dataset is in the picture (\ref{Abb:SWTP_KI_dataset}) below:

\begin{figure}[htb]
	\centering
	\includegraphics[width=0.7\textwidth]{swtp_ki_dataset}
	\caption[custom dataset]{SWTP-AI dataset}\label{Abb:SWTP_KI_dataset}
\end{figure}


\documentclass[11pt, sans]{amsart}
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ...
%\geometry{landscape}                % Activate for for rotated page geometry
%\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{color}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{comment}
\usepackage{float}
\usepackage{hyperref}
%\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

\input{def}

\title{Navier Stokes for Cavity flow}
\author{Panagiotis Tsilifis}
\address{Department of Civil Engineering, University of Southern California, Los Angeles, CA 90089}
\email{tsilifis@usc.edu}
%\date{}                                           % Activate to display a given date or no date

\begin{document}
\maketitle
%\section{}
%\subsection{}
\begin{abstract}
Source: {\color{blue}\url{http://nbviewer.jupyter.org/github/barbagroup/CFDPython/blob/master/lessons/15_Step_11.ipynb}}
\end{abstract}

\section{Equations}

The final two steps in this interactive module teaching beginning [CFD with Python] (https://bitbucket.org/cfdpython/cfd-python-class) will both solve the Navier-Stokes equations in two dimensions, but with different boundary conditions.
The momentum equation in vector form for a velocity field $\vec{v}$ is:,
\begin{equation}
\frac{\partial \vec{v}}{\partial t}+(\vec{v}\cdot\nabla)\vec{v}=-\frac{1}{\rho}\nabla p + \nu \nabla^2 \vec{v}.
\end{equation}
This represents three scalar equations, one for each velocity component $(u,v,w)$. But we will solve it in two dimensions, so there will be two scalar equations.
Remember the continuity equation? This is where the {\color{red}Poisson equation} for pressure comes in!

\subsection{Cavity flow in 2d}

Here is the system of differential equations: two equations for the velocity components $u,v$ and one equation for pressure:
\begin{equation}
\frac{ \partial u}{\partial t}+u\frac{\partial u}{\partial x}+v\frac{\partial u}{\partial y} = -\frac{1}{\rho}\frac{\partial p}{\partial x}+ \nu \left(\frac{\partial^2 u}{\partial x^2}+\frac{\partial^2 u}{\partial y^2} \right),
\end{equation}
\begin{equation}
\frac{\partial v}{\partial t}+u\frac{\partial v}{\partial x}+v\frac{\partial v}{\partial y} = -\frac{1}{\rho}\frac{\partial p}{\partial y}+\nu\left(\frac{\partial^2 v}{\partial x^2}+\frac{\partial^2 v}{\partial y^2}\right),
\end{equation}
\begin{equation}
\frac{\partial^2 p}{\partial x^2}+\frac{\partial^2 p}{\partial y^2} = -\rho\left(\frac{\partial u}{\partial x}\frac{\partial u}{\partial x}+2\frac{\partial u}{\partial y}\frac{\partial v}{\partial x}+\frac{\partial v}{\partial y}\frac{\partial v}{\partial y} \right).
\end{equation}
From the previous steps, we already know how to discretize all these terms. Only the last equation is a little unfamiliar. But with a little patience, it will not be hard!

\section{Discretization}

First, let's discretize the $u$-momentum equation, as follows:
\begin{eqnarray}
    &&\frac{u_{i,j}^{n+1}-u_{i,j}^{n}}{\Delta t}+u_{i,j}^{n}\frac{u_{i,j}^{n}-u_{i-1,j}^{n}}{\Delta x}+v_{i,j}^{n}\frac{u_{i,j}^{n}-u_{i,j-1}^{n}}{\Delta y}\\
    &&=-\frac{1}{\rho}\frac{p_{i+1,j}^{n}-p_{i-1,j}^{n}}{2\Delta x}+\nu\left(\frac{u_{i+1,j}^{n}-2u_{i,j}^{n}+u_{i-1,j}^{n}}{\Delta x^2}+\frac{u_{i,j+1}^{n}-2u_{i,j}^{n}+u_{i,j-1}^{n}}{\Delta y^2}\right).
\end{eqnarray}
Similarly for the $v$-momentum equation:
\begin{eqnarray}
    &&\frac{v_{i,j}^{n+1}-v_{i,j}^{n}}{\Delta t}+u_{i,j}^{n}\frac{v_{i,j}^{n}-v_{i-1,j}^{n}}{\Delta x}+v_{i,j}^{n}\frac{v_{i,j}^{n}-v_{i,j-1}^{n}}{\Delta y}\\
    &&=-\frac{1}{\rho}\frac{p_{i,j+1}^{n}-p_{i,j-1}^{n}}{2\Delta y}
    +\nu\left(\frac{v_{i+1,j}^{n}-2v_{i,j}^{n}+v_{i-1,j}^{n}}{\Delta x^2}+\frac{v_{i,j+1}^{n}-2v_{i,j}^{n}+v_{i,j-1}^{n}}{\Delta y^2}\right)
\end{eqnarray}
Finally, the discretized pressure-Poisson equation can be written thus:
\begin{eqnarray}
&&\frac{p_{i+1,j}^{n}-2p_{i,j}^{n}+p_{i-1,j}^{n}}{\Delta x^2}+\frac{p_{i,j+1}^{n}-2p_{i,j}^{n}+p_{i,j-1}^{n}}{\Delta y^2}
\\ &&=\rho\left[\frac{1}{\Delta t}\left(\frac{u_{i+1,j}-u_{i-1,j}}{2\Delta x}+\frac{v_{i,j+1}-v_{i,j-1}}{2\Delta y}\right)
\right.
\\ && -\frac{u_{i+1,j}-u_{i-1,j}}{2\Delta x} \frac{u_{i+1,j}-u_{i-1,j}}{2\Delta x}
    -  2\frac{u_{i,j+1}-u_{i,j-1}}{2\Delta y} \frac{v_{i+1,j}-v_{i-1,j}}{2\Delta x} \\
    &&- \left.\frac{v_{i,j+1}-v_{i,j-1}}{2\Delta y}\frac{v_{i,j+1}-v_{i,j-1}}{2\Delta y}
\right].
\end{eqnarray}

You should write these equations down on your own notes, by hand, following each term mentally as you write it.
As before, let's rearrange the equations in the way that the iterations need to proceed in the code. First, the momentum equations for the velocity at the next time step.

The momentum equation in the $u$ direction:
\begin{eqnarray}
&& u_{i,j}^{n+1} = u_{i,j}^{n} - u_{i,j}^{n}\frac{\Delta t}{\Delta x}(u_{i,j}^{n}-u_{i-1,j}^{n})
    - v_{i,j}^{n}\frac{\Delta t}{\Delta y}(u_{i,j}^{n}-u_{i,j-1}^{n})
    -\frac{\Delta t}{\rho 2\Delta x}(p_{i+1,j}^{n}-p_{i-1,j}^{n}) \\
    && +\nu\left(\frac{\Delta t}{\Delta x^2}(u_{i+1,j}^{n}-2u_{i,j}^{n}+u_{i-1,j}^{n})\right.
    +\left.\frac{\Delta t}{\Delta y^2}(u_{i,j+1}^{n}-2u_{i,j}^{n}+u_{i,j-1}^{n})\right).
\end{eqnarray}

The momentum equation in the $v$ direction:
\begin{eqnarray}
&& v_{i,j}^{n+1} = v_{i,j}^{n}-u_{i,j}^{n}\frac{\Delta t}{\Delta x}(v_{i,j}^{n}-v_{i-1,j}^{n})
    - v_{i,j}^{n}\frac{\Delta t}{\Delta y}(v_{i,j}^{n}-v_{i,j-1}^{n})-\frac{\Delta t}{\rho 2\Delta y}(p_{i,j+1}^{n}-p_{i,j-1}^{n}) \\
   && +\nu\left(\frac{\Delta t}{\Delta x^2}(v_{i+1,j}^{n}-2v_{i,j}^{n}+v_{i-1,j}^{n})\right.
    +\left.\frac{\Delta t}{\Delta y^2}(v_{i,j+1}^{n}-2v_{i,j}^{n}+v_{i,j-1}^{n})\right).
\end{eqnarray}

Almost there! Now, we rearrange the pressure-Poisson equation:
\begin{eqnarray}
&& p_{i,j}^{n}=\frac{(p_{i+1,j}^{n}+p_{i-1,j}^{n})\Delta y^2+(p_{i,j+1}^{n}+p_{i,j-1}^{n})\Delta x^2}{2(\Delta x^2+\Delta y^2)}-\frac{\rho\Delta x^2\Delta y^2}{2(\Delta x^2+\Delta y^2)} \times \\
&& \left[\frac{1}{\Delta t}\left(\frac{u_{i+1,j}-u_{i-1,j}}{2\Delta x}+\frac{v_{i,j+1}-v_{i,j-1}}{2\Delta y}\right)-\frac{u_{i+1,j}-u_{i-1,j}}{2\Delta x}\frac{u_{i+1,j}-u_{i-1,j}}{2\Delta x}\right. \\
&& -2\frac{u_{i,j+1}-u_{i,j-1}}{2\Delta y}\frac{v_{i+1,j}-v_{i-1,j}}{2\Delta x}-\left.\frac{v_{i,j+1}-v_{i,j-1}}{2\Delta y}\frac{v_{i,j+1}-v_{i,j-1}}{2\Delta y}\right]
\end{eqnarray}

\end{document}


\clearpage
\section{Updates: 03/31/2020}%
\label{sec:updates_2020_03_31}
\subsection{Periodicity}%
\label{subsec:periodicity}
\begin{itemize}
  \item When using the angular representation, \(x \equiv \phi_{\mu}(k) \in [0,
    2\pi)\) of the link variables \(U_{\mu}(k) = e^{i\phi_{\mu}(k)}\in U(1)\),
    it seems like the main problem (possibly in addition to issues with
    reversibility) is that the output is discontinuous when the input moves
    between \(0\), and \(2\pi -\varepsilon\) (\(\varepsilon \ll 1\)).
    % the network is \emph{not} gauge
    % periodic, i.e. \(f(x) \neq
    % f(x + 2\pi)\).
  % \item Because of this, taking
  %   \begin{equation}
  %     x \longrightarrow x \pmod{2\pi}
  %   \end{equation}
  %   % violates reversibility since information about \(x\) is lost.
  \item Additionally, the network itself is not periodic, i.e.\ if \(x
    \longrightarrow x + n\pi\), the \(x\odot \exp(\varepsilon
    S_{x}(\zeta_{1}))\) term in the \(x\)-update becomes
    \begin{equation}
      x\odot \exp(\varepsilon S_{x}(\zeta_{1})) \longrightarrow (x +
      n\pi)\odot\exp(\varepsilon S_{x}(\zeta_{1}))
    \end{equation}
    and we're left with an additional \(n\pi \odot \exp(\varepsilon
    S_{x}(\zeta_{1}))\) term.
  \item We can avoid this issue by using the \(\vec{x} \equiv
    \left[\cos\phi_{\mu}(k), \sin\phi_{\mu}(k)\right]\) representation as input
    to the network, which then updates the \(\cos\) and \(\sin\) terms
    separately.
\end{itemize}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PROBLEM 4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Problem 4}

Given UO$_2$ with $2.5 \times 10^{21}$ atoms/cm$^3$ of $^{235}$U and $2.0\times10^{22}$ atoms/cm$^3$ of $^{238}$U, find the partial densities of $^{235}$U, $^{238}$U, and O, and determine the enrichment.