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

\section{Nöther's theorem}

\marginpar{Monday\\ 2020-5-4, \\ compiled \\ \today}

We can relate symmetries and conserved quantities.

\begin{definition}
A \textbf{symmetry} of the theory is the transformation of the fields and/or of the spacetime coordinates such that the equations of motion do not change.
\end{definition}

This is equivalent to saying that the action is stationary for the transformed fields iff it is stationary for the untransformed ones.

The Lagrangian's symmetries are different from those of the EoM: for instance, we have shown that \(\mathscr{L} \to \mathscr{L} + \partial_{\mu } k^{\mu }\) preserves them, but the Lagrangian definitely changes.

Symmetries can be classified into \textbf{discrete} and \textbf{continuous} ones, depending on the group they correspond to.
A \emph{discrete} group is a group which is endowed with the discrete topology --- the one in which all the subsets are open.
A \emph{continuous} group, for what we will need, is a Lie group: one which is described as a differentiable manifold.

The discrete groups we use are usually finite, but they can be inifinite: for instance, translations by \(\SI{1}{m}\) along a certain axis are isomorphic to \(\mathbb{Z}\).
Continuous groups are always uncountably infinite, since at the very least they are described by one real parameter.
Here, we are interested in continuous symmetries, since Nöther's theorem applies to them.

We classify these based on two characteristics: first, we have the \textbf{global} versus \textbf{local} symmetries.
Local symmetries' parameters depend on the position in spacetime, global symmetries' parameters are constant.

\textbf{Spacetime} symmetries alter only the spacetime coordinates, \textbf{internal} symmetries alter the fields as well as the spacetime coordinates.

\begin{enumerate}
    \item Lorentz transformations \(x \to \Lambda x\) are global spacetime symmetries;
    \item general-relativistic diffeomorphisms \(x \to x'(x)\) are local spacetime symmetries;
    \item leptonic and hadronic number symmetries and flavour symmetry are global internal symmetries;
    \item gauge field symmetries like \(A_{\mu } \to A_{\mu } + \partial_{\mu } \Lambda \) are local internal symmetries.
\end{enumerate}

Nöther's theorem associates a conserved current and charge to every continuous symmetry of the action: the current is \(j^{\mu }_{(a)}\), where the index \(\mu \) is a spacetime one, while \((a)\) labels the generators of the group of symmetry. This current will be conserved:
%
\begin{align}
\partial_{\mu } j^{\mu }_{(a)} = 0
\,.
\end{align}

A charge can be associated with this current:
%
\begin{align}
Q_{(a)} = \int \dd[3]{x} j^{0}_{(a)}
\,.
\end{align}

This charge is conserved: \(\partial_{t} Q_{(a)} =0 \) (note that this is a partial derivative but it can also be written as a total one: the total charge only depends on time). This statement follows from the conservation \(\partial_{\mu } j^{\mu }_{(a)} =0 \): if we integrate this law over a cylinder, the product of an interval in time by a spatial sphere with diverging radius, we get
%
\begin{align}
\int \dd[4]{x} \partial_{\mu } j^{\mu }_{(a)} = \int \dd{t} \dd[3]{x} \qty(\partial_{0} j^{0}_{(a)} + \partial_{i}j^{i}_{(a)}) = Q_{(a)}(t _{\text{fin}}) - Q_{(a)} (t _{\text{in}})
\,,
\end{align}
%
since the integral of the divergence vanishes by the usual boundary conditions.

\subsection{Nöther's theorem for internal global symmetries}

An internal global symmetry leaves the spacetime coordinates unchanged, and changes the fields as
%
\begin{align}
\varphi \to \varphi + \delta_0 \varphi
\qquad \text{where} \qquad
\delta_0 \varphi = \epsilon^{(a)} X_{(a)}(\varphi )
\,.
\end{align}

Here \(\epsilon^{(a)}\) is a vector of small constant parameters, while \(X_{(a)}\) are the generators of the symmetry.
The index \(a\) runs from 1 to \(n\), the dimension of the symmetry group.

So, we can take the variation of the perturbed action \(\delta S[\varphi + \delta_0 \varphi ]\) and set it to zero. An important note, though: the variation of the action must be zero \emph{locally} as well as globally, so we can perform our integral in an arbitrary spacetime volume \(V\). We find:
%
\begin{subequations}
\begin{align}
\eval{\delta S [ \varphi + \delta_0 \varphi ]}_{V} &= \delta  \int_{V} \dd[4]{x} \mathscr{L} \qty(\varphi + \delta_0 \varphi , \partial_{\mu } \varphi + \partial_{\mu } \delta_0 \varphi  )  \\
&= \int_{V} \dd[4]{x} \pdv{\mathscr{L}}{\varphi } \delta_0 \varphi + \pdv{\mathscr{L}}{\partial_{\mu}\varphi } \qty(\partial_{\mu } \delta_0 \varphi )  \\
&= \int_{V} \dd[4]{x} \pdv{\mathscr{L}}{\varphi } \delta_0 \varphi - \partial_{\mu } \qty(\pdv{\mathscr{L}}{\partial_{\mu}\varphi } ) \delta_0 \varphi  + \partial_{\mu } \qty( \pdv{\mathscr{L}}{\partial_{\mu } \varphi } \delta_0 \varphi ) \marginnote{Integrated by parts.}
\,.
\end{align}
\end{subequations}

Unlike what we usually do when we derive the EL equations, we cannot neglect the boundary term: since we are integrating in an arbitrary volume, there is no reason why the variation of the field should vanish at the boundary (\(\eval{\delta_0 \varphi }_{\partial V} =0\)).

The terms which are multiplied by \(\delta_0 \varphi \) vanish by the regular Euler-Lagrange equations (which hold everywhere). Therefore, in order for the variation in the action to be zero, we must ask the extra term to vanish: this means
%
\begin{align}
\int_{V} \dd[4]{x} \partial_{\mu } \qty(\pdv{\mathscr{L}}{\partial_{\mu }\varphi } \delta_0 \varphi )
=\epsilon^{(a)} \int_{V} \dd[4]{x} \partial_{\mu } \qty( \pdv{\mathscr{L}}{\partial_{\mu } \varphi } X_{(a)} \varphi )
= 0
\,,
\end{align}
%
which must hold:
\begin{enumerate}
    \item for any region \(V\);
    \item for any choice of \(\epsilon^{(a)}\).
\end{enumerate}

Therefore, the only possibility is that
%
\begin{align}
\partial_{\mu  }\qty( \pdv{\mathscr{L}}{\partial_{\mu } \varphi } X_{(a)} (\varphi) ) = 0
\,,
\end{align}
%
for all choices of \(a\). This is a conservation equation just like the one we mentioned above: so, we define
%
\begin{align}
j^{\mu }_{(a)} = \pdv{\mathscr{L}}{\partial_{\mu } \varphi } X_{(a)} (\varphi)
\,
\end{align}
%
and we are done.
The conserved charges will look like
%
\begin{align}
Q_{(a)} = \int \dd[3]{x} j^{0}_{(a)} = \int \dd[3]{x} \pdv{\mathscr{L}}{\partial_{0} \varphi } X_{(a)} (\varphi )
\,.
\end{align}

\subsection{Nöther's theorem for spacetime global symmetries}

Let us consider a more general formulation of the theorem: the statement is the same, but we generalize it to a symmetry which acts both on the spacetime coordinates and on the fields.

The variations will be
%
\begin{subequations}
\begin{align}
\delta {x^{\mu }} &= \epsilon^{(a)} Y_{(a)}^{\mu }  \\
\delta \varphi &= \epsilon^{(a)} X_{(a)}(\varphi )
\,.
\end{align}
\end{subequations}

Here, \(X_{(a)}\) are the generators of the action of the group on \(\varphi \), while \(Y_{(a)}\) are the generators of its action on \(x^{\mu }\).

The variation is now \(\delta \) instead of \(\delta_0 \): it is not synchronous anymore. To be more explicit:
%
\begin{subequations}
\begin{align}
\delta \varphi &= \varphi' (x') - \varphi (x)  \\
&= \varphi ' (x') - \varphi (x') + \varphi (x') - \varphi (x)  \marginnote{Added and subtracted.}\\
&\approx  \delta_0 \varphi + (\partial_{\mu } \varphi ) \delta x^{\mu }
\,.
\end{align}
\end{subequations}

Here \(\varphi \) is a test field, but this reasoning holds for any function.

Note that, while the synchronous variation \(\delta_0\) commutes with \(\partial_{\mu }\), this is not the case for the total variation \(\delta \)! In fact, we have
%
\begin{align}
\qty[\partial_{\mu }, \delta ] \varphi = \qty(\partial_{\nu } \varphi ) \partial_{\mu } \delta x^{\nu }
\,.
\end{align}

Also, in general if we transform the coordinates we are also modifying the volume element:
%
\begin{align}
\dd[4]{x'} \approx \qty(1 + \partial_{\mu } \delta x^{\mu }) \dd[4]{x}
\,.
\end{align}

Therefore, we can write \(\delta \qty(\dd[4]{x}) = \partial_{\mu } \delta x^{\mu } \dd[4]{x}\).

\begin{proof}
This can be shown by using Liouville's formula \cite[eq. 4.9]{winitzkiLinearAlgebraExterior2010}:
%
\begin{align}
\det \exp(M) = \exp(\Tr M)
\,.
\end{align}

The variation of the volume element is given, in full generality, by
%
\begin{align}
\dd[4]{x'} = \abs{ \pdv{x'}{x}} \dd[4]{x}
\,,
\end{align}
%
where the Jacobian is given by:
%
\begin{align}
\pdv{x^{\prime \mu }}{x^{\nu }} = \delta^{\mu }_{\nu } + \partial_{\nu } \delta x^{\mu } \approx \exp( \partial_{\nu } \delta x^{\mu }) = \exp(M)
\,.
\end{align}

So, we can apply the formula to get:
%
\begin{subequations}
\begin{align}
\det \qty(\pdv{x^{\prime \mu }}{x^{\nu }}) &= \exp(\Tr M)
= \exp(\Tr(\partial_{\nu } \delta x^{\mu }))   \\
&= \exp( \partial_{\mu } \delta x^{\mu })  \\
&\approx 1 + \partial_{\mu } \delta x^{\mu }
\,,
\end{align}
\end{subequations}
%
which proves our claim. One plus a small value is positive, so there is no issue with the modulus.
\end{proof}

So, let us get to the computation: as before, we integrate in a spacetime region \(V\), and we find
%
\begin{subequations}
\begin{align}
\delta S &= \int_{V} \delta \qty(\dd[4]{x}) \mathscr{L} + \int \dd[4]{x} \delta \mathscr{L}  \\
&= \int_V \dd[4]{x} \qty{ \partial_{\mu } \delta x^{\mu } \mathscr{L} +
\delta_{0} \mathscr{L} + \qty(\partial_{\mu } \mathscr{L}) \delta x^{\mu}
}  \\
&= \int_V \dd[4]{x}  \partial_{\mu } \qty(\qty(\mathscr{L} \delta x^{\mu }) + \pdv{\mathscr{L}}{\partial_{\mu } \varphi } \delta_0  \varphi )
+ \text{LE} \times \delta_0 \varphi
\,,
\end{align}
\end{subequations}
%
where the reasoning for the \(\delta_0 \mathscr{L}\) part is the same as in the internal symmetry case; while the two new additional terms were combined into a single derivative.

As before, the Lagrange Equations vanish identically, and since we are integrating in a generic region \(V\) the rest of the integrand must be zero everything: so, we have found a conserved current!

It is, however, still written in terms of \(\delta_0 \), while the variation of the field is not the synchronous one: so, we substitute the expression for \(\delta_0 \varphi \) in terms of \(\delta \varphi \). This yields
%
\begin{subequations}
\begin{align}
\delta S &=
\int_{V} \dd[4]{x} \partial_{\mu } \qty(\mathscr{L} \delta x^{\mu } + \pdv{\mathscr{L}}{\partial_{\mu } \varphi } \qty(\delta \varphi - \partial_{\rho  } \varphi \delta x^{\rho })  )  \\
&= \int_{V} \dd[4]{x} \partial_{\mu } \qty[ \qty(\mathscr{L} \delta^{\mu }_{\rho } - \pdv{\mathscr{L}}{\partial_{\mu } \varphi } \partial_{\rho } \varphi ) \delta x^{\rho }+ \pdv{\mathscr{L}}{\partial_{\mu }\varphi } \delta \varphi ]  \\
&= \epsilon^{(a)}\int_{V} \dd[4]{x} \partial_{\mu } \qty[ \qty(\mathscr{L} \delta^{\mu }_{\rho } - \pdv{\mathscr{L}}{\partial_{\mu } \varphi } \partial_{\rho } \varphi ) Y^{\rho }_{(a)}+ \pdv{\mathscr{L}}{\partial_{\mu }\varphi } X_{(a)} ]
\,,
\end{align}
\end{subequations}
%
which, as before, must hold for any volume \(V\) and for any \(\epsilon^{(a)}\), therefore we get that the integrand must be conserved: our final result for the conserved current is
%
\begin{align}
j^{\mu }_{(a)} = \qty(\pdv{\mathscr{L}}{\partial_{\mu } \varphi } \partial_{\rho } \varphi  - \mathscr{L} \delta^{\mu }_{\rho } ) Y^{\rho }_{(a)}-  \pdv{\mathscr{L}}{\partial_{\mu }\varphi } X_{(a)}
\,,
\end{align}
%
where we changed the global sign; this is purely conventional, as any scalar multiple of the conserved current is also conserved.

\subsection{Application: Poincaré invariance} \label{sec:poincare-invariance-noether}

We want our theories to respect the principles of special relativity. So, the action must be a Lorentz scalar.
Poincaré transformations are the most general ones in SR, they consist in combinations of translations (4 generators), Lorentz boosts (3 generators) and Lorentz rotations (3 generators).

\subsubsection{Translations}

Translations shift the coordinates by constant amounts, and should not alter the fields.

We then have
%
\begin{subequations}
\begin{align}
\delta x^{\mu } &= \epsilon^{\mu } = \epsilon^{\nu } \delta^{\mu }_{\nu } = \epsilon^{(\nu)} Y^{\mu }_{(\nu )}  \\
\delta \varphi &= 0 = X
\,.
\end{align}
\end{subequations}

So, our conserved current reads
%
\begin{align}
j^{\mu } _{(\nu), \text{transl}} = \pdv{\mathscr{L}}{\partial_{\mu } \varphi } \partial_{\nu } \varphi  -  \mathscr{L} \delta^{\mu }_{(\nu )} \overset{\text{def}}{=} \widetilde{T}^{\mu }_{\nu }
\,,
\end{align}
%
which is called the canonical stress-energy-momentum tensor.
Note that this tensor is not generally symmetric as written, although there are procedures to make it so.

The components \(\widetilde{T}^{0}_{\nu }\) are called the \emph{momentum density} associated to the field; their integrals over 3-space are the components of the total momentum \(P^{\mu }\). They are
%
\begin{align}
P_{\mu } = \int \dd[3]{x} \widetilde{T}^{0}_{\mu } = \int \dd[3]{x} \qty(\pdv{\mathscr{L}}{\partial_{0} \varphi } \partial_{\mu } \varphi  - \mathscr{L} \delta^{0}_{\mu })
\,,
\end{align}
%
so the \(00\) component \(P_{0}\) is precisely the Hamiltonian, which is defined by the Legendre transform:
%
\begin{align}
H = \int \dd[3]{x} \pdv{\mathscr{L}}{\partial_{0} \varphi } \partial_{0} \varphi - \mathscr{L}
\,.
\end{align}

\subsubsection{Lorentz transformations}

Lorentz rotations and boosts are generated by antisymmetric tensors \(\omega_{\mu \nu  }\). These have six degrees of freedom. They alter the fields as
%
\begin{subequations}
\begin{align}
x^{\prime \mu } &= x^{\mu } + \omega^{\mu }_{\nu }x^{\nu }  \\
\varphi '(x') &= \varphi (x) - \frac{i}{2} \omega^{\mu \nu } \Sigma_{\mu \nu } \varphi (x)
\,,
\end{align}
\end{subequations}
%
where \(\Sigma_{\mu \nu }\) are the representations of the generators of Lorentz transformations for our field: for scalar fields they are zero, for a Dirac spinor we found that they can be expressed as
%
\begin{align}
\Sigma^{\mu \nu } = \frac{i}{4} \qty[\gamma^{\mu }, \gamma^{\nu }]
\,.
\end{align}

So, we can express the transformations in our general form:
%
\begin{subequations}
\begin{align}
\delta x^{\mu } &= \frac{1}{2} \omega^{\nu \rho } Y^{\mu }_{(\nu \rho )}  \\
\delta \varphi  &= \frac{1}{2} \omega^{\mu \nu } X_{(\mu \nu )}
\,,
\end{align}
\end{subequations}
%
where we included a \(1/2\) in the coordinate transformations since we are summing over two antisymmetric indices, so we will have two copies of every term. In order for these expressions to be equal, we need to set:
%
\begin{subequations}
\begin{align}
\omega^{\mu }_{\nu }x^{\nu } &= \frac{1}{2} \omega^{\nu \rho } Y^{\mu }_{(\nu \rho )}  \\
\frac{-i}{2} \omega^{\mu \nu } \Sigma_{\mu \nu } &=\frac{1}{2} \omega^{\mu \nu } X_{(\mu \nu )}
\,,
\end{align}
\end{subequations}
%
which is solved by
%
\begin{subequations}
\begin{align}
Y^{\mu }_{(\nu \rho )} &= \qty(\delta ^{\mu }_{\rho } \eta_{\nu \sigma } - \delta ^{\mu }_{\sigma } \eta_{\nu \rho })x^{\nu }  \\
X_{(\rho \sigma )} &= -i \Sigma_{\rho \sigma }
\varphi
\,.
\end{align}
\end{subequations}

Note that although we are using two indices for the bookkeeping of these transformations there are only six independent ones by antisymmetry.

The conserved currents are then given directly from the formula:
%
\begin{subequations}
\begin{align}
J^{\mu }_{(\rho \sigma )} &= 2 x_{[\rho } \widetilde{T}_{\sigma ]}^{\mu } - i \pdv{\mathscr{L}}{\partial_{\mu }\varphi } \Sigma_{\rho \sigma } \varphi  \label{eq:conserved-currents-Lorentz}\\
&= L^{\mu }_{\rho \sigma } + S^{\mu }_{\rho \sigma }
\,.
\end{align}
\end{subequations}

So, we have both an ``external'' angular momentum term and a spin term --- as long as the generators \(\Sigma_{\mu  \nu }\) are nonzero! The fact that a scalar field carries no spin can be read off from here.

\end{document}


\chapter{Introduction}

\section{The Problem}

The internet has become an essential tool for communication in the lives of many. But privacy has always remained a major concern.
This is the reason why nowadays most web content providers are slowly moving away from HTTP to HTTPS.
For instance, at the time of writing, around $86\%$ of Google's traffic is encrypted, which is a significant improvement compared to 2014 when only around $50\%$ of the traffic was sent over HTTPS \cite{google_transparancy}.
However, this encryption only obscures the content of the web pages and does not hide metadata such as what websites a user might be visiting.

Consequently, Internet service providers (ISPs) can easily obtain a lot of information about a person.
This can be a large concern for several people, like those living in oppressive regimes.
Having this data allows a government to easily spy on its people and censor whatever websites they would like.
To circumvent these issues, several anonymization techniques have been developed.
These systems obscure both the content and meta-data, allowing users to anonymously browse the web.
One of the most popular low-latency anonymization networks is called Tor, which relies on a concept called \textit{onion routing} to anonymize traffic \cite{tor_project}.

At the time of writing, the list of known attacks against Tor is limited and most of them rely on unlikely scenarios such as having access to specific parts of the network \textit{(like both entry and exit nodes)} \cite{tor_project}.
However, in this work we will make a more reasonable assumption that an attacker is a \textit{local eavesdropper}.
By this we mean that the entity only has access to the traffic between the sender and the first anonymization node.

The most successful attacks that satisfy these conditions are known as \textit{website fingerprinting attacks} (WF).
They rely on the fact that Tor does not significantly alter the shape of the network traffic \cite{kfingerprinting}.
Hence, the adversary can infer information about the content by analysing the raw traffic.
For instance by examining the packet sizes, the amount of packets and the direction of the traffic, we might be able to deduce
which web pages certain users are visiting.
Initially, Tor was considered to be secure against this threat but around 2011, some techniques such as the \textit{support vector classifier} (SVC) used by Panchenko et al. started to get recognition rates higher than 50\%.
Ever since, various defenses against WF attacks have been proposed \cite{panchenko1,perry2011experimental}.

However, one of the main problems with majority of the WF attacks proposed in the research literature is that they rely on a laborious,
time-consuming, manual feature engineering process, which often requires expert knowledge of the underlying TCP/IP protocols.
The reason behind this is that most primitive machine learning (ML) techniques only take fixed-length vectors as their input whilst traffic data consists of a variable-length amount of packets.
The features that are proposed are based on intuition and trial and error arguments as to why they identify specific web pages.
But there is no guarantee that they are in fact the most appropriate ones.

Thus the goal of this paper is to investigate the use of novel deep-learning techniques to automatically extract
a fixed-length vector representation from a traffic trace.
Next, we aim to use these features in existing attacks to see if our model is successful in the aforementioned task.

\newpage

\section{Aims and Goals}

We can subdivide the project up into several different aims, each with their own goals:

\begin{enumerate}
   \item \textbf{Aim:} Critically review the effectiveness of current website fingerprinting attacks.\\
   \textbf{Goals:}
   \begin{itemize}
      \item Analyse various models that are currently used in fingerprinting attacks.
      \item Research how a small percentage of false positives would impacts a real WF attack.
      \item Examine the effect of the rapidly changing nature of some web pages.
      \item Review if previous works make any assumptions that could impact the effectiveness of a real attack.
   \end{itemize}

   \item \textbf{Aim:} Automatically generate features from a trace that represents loading a webpage.\\
   \textbf{Goals:}
   \begin{itemize}
      \item Critically compare various feature generation techniques such as stacked autoencoders, sequence-to-sequence models and bidirectional encoder-decoder models.
      \item Identify a dataset that is large enough to train our unsupervised deep-learning models.
      \item Compare several software libraries to perform fast numerical computation such as Tensorflow, Torch, Theano and Keras.
      \item Implement the most appropriate feature generation models in one of the previously mentioned software libraries.
   \end{itemize}

   \item \textbf{Aim:} Train existing models with the automatically generated features and test their performance compared to hand-picked features.\\
   \textbf{Goals:}
   \begin{itemize}
      \item Identify several different models that have successful been applied to a website fingerprinting attacks and implement those attacks.
      \item Extract the same hand-picked features as have previously been used with the respective attacks.
      \item Investigate an appropriate technique for evaluating the results of different models.
      \item Compare the hand-picked features to the automatically generated ones for different classifiers.
      \item Investigate the classifiers' effectiveness in different threat models.
         For instance an adversary might want to identify which specific web pages a user is visiting \textit{(multi-class classification)} or
         they might just want to know whether the user visits a web page from a monitored set of web pages \textit{(binary classification)}.
   \end{itemize}

\end{enumerate}

\newpage

\section{Project Overview}
As previously mentioned, the project can be split up into three different aims, which is why we also approach the problem in three different stages:

\begin{itemize}
\item First, we examine different existing website fingerprinting classifiers to gain a deeper understanding of the concept.
\item Next, we perform more research into different automatic feature selection models and implement the most appropriate ones.
\item Finally, we evaluate the performance of the feature extraction models using different methods such as training existing WF classifiers with the generated features.
\end{itemize}

\section{Report Structure}
The general report has a very simple structure.
In the following section we further explore similar works and several concepts that are necessary to understand the basics of website fingerprinting and our specific attack.
Next, we identify the threat model and design an attack that uses our automatic feature generation model.
Finally, we explore several methods of evaluating the performance of different feature generation models and use these methods to perform a thorough analysis to see how our attack compares to existing state-of-the-art attacks.


\documentclass[aspectratio = 169]{beamer}

\usepackage[utf8]{inputenc} % Character encoding.

\pdfinfo{
   /Author (Bashar Dudin)
   /Title  (The Simplex Algorithm I)
   /Subject (Linear Programs)
}

\usepackage{./Style/linearProgramsBeamer} % This is extra styling for Beamer environments.
\usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content.

%-------------------------------------------------------------------------------
%   TITLE PAGE
%-------------------------------------------------------------------------------

\author[BD]{Bashar Dudin}

\institute[]{EPITA}

\title{Linear Programs} %
\subtitle{The Simplex Algorithm I}

%-------------------------------------------------------------------------------
%   DOCUMENT BODY
%-------------------------------------------------------------------------------

\begin{document}

\begin{frame}[plain]
\titlepage % Print the title page as the first slide
\end{frame}

\section{Linear Optimization over Polyhedra}

\begin{frame}{Geometry of the Set of Feasible Solutions}
    Let $L$ be the following linear program, in standard form :
    \begin{figure}
        \begin{linearProg}{
            maximize
            }{
            $x_1 + 2x_2$
            }{
            \systeme{x_1 + x_2 \leq 5, -2x_1 + x_2 \leq 3}
            }{
            $x_1, x_2 \geq 0$
            }
        \end{linearProg}
    \end{figure}

    The set of feasible solutions of $L$ is the region of the plane in
    between the positive parts of both axes and the lines having
    equations $x_2 = 5 - x_1$ and $x_2 = 3 + 2x_1$.
\end{frame}

\begin{frame}{Geometry of the Set of Feasible Solutions}
  \begin{columns}
    \begin{column}{.4\textwidth}
      This set of feasible solutions of $L$ has a remarkable geometric
      property called \textit{convexity}.
      \begin{defn}
        A subset $A$ of $\R^n$ is said to be \emph{convex} if the
        line segment linking any two points of $A$ is contained in
        $A$.
      \end{defn}
      In our case, we have a specific type of convex set called a
      \emph{polyhedron}. It is the intersection of a finite set of
      half-spaces.
    \end{column}
    \begin{column}{.6\textwidth}
      \begin{figure}
        \begin{tikzpicture}
          \begin{axis}[
            domain=0:5, xmin=-0.5, xmax=5.5, ymin=-0.5, ymax=5,
            grid=major, axis x line=center, axis y line=center,
            legend pos=north east,
            ]
            \addplot+[ultra thick, mark = none] {5 - x};
            \addplot+[ultra thick, mark = none] {3 + 2*x};
            \addplot+[fill = green, fill opacity = 0.3] coordinates
            {(0,0) (0,3) (.667,4.334) (5,0)} \closedcycle ;
          \end{axis}
        \end{tikzpicture}
      \end{figure}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}{Geometry of the Set of Feasible Solutions}
  \begin{prop}
    Any linear program has an underlying set of feasible solutions
    which is convex.
  \end{prop}
  \begin{defn}
    We call \emph{interior} of a convex set $A$ the set of points
    $x \in A$ for which there is a \textit{disk} having a positive
    radius and centered at $x$ contained in $A$. Any point of $A$ not
    satisfying this condition is called a \emph{boundary point}. The
    \emph{boundary} of $A$ is the set of boundary points (it can be
    empty).
  \end{defn}
  When dealing with convex sets defined by linear constraints,
  boundary points are points of the hyperplanes defined by replacing
  inequalities by equalities. This is clearly the case in our
  $2$-dimensional case.
\end{frame}

\begin{frame}{Boundary Optimizes Linear Function}
  Recall that a function $f : A \to \R$ for a region $A$ in $\R^n$ is
  said to be \emph{bounded} if there is a positive real number $M$
  such that : for all $x \in A$, $\big|f(x)\big| \leq M$.
  \begin{prop}
    Let $A$ be the region defined by the set of feasible solutions of
    a linear program $L$. If the objective function is
    \textit{bounded} on $A$ then $L$ has an optimal objective value,
    it is attained on the boundary of $A$ (if not empty).
  \end{prop}
  The justification for this result says way more!
\end{frame}

\begin{frame}{Extremal Points Optimize Linear Function}
  Let $A$ be the feasible region of a linear program $L$ in standard
  form. An \emph{extremal point} of A is a point $x$ for which any
  \textit{disk} centered at $x$ doesn't contain any (open) line
  segment centered at $x$ and fully contained in A. \pause Such points
  are necessarily boundary points, they appear as intersections of as
  many hyperplanes as dimension of program. \pause
  \begin{prop}
    Under previous assumptions, if the objective function of $L$ is
    \textit{bounded} on $A$ then $L$ has an optimal objective value
    which is attained at an extremal point of $A$ (if there are any).
    \end{prop}
\end{frame}

\begin{frame}
  \frametitle{Boundary Optimizes Linear Function | Naive Search}
  Let $L$ be a linear program of dimension $n$. A naive way to look
  for optimal points is then to look for intersections of combinations
  of any $n$ equations composing constraints of the linear
  program. \pause Looking for one single such intersection means
  solving a linear system having $n$ equations.
  \pause
  \begin{halfshyblock}{Question}
    Let $n$ be a positive integer. Consider the linear constraints
    \[
    \forall i \in \{1, \ldots, n\}, \quad 0 \leq x_i \leq 1.
    \]
    How many extremal points do the following constraints define?
  \end{halfshyblock}
  \pause As the example shows, complexity at worst grows exponentially
  with respect number of inequalities defining the constraints.
\end{frame}

\begin{frame}{Boundary Optimizes Linear Function | A Better Search}
  Rather than listing all potential optimal points, the \emph{simplex
    algorithm} is a walk along extremal points of the feasible region
  satisfying the fact :
  \begin{quotation}
    A given step returns a higher or equal objective value than
    previous step.
  \end{quotation}
  It has an initialization step we'll be keeping on the side for now
  by working under the following assumption:
  \begin{alertblock}{Assumption}
    Given a linear program $L$ in \textit{standard} form, we assume
    the vector having only zero entries is a feasible solution of $L$.
  \end{alertblock}
  \pause
  In the following example, starting from the zero feasible
  solution we're going to walk around the set of extremal points of
  feasible region to look for an optimal value.
\end{frame}

\section{Simplex Algorithm : First Try}

\begin{frame}{Simplex Algorithm : First Practical Examples}
    This is the slack form of the linear program $L$ we started with:
    \begin{figure}
      \begin{linearProg}{
          maximize
        }{
          $x_1 + 2x_2$
        }{
          \systeme{x_3 = 5 - x_1 - x_2, x_4 = 3 + 2x_1 - x_2 }
        }{
          $x_1$, $x_2$, $x_3$, $x_4 \geq 0$
        }
      \end{linearProg}
    \end{figure}
    The zero feasible solution of the standard form of $L$ corresponds
    to the solution $(0, 0, 5, 3)$ of its slack form; it has objective
    value $0$. The slack variables $x_3$ and $x_4$ tell us how far
    solution $(x_1, x_2)$ is from making the constraints
    \[
    \sysdelim..{\systeme{x_1 + x_2 \leq 5, -2x_1 + x_2 \leq 3}}
    \]
    tight, i.e. equalities.
\end{frame}

\begin{frame}{Simplex Algorithm : First Practical Examples}
    \begin{columns}
        \begin{column}{.5\textwidth}
            \begin{onlyenv}<1
              >The feasible slack solution $(0, 0, 5, 3)$ has
              corresponding feasible standard solution the origin of
              the plane. To wander around the boundary of the feasible
              region we have to choose which way to go ; we either go
              vertically keeping $x_1$ to $0$ or horizontally keeping
              $x_2$ to $0$. Any choice is fine as long as we are
              increasing the objective value. We shall give a
              \textit{rule of thumb} as to what choice one can make at
              each step later. For now, let us increase $x_1$ while
              keeping $x_2$ at $0$.
            \end{onlyenv}
            \begin{onlyenv}<2
              >
              \begin{figure}
                \small{
                  \begin{linearProg}{
                      maximize
                    }{
                      $x_1 + 2x_2$
                    }{
                      \systeme{x_3 = 5 - x_1 - x_2@(E_{*}), x_4 = 3 + 2x_1 - x_2 }
                    }{
                      $x_1$, $x_2$, $x_3$, $x_4 \geq 0$
                    }
                  \end{linearProg}
                }
              \end{figure}
              Variable $x_1$ is constrained by $E_1$: increasing it
              indefinitely would violate non-negativity
              constraints. No such constraints come from $E_2$. The
              highest possible value for $x_1$ is thus obtained when
              $x_3$ is $0$. Obtained solution is $(5, 0, 0, 13)$ of
              objective value $5$. It forces first equation of initial
              program tight.
            \end{onlyenv}
            \begin{onlyenv}<3
              >
              \begin{figure}
                \small{
                  \begin{linearProg}{
                      maximize
                    }{
                      $x_1 + 2x_2$
                    }{
                      \systeme{x_3 = 5 - x_1 - x_2@(E_{*}), x_4 = 3 + 2x_1 - x_2 }
                    }{
                      $x_1$, $x_2$, $x_3$, $x_4 \geq 0$
                    }
                  \end{linearProg}
                }
              \end{figure}
              Solution $(0, 0, 5, 3)$ can be understood as setting
              $x_1$ and $x_2$ to $0$. Solution $(5, 0, 0, 13)$ is
              about doing so to $x_3$ and $x_2$. \pause The thing to
              notice is that extremal points are exactly those for
              which $2$ variables are set to $0$. \pause To keep
              pattern \textit{set variables on the right to $0$} we're
              going to exchange sides of $x_1$ and $x_3$ (variables
              that entered into choice of walk).
            \end{onlyenv}
            \begin{onlyenv}<4
              >To get the feasible solution $(5, 0, 0, 13)$ one can
              express $x_1$ in $E_1$ in terms of the two other
              variables. One then replaces $x_1$ elsewhere with this
              expression. We get the equivalent program
                \begin{figure}
                  \small{
                    \begin{linearProg}{
                        maximize
                      }{
                        $5 - x_3 + x_2$
                      }{
                        \systeme{x_1 = 5 - x_3 - x_2@(E_{*}), x_4 = 13 - 2x_3 - 3x_2 }
                      }{
                        $x_1, x_2, x_3, x_4 \geq 0$
                      }
                    \end{linearProg}
                  }
                \end{figure}
                Putting $x_3$ and $x_2$ to zero in both equation gives
                back the expected feasible solution.
            \end{onlyenv}
            \begin{onlyenv}<5-6
                >\alt<6>{
                \textcolor{orange}{
                \begin{figure}
                  \small{
                    \begin{linearProg}{
                        maximize
                      }{
                        $\dfrac{28}{3} - \dfrac{5}{3}x_3 - \dfrac{1}{3}x_4$
                      }{
                        \systeme{x_1 = 2/3 - (1/3)x_3 + (1/3) x_4@(E_{*}), x_2 = 13/3 - (2/3)x_3 - (1/3)x_4 }
                      }{
                        $x_1$, $x_2$, $x_3$, $x_4 \geq 0$
                      }
                    \end{linearProg}
                  }
                \end{figure}
              }
              \vspace{-1em}
              Playing the same previous trick using $x_2$ and the
              second equation we get the above equivalent linear
              program. Putting both $x_3$ and $x_4$ to zero, we get
              the feasible solution $(2/3, 13/3, 0, 0)$ which has
              objective value $28/3$.  }{
                \begin{figure}
                  \small{
                    \begin{linearProg}{
                        maximize
                      }{
                        $5 - x_3 + x_2$
                      }{
                        \systeme{x_1 = 5 - x_3 - x_2@(E_{*}), x_4 = 13 - 2x_3 - 3x_2 }
                      }{
                        $x_1$, $x_2$, $x_3$, $x_4 \geq 0$
                      }
                    \end{linearProg}
                  }
                \end{figure}
                One can hope to maximize this linear program by
                increasing $x_2$. Any increase in $x_3$ would decrease
                the objective value. The most restrictive equation for
                $x_2$ is the second, indeed one can only increase
                $x_2$ up to $13/3$ while in the second up to $5$.  }
            \end{onlyenv}
            \begin{onlyenv}<7->
                \begin{figure}
                  \small{
                    \begin{linearProg}{
                        maximize
                      }{
                        $\dfrac{28}{3} - \dfrac{5}{3}x_3 - \dfrac{1}{3}x_4$
                      }{
                        \systeme{x_1 = 2/3 - (1/3)x_3 + (1/3) x_4@(E_{*}), x_2 = 13/3 - (2/3)x_3 - (1/3)x_4 }
                      }{
                        $x_1$, $x_2$, $x_3$, $x_4 \geq 0$
                      }
                    \end{linearProg}
                  }
                \end{figure}
                \vspace{-1em}
                We can't hope to increase the objective value
                anymore. Any increase in the values of $x_3$ or $x_4$
                would decrease the object value. The objectve function
                is maximal when both are zero. The corresponding
                maximal solution is $(2/3, 13/3, 0, 0)$ of objective
                value $28/3$.
            \end{onlyenv}
        \end{column}
        \begin{column}{.5\textwidth}
            \begin{overlayarea}{\textwidth}{.8\textheight}
                \begin{onlyenv}<1>
                \begin{figure}
                    \begin{tikzpicture}
                        \begin{axis}[
                            domain=0:5, xmin=-0.5, xmax=5.5, ymin=-0.5, ymax=5,
                            grid=major, axis x line=center, axis y line=center,
                            legend pos=north east,
                            ]
                            \addplot+[ultra thick, mark = none] {5-x};
                            \addplot+[ultra thick, mark = none] {3 + 2*x};
                            \addplot+[fill = green, fill opacity = 0.3] coordinates
                            {(0,0) (0,3) (.667,4.334) (5,0)} \closedcycle ;
                            \addplot[ultra thick, black, mark size = 8pt, mark = square] coordinates {(0,0)};
                        \end{axis}
                    \end{tikzpicture}
                \end{figure}
                \end{onlyenv}
                \begin{onlyenv}<2-5>
                    \begin{figure}
                    \begin{tikzpicture}
                        \begin{axis}[
                            domain=0:5, xmin=-0.5, xmax=5.5, ymin=-0.5, ymax=5,
                            grid=major, axis x line=center, axis y line=center,
                            legend pos=north east,
                            ]
                            \addplot+[ultra thick, mark = none] {5-x};
                            \addplot+[ultra thick, mark = none] {3 + 2*x};
                            \addplot+[fill = green, fill opacity = 0.3] coordinates
                            {(0,0) (0,3) (.667,4.334) (5,0)} \closedcycle ;
                            \addplot[ultra thick, black, mark size = 8pt, mark = square] coordinates {(5,0)};
                        \end{axis}
                    \end{tikzpicture}
                \end{figure}
                \end{onlyenv}
                \begin{onlyenv}<6->
                    \begin{figure}
                    \begin{tikzpicture}
                        \begin{axis}[
                            domain=0:5, xmin=-0.5, xmax=5.5, ymin=-0.5, ymax=5,
                            grid=major, axis x line=center, axis y line=center,
                            legend pos=north east,
                            ]
                            \addplot+[ultra thick, mark = none] {5 - x};
                            \addplot+[ultra thick, mark = none] {3 + 2*x};
                            \addplot+[fill = green, fill opacity = 0.3] coordinates
                            {(0,0) (0,3) (.667,4.334) (5,0)} \closedcycle ;
                            \addplot[ultra thick, black, mark size = 8pt, mark = square] coordinates {(.667, 4.334)};
                        \end{axis}
                    \end{tikzpicture}
                    \end{figure}
                \end{onlyenv}
            \end{overlayarea}
        \end{column}
    \end{columns}
\end{frame}

\section{Simplex Algorithm : A Step Towards Rigorousness}

\begin{frame}{Notation and Terminology}
    Consider a linear program given in standard form as
    \begin{figure}
        \begin{linearProgG}{
            ${\displaystyle z = \nu + \sum_{j=1}^n c_jx_j}$
            }{
            ${\displaystyle \forall i \in \{ 1, \ldots, m \}, \quad \sum_{j=1}^n a_{ij}x_j \leq b_i}$
            }{
            $\forall j \in N, \quad x_j \geq 0$
            }
        \end{linearProgG}
    \end{figure}
    The set $N$ is the set $\{ 1, \ldots, n \}$ of indexes of
    variables. Notice that the scalar $\nu$ is the objective value of
    the basic solution ; recall that this is not a feasible solution
    in general, it might have negative entries.
\end{frame}

\begin{frame}{Notation and Terminology}
    The slack form of the previous linear program is written
    \begin{figure}
        \begin{linearProgG}{
            ${\displaystyle z = \nu + \sum_{j=1}^n c_jx_j}$
            }{
            ${\displaystyle \forall i \in \{1, \ldots m \}, \quad x_{i + n} = b_i - \sum_{j=1}^n a_{ij}x_j}$
            }{
            $\forall j \in N\cup B, \quad x_j \geq 0$
            }
        \end{linearProgG}
    \end{figure}
    The set of variables (indexed by $B = \{n + 1, \ldots, n + m \}$)
    are called \emph{basic} variables. Variables on the right (indexed
    by $N$) are called \emph{non-basic} ones. The \emph{basic
      solution} of a linear program in slack form is the one obtained
    by putting all non-basic variables to zero.
\end{frame}

\begin{frame}{Practical Steps of the Simplex Algorithm}
  Linear programs having feasible basic solution are easier to deal
  with. The ones having non-feasible basic solution need a work
  around. The assumption under which we've been working can be
  rephrased as:
  \begin{alertblock}{Assumption (BF)}
    The \textit{basic solution} of initial linear program in
    standard form is a feasible solution.
  \end{alertblock}
  We first treat programs satisfying (\emph{BF}) before going onto
  general case.
\end{frame}

\begin{frame}{Practical Steps of the Simplex Algorithm}
  The simplex algorithm is a procedure exchanging a basic variable
  with a non-basic one at each step. \pause Here is the main steps of
  the simplex algorithm in case (\emph{BF}) is satisfied.
  \begin{itemize}
  \item<2->[\textbullet]
    Choose a non-basic variable $x_e$ increasing the objective
    value.
  \item<3->[\textbullet]
    Use the most restrictive constraint $\ell$ on $x_e$ to
    express $x_e$ in terms of the remaining variables.
  \item<4->[\textbullet]
    Replace $x_e$ in remaining linear equalities and objective
    function by the expression previously obtained. The variable $x_e$
    becomes a basic variable while $x_\ell$ becomes non-basic.
  \item<5->[\textbullet]
    Putting all non-basic variables to zero we get a tuple whose
    first $n$ entries are a feasible solution of the linear
    program we started with.
  \item<6->[\textbullet]
    Repeat previous steps until one cannot increase objective
    value anymore.
  \end{itemize}
\end{frame}

\begin{frame}{A Finishing Blow about Boundedness}
  Notice that there is no garantee that the previous algorithm would
  get you a maximal solution in general. We do know that, if the
  objective function is bounded on the feasible region, then there is
  a maximum attained at the boundary of this region. But there are
  cases when the objective function is not bounded on the feasible
  region.
  \begin{halfshyblock}{Unboundedness}
    Can you find a linear program which is not bounded?
  \end{halfshyblock}
\end{frame}

\begin{frame}{Practical Steps of the Simplex Algorithm}
  The previous steps are precisely what we've been doing while
  wandering around the boundary of our dummy example. This approach
  does however exceed the $2$-dimensional case.
  \begin{halfshyblock}{A $3$-dimensional case}
    Following previous steps try solving the linear program
    \begin{figure}
      \begin{linearProg}{
          maximize
        }{
          $3x_1 + x_2 + 2x_3 $
        }{
          \systeme{x_1 + x_2 + 3x_3 \leq 30, 2x_1 + x_2 + 5x_3 \leq 24, 4x_1 + x_2 + x_3 \leq 36}
        }{
          $x_1, x_2, x_3 \geq 0 $
        }
      \end{linearProg}
    \end{figure}
  \end{halfshyblock}
\end{frame}

\begin{frame}
  \begin{center}
    {\huge \textbf{That's it for today}}
  \end{center}
\end{frame}

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

\end{document}

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


\chapter{Arrays and Pointers}

\section{Array}
\begin{enumerate}
\item Sequential container of objects of a single data type with fixed size:
    \imc{int array[3] = {5, 3, 2};}
\end{enumerate}

\section{Pointer}
\begin{enumerate}
\item A pointer is a variable that holds the address of an object, enabling
    indirect access: \imc{int *m = new int[4];}
\item Adding an integer $n$ to a pointer variable returns the address of an
    element displaced by $n$ from the original element.
\end{enumerate}

\section{<++>}

\section{<++>}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\title{Very Basic Environments}
\author{Connor Barlow}
\date{October 2020}

\newtheorem{thm}{Theorem}
\newtheorem{corr}{Corollary}

\begin{document}
\maketitle

\section{Lists}
\begin{enumerate}
    \item This is a numbered list.
    \item The numbers should be read aloud.
\end{enumerate}
\begin{itemize}
    \item This is a bullet list.
    \item The items have no intrinsic ordering.
\end{itemize}
\begin{description}
    \item[Bob] What type of list is this?
    \item[Bill] Its for listing items that have a corresponding name!
    \item[Bob] Neat.
\end{description}
\section{Simple Table}
\par
Here's a very ugly table to show different combinations of lines.
\par
\begin{tabular}{|l||cr}
1 & 2 & 3 \\
4 & 5 & 6 \\
\hline
7 & 8 & 9 \\
\hline \hline
\end{tabular}
\section*{This Section Isn't Numbered}
\begin{verbatim}
\textbf{This} text is not formatted in \textit{any} way,
\end{verbatim}
but \textit{this} \textbf{is}! Now here's some math related things.\\
Here's some varieties of math mode. First some line separated math modes \dots
\[f(x)=x\]
$$g(x)=\frac{1}{f(x)}$$
\dots and now inline math modes, \($lim$_{x\rightarrow\infty}f(x)=\infty\) and $\int g(x)=\ln(x)$. For something a bit more sophisticated we have equations and theorems.
\begin{equation}
h(x)=x^2
\end{equation}
\begin{eqnarray}
\text{short} &= -\frac{b+\sqrt{b^2-4ac}}{2a}\\
\text{looooooongVariableName} &= -\frac{b-\sqrt{b^2-4ac}}{2a}
\end{eqnarray}
\begin{thm}
This is my theorem.
\end{thm}
\begin{corr}
This is my corollary.
\end{corr}
\begin{center}
And now a couple basic formatting environments.
\end{center}
\begin{flushright}
These shouldn't change too much besides documents structure.
\end{flushright}
\begin{flushleft}
And their typical use won't be as contrived as this.
\end{flushleft}
\end{document}


\chapter{Geometrical Calibration of CT system}
\label{chap:calibration}

\section{Background}
CT system requires precise knowledge of the scan geometry of the acquisition system.  These parameters are crucial for the reconstruction algorithm to provide the best object resolution and image quality.  Since it is not possible to know precisely the geometry of the system, calibration methods are needed to account for misalignment of system prior to image reconstruction.  In cone beam tomography , it is well know that using inaccurate parameters can produce sever artifacts (\citep{Li1994a}, \citep{Li1994b}, \citep{Wang1998}). Methods for estimation of geometrical parameters of tomographic scanners have been investigated by many groups since 1987 starting with Gullberg \citep{Gullberg1987}.  Some calibration methods tend to be specific to the 2D parallel-beam geometry (\citep{Azevedo1990}, \citep{Busemann1987}), some are only for 2D fan beam geometry(\citep{Crawford1988}, \citep{Hsieh1999} \citep{Gullberg1987}).  In these earlier days, the overall approach is to estimate the geometric parameters by first measure the locations of a point object on the detector and determine analytic expressions for the point object location as functions of the unknown scanner parameters and unknown positions of the point object.  This step provides a set of nonlinear equations and these equations are solved using an iterative method such as the Levenberg-Marquard algorithm.  The downside of these algorithms is that they rely on a highly nonlinear parameter-estimation problem and are highly sensitive to the initial estimations and the sequential order in which the parameters are estimated.  There are questions of stability and uniqueness.  It is uncertain if local minima exist or if more than one set of calibration parameters can satisfy the equations.  Later this work was extended to 3D for cone-beam scanners \citep{Gullberg1990}, however the degree of freedom were restricted and some shift parameters were assumed to be known.

To avoid these problems, in 2000 Noo \citep{Noo2000} proposed a method by introducing intermediate parameters by fitting an ellipse to the projection-orbit data.  This method only requires a small set of measurements of a simple phantom.  However this method assumes that one out-of-plane rotation angle to be zero.  In 2004 Smekal introduced an analytical method to solve six system parameters except for the source to isocenter distance.  This method is based on Fourier analysis of the projection-orbit data, as a result it is insensitive to the precise extraction of the phantom point projection location on the detector.  In 2006, Yang \citep{Yang2006} proposed a similar method based on tracing the point projection of a phantom on the detector.  They assume two out of plane rotation angles are quite small so instead of measure them they simply assumed them to be zero.  In 2005 Cho has another great idea. \citep{Cho2005} where you don't need to rotate the phantom, they used the rapid prototype machine to create a phantom with great accuracy.  Jared Moore used the MLEM algorithm to use all points of the phantom to estimate the parameters.  In 2008, Panetta \citep{Panetta2008} proposed a new method where they measure the misalignment parameters of a cone-beam scanner by minimizing a geometry-dependent cost function.  This cost function is computed from the projection data of a generic object, hence, no a-priori knowledge of the object shape or position is required.

\section{Phantom}
Our method requires use to rotate a line of fiducial markers placed at known separation in front of the scintillator.  We needed a phantom that does not require a lot of rapid prototype material and is able to switch out different marker sizes for different magnifications.  Shown in Figure~\ref{fig:calibration_phantom}, the phantom is composed of 2 separate pieces, a bracket that can be mounted on the rotation stage, and a marker insert for the bracket where different marker sizes can be placed.  It is much easier and cheaper to print a different marker insert than to print an entire phantom bracket.  The bracket places the markers 6 inches from the center rotation axis.  The marker inserts uses a conical end so it's easy to align the vertical axis of the market against the axis of the bracket.  The marker insert is held at 2 ends by the bracket to ensure the insert is vertical.  The marker points are made out of stainless steel bearings purchased from McMaster-Carr.  Three different bearing sizes (1/16 \inches, 1/8 \inches and 3/16 \inches and 1/4 \inches) where glued onto the insert, though we've found 1/8 \inches bearing worked the best.

\begin{figure}
\centering
	\begin{subfigure}[b]{0.3\linewidth}
	\centering
	\placeholderimage[width=3cm,height=3cm]{phantombracket.png}
	\caption{phantom bracket}
	\label{fig:phantom_bracket}
	\end{subfigure}
\hspace{0.2cm}
	\begin{subfigure}[b]{0.3\linewidth}
	\centering
	\placeholderimage[width=3cm,height=3cm]{markerinsert.jpg}
	\caption{marker insert}
	\label{fig:marker_holder}
	\end{subfigure}
\hspace{0.2cm}
	\begin{subfigure}[b]{0.3\linewidth}
	\centering
	\placeholderimage[width=3cm,height=3cm]{steelbearings.jpg}
	caption{steel bearings}
	\label{fig:steel_bearings}
	\end{subfigure}
\caption{Calibration phantom}
\label{fig:calibration_phantom}
\end{figure}

\section{Calibration Method}
Tomographic image quality depends on the precise knowledge of the scan geometry of the acquisition system. Most methods available require a precise knowledge of marker locations in a calibration phantom.  Here we follow the method introduced by Lorenz von Smekal to calculate the geometric misalignment of our CT system.  There are two magnification factors involved in our system, the x-ray magnification is created by the ratio of the distance between x-ray source and scintillator screen and the distance between object and scintillator screen.  Optical magnification is introduced by scaling the image created by the scintillator and down to the size of the camera detector.  If we were to look at the CT system, we can draw an optical axis from the x-ray source to the center of the camera detector. Each component in the CT system can potentially add 6 degrees of freedom, xyz position and 3 angular rotations.  However many of these degrees of freedoms are linked and can be grouped together as one.  We used a 2 step calibration process, the first step is to measure the optical magnification from the scintillator screen to the lens-camera system.  Second, we treat the x-ray source to scintillator screen as one imaging system. This way, we do not have to measure the the misalignment introduced by the scintillator, mirror and lens-camera system as separate factors. After all, a tilt in the scintillator will be in separable from tilt in mirror or camera.  We simply assume that all points of the scintillator screen is focused by the lens onto the camera detector therefore the only difference between the image produced at the scintillator and camera detector is the magnification.  As a result, the only geometrical measurements we needed to calibrate is detector angular misalignment (slant $\phi$, tilt $\theta$, skew $\eta$), and position misalignment (shift $d_x$ and $d_z$), and the distance between the x-ray source to the scintillator.
To calculate the optical magnification, we take a metal plate of a known size and place it directly in front of the scintillator screen.  The image produced will be directly transferred onto the camera detector via the lens by a magnification factor.  Once the optical magnification was known, we then use the following steps to find the rest of the system parameters:
\begin{enumerate}
\item Extract phantom marker locations
\item Find system parameters
\item Find object parameters
\end{enumerate}

\subsection{Extract phantom marker locations}
Both threshold and Gaussian filters were used to extract the centroid location for each of the markers.  First the projection image of the markers are filtered through a threshold value range in attempt to eliminate as much background information as possible.  We then set a small ring along the edge of image to zero.  Each points in the processed image is then multiplied by a small Gaussian filter and the values summed up.  This is an attempt to try to eliminate spotty non-localized noise remained in the image.  The result is an image with mostly zero values except at the marker locations.  Finally we then use another Gaussian filter with its size approximately equal to the size of the marker and multiply it by each of the marker point clusters to find the centroid value.  We assume that the centroid should have the most neighboring pixels and the point with the highest summed value after multiplied by the Gaussian filter is the centroid.  The x and y coordinate of the marker locations were then recorded for projection image at each angular rotation.

\begin{figure}
	\centering
	\begin{subfigure}[b]{0.3\linewidth}
	\centering
	\placeholderimage[width=3cm,height=3cm]{GaussianFilter.jpg}
	\label{fig:GaussianFilter}
	\caption{Gaussian filter}
	\end{subfigure}
\hspace{0.2cm}
	\begin{subfigure}[b]{0.3\linewidth}
	\centering
	\placeholderimage[width=3cm,height=3cm]{MarkerCluster.jpg}
	\label{fig:markercluster}
	\caption{projection of a marker}
	\end{subfigure}
\label{fig:extractmarkerlocation}
\caption{filters used to extract each marker locations}
\end{figure}

\subsection{Find system parameters}
To find the system parameters we used Lorenz von Smekal's calibration method. This method overcomes convergence and initialization problems that has plagued other methods (need more citation).  This method does not require knowledge of the marker spatial location inside the field of measurements.  The misalignment parameter are determined independently for each of the point objects by explicit analytic expression.  The result for each point markers can then be averaged as the final result.  The corresponding mean square deviation provide with an error estimate of the calibration parameters.  The method is based on an analysis of the low spatial-frequency Fourier components of the point projection orbits on a misaligned detector.  The method then disentangle each parameters by using a series of coefficients and equations.  For more detailed information please refer to his paper~\citep{Smekal2004}.  In this section we will only focus on the geometry and steps taken to calculate the calibration parameters, and will provide the equations used for these calculations.  Shown in Fig.\ref{fig:system_geometry}, the x-ray source is connected through the center of the detector by the y axis.  The object rotates about the z axis and the detector plane is in the x and z plane.  The detector can be described by 6 misalignment parameters ($dx$,$dy$,$dz$, $\theta$, $\eta$, $\phi$).  The distance between the source and the ideal detector is R, the distance between the source and object axis of rotation is Rf.  The projection of the the point markers in a circular orbit onto a misaligned detector plane is described by $u_{\alpha}$ and $v_{\alpha}$.  The method first parameterize the projected path of the point markers in a circular orbit on the misaligned detector axis $u$ and $v$.  The result is two equations that describes the path of the point markers in $u$ and $v$ separately in terms of cosine and sine using a set of coefficients.  These coefficients are directly related to the detector misalignment parameters.  The first step is to calculate these coefficients by fitting projected marker point path on detector to Fourier series.  Figure X shows the experimental u and v values for a set of markers.  The equation for Fourier series is shown in \ref{eq:fourierseries}.  In this calibration method, only the first 3 orders for both u and v were used and their corresponding coefficients are calculated using equation ~\ref{eq:fouriercoeff}.

\begin{figure}
\centering
\placeholderimage[width=5cm,height=3cm]{systemgeometry.jpg}
\caption{system geometry}
\label{fig:system_geometry}
\end{figure}

\begin{equation}\label{eq:fourierseries}
u_n = \frac{U_0}{2} + \sum ^{N/2-1}_{k=1} (U_k \cos (k\alpha_n)) + \tilde{U}_k \sin (k \alpha_n) + (-1)^{(n-1)} \frac{U_{N/2}}{2};
\end{equation}
The Fourier coefficients in this series are given by:
\begin{equation}\label{eq:fouriercoeff}
\begin{split}
U_k = & \frac{2}{N}\sum_{n=1}^{N} u_n \cos (k \alpha_n), \hspace{0.3cm} k = 0, ...., N/2, \\
\tilde{U}_k = & \frac{2}{N} \sum_{n=1}^{N} u_n \sin (k \alpha_n), \hspace{0.3cm} k = 1,...,N/2-1
\end{split}
\end{equation}
and analogously for the $V_k$ and $\tilde{V_k}$.
These Fourier coefficients are then used to calculate nine coefficients, that are used further to calculate the calibration parameters.  Please refer to Appendix for the set of equations used to calculate the calibration parameters.  Figure ~\ref{fig:FourierFit} shows the Fourier series fit to u and v variable extracted from projection of the phantom markers.  Figure~\ref{fig:smekalresult} shows the result of the method after using Smekal's method.

\begin{figure}
\centering
	\begin{subfigure}[b]{0.4\linewidth}
	\centering
	\placeholderimage[width=3cm,height=2cm]{FourierFit.png}
	\label{fig:FourierFit}
	\caption{Fourier coefficient fit to data}
	\end{subfigure}
\hspace{0.2cm}
	\begin{subfigure}[b]{0.4\linewidth}
	\centering
	\placeholderimage[width=3cm,height=2cm]{smekalresult.png}
	\label{fig:smekalresult}
	\caption{Calculated result}
	\end{subfigure}
\label{fig:smekal_method}
\caption{Fitting result}
\end{figure}
Smekal's method calculates 11 parameters.  These are the detector rotation misalignment ($\eta$,$\theta$,$\varphi$), detector position misalignment ($dx$,$dz$), $R$, $Ry_p$, $Rf_p$, and object marker initial location with respect to $R_f$ ($x_0/R_f$, $y_0/R_f$, $z_0/R_f$).  Unfortunately $R_f$ and marker initial locations are presented together and we cannot separate initial marker point location anymore by using Smekal's calibration method.  To over come this problem, we used the contracting grid algorithm to search for $R_f$ as well as nuisance parameters that include six degrees of freedom for the object.
\subsection{Find object parameters}
The contracting grid search algorithm is based on maximum-likelihood estimation.  The maximum-likelihood method can generally be formulated as a search over a parameter space,
\begin{equation}
\label{eq:mlem}
\mathbf{\hat{\theta}} = \arg\max_{\theta} \; \lambda (\mathbf{\theta | g}) = \arg\max_{\theta} \; pr( \mathbf{g| \theta} )
\end{equation}
where $\theta$ is a vector of parameters, $g$ is a vector of observations (data), $\lambda$ is the likelihood, and $\hat{\theta}$ is a vector of estimated model parameters.
The equation can be explained as find$\theta$ that will maximize $pr(g|\theta)$, or the likelihood ($\lambda(\theta|g)$). The general method can be summarized in the form of a question: given a set of observations $g$, what is the set of parameters $\theta$ that has the highest probability of generating the observed data?
The set of observations $g$ in our case are the positions of the marker points on the detector as they rotate through a circular orbit. The parameters $\theta$ are the misaligned parameters we found using Smekal's method, as well as $R_f$ and the marker's object positions.  Given an imaging system and object model we can express the results of the imaging system using a general equation:
\begin{equation}
\label{eq:gHf}
\mathbf{g} = \mathbf{H} \; f + n
\end{equation}
where $n$ is additive noise assumed to have zero mean, $f$ is the object, $g$ is the image created, $H$ is the imaging system operator that takes the object information and creates $g$.  If we average multiple images of the same object we arrive at the mean image, $\bar{g}$ with
\begin{equation}
\label{eq:gbar}
\bar{\mathbf{g}} = \mathbf{H} \; f
\end{equation}
In real x-ray CT image data obtained with reasonably long exposure time, the noise term, n, is normally distributed with zero mean.  Thus the image data, g is normally distributed with mean $\bar{g}$.  Another way to write this is:
\begin{equation}
\label{eq:prob_gaus}
pro(g|\theta) = pr(n) = Gauss(0, \sigma^2)
\end{equation}
where $Gauss(0, \sigma^2)$ is a zero-mean Gaussian distribution of a vector the same size as n with variance $\sigma^2$.
The maximum-likelihood estimation of parameters on a zero mean normally distributed data reduces to solve:
\begin{equation}
\arg\min_{\theta} \| g - \bar{g} \|^2
\end{equation}
The  maximum-likelihood method is equivalent to a least-squares solution.
In other words, choose the parameters $\theta$ that minimize the mean-squared error between the observed data, g, and the parameter-dependent mean, $\bar{g}$
Since $\theta$ is a multi-dimensional space(each parameter to be estimated adds one dimension).  There are many techniques developed to address this problem, including conjugate gradient methods and a host of other (Kolda2003, Knuth1998, Audet2006, Kolda2003, Conn2008).  The algorithm allows identification of a function maximum (or minimum) in a fixed number of iterations that depends on the desired precision.  It is a deterministic search algorithm (so the same starting point always yields the same result compared to statistical search methods where the end result is always slightly different).  Essentially the algorithm is a semi exhausted search for a set of parameters that minimizes the MSE, then the algorithm regenerate another set of parameter sets based on the previous iteration until we reach the maximum iteration specified. The contracting grid algorithm is broken down into X steps.
\comment{talk about prior? we know a guess right?}
guess a prior parameter. this is not the same as $pr(\theta)$
1. For each parameter $\theta_i$, create  a region of physically reasonable grid size $M_i$.
2. Calculate MSE for all combination of each parameters grids.
3. Locate the minimum MSE and the set of parameters that was used.
4. Contract the grid size
5. repeat steps 2-4 until reaching maximum iteration number.

We have found that it is more efficient to first approximate $R_f$, $\varphi$, $\eta$, and $\theta$.  A rough estimation of $R_f$ can simply be found by calculating the ratio of $\Delta z$ from the phantom and $\Delta z/R_f$ calculated from previous section.  $\varphi$ of the phantom is the rotation of the markers about the $z$ axis, changing this variable does not effect the overall dimension of the projection markers but it does greatly contribute to MSE value so we tried to approximate it after $R_f$ to minimize the search extension of the search grid space.  Finally the initial values for both $\phi$ and $\eta$ is approximated.  Figure X shows the projection of the markers using initial parameters.  The tolerance for each variable is described in Table X.  We have used grid size of 4 for each parameter at rate of 1.1.  Using 100 iteration, the result to the calibration is show in Table X.

locate $\varphi$ of the object roughly because it does not eff

The phantom was designed in SolidWorks and printed on the rapid prototype machine, so we know the location of the bearing markers in the object relative to its axis of rotation.  These are the initial guesses to the marker location, x0, y0, and z0.  The other unknown values are object rotation parameters ($\eta_{obj}$,$\varphi_{obj}$,$\theta_{obj}$) and $R_f$.  By initially perturbing each parameter, we have created initial guess of each parameter, then final values where ran through the contracting grid algorithm.

\section{Calibration result}

\begin{equation}\label{eq:d_coeff}
\begin{split}
d_{22}' =& \; (U_3^2 - U_1^2 + \tilde{U}_3^2 - \tilde{U}_1^2)/2 \\
d_{20}' =& \; ((U_1 - U_3)\,U_2 - (\tilde{U}_3 - \tilde{U}_1)\tilde{U}_2)/d_{22}' \\
d_{21}' =& \; ((U_1 + U_3)\tilde{U}_2 - (\tilde{U}_3 + \tilde{U}_1) U_2)/ d_{22}' \\
d_{00}' =& \; ((U_0 + U_2)\,d_{20}' + \tilde{U}_2 \, d_{21}' + 2 U_1)/2 \\
d_{01}' =& \; (\tilde{U}_2 \, d_{20}' + (U_0 - U_2)\, d_{21}' + 2 \tilde{U}_1)/2  \\
d_{02}' =& \; (U_1 d_{20}' + \tilde{U}_1 \, d_{21}' + U_0)/2 \\
d_{10}' =& \; ( (V_0 + V_2) \, d_{20}' + \tilde{V}_2 \, d_{21}' + 2 V_1 )/2 \\
d_{11}' =& \; (\tilde{V}_2 d_{20}' + \tilde{V}_2 \, d_{21}' + 2 V_1)/2 \\
d_{12}' =& \; (V_1 \, d_{20}' + \tilde{V}_1 \, d_{21}' + V_0)/2   \\
\end{split}
\end{equation}

\begin{equation}\label{eq:c_coeff}
\begin{split}
&
\begin{pmatrix}
c_{00}' \\
c_{01}'
\end{pmatrix} = \frac{1}{d_{20}'^2 + d_{21}'^2}
\begin{pmatrix}
d_{20}' & d_{21}' \\
d_{21}' & d_{20}'
\end{pmatrix}
\left[ \frac{1}{2}
\begin{pmatrix}
U_2 & \tilde{U}_2 \\
\tilde{U}_2 & -U_2
\end{pmatrix}
\begin{pmatrix}
d_{20}' \\ d_{21}'
\end{pmatrix}
+ \begin{pmatrix}
U_1 \\ \tilde{U_1}
\end{pmatrix}
\right]
+ \begin{pmatrix}
U_2/2 \\ 0
\end{pmatrix} \\
&
\begin{pmatrix}
c_{10}' \\ c_{11}'
\end{pmatrix}
= \frac{1}{d_{20}' + d_{21}'^2}
\begin{pmatrix}
d_{20}' & d_{21}' \\
d_{21}' & d_{20}'
\end{pmatrix}
\left[ \frac{1}{2}
\begin{pmatrix}
V_2 & \tilde{V}_2 \\
\tilde{V}_2 & -V_2
\end{pmatrix}
\begin{pmatrix}
d_{20}' \\ d_{21}'
\end{pmatrix}
+ \begin{pmatrix}
V_1 \\ \tilde{V_1}
\end{pmatrix}
\right]
+ \begin{pmatrix}
V_2/2 \\ 0
\end{pmatrix}
\end{split}
\end{equation}

\begin{equation}
\label{eq:eta}
\tan \eta = - \frac{c_{11}'}{c_{01}'}
\end{equation}

\begin{equation}
\label{eq:ABCEF}
\begin{split}
A =& \sin \eta \; c_{00}' + \cos \eta \; c_{10}' \\
B =& \cos \eta \; c_{01}' + \sin \eta \; c_{11}' \\
C =& \cos \eta \; c_{00}' - \sin \eta \; c_{10}' \\
E =& \sin \eta \; d_{02}' + \cos \eta \; d_{12}' \\
F =& \cos \eta \; d_{02}' + \sin \eta \; d_{12}' \\
\end{split}
\end{equation}

\begin{equation}
\label{eq:theta}
\sin \theta = \frac{B (F_k - F_j)}{(E_k - E_j)(C - F_k)-(F_k - F_j)(A - E_k)}
\end{equation}

\begin{equation}
\label{eq:varphi}
\tan \varphi = \frac{C-F}{\sin \theta \, (A-E) \, \pm \, B}
\end{equation}