\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{subfig}
\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt
]{biblatex}

\addbibresource{ssvgd.bib}

\title{State Space Reporting Delay}

\date{January 2018}

\begin{document}

\subsection*{Introduction}

State-Space models have become popular tools in the analysis of time-series. They allow for arbitrary transition and observation dynamics. The researcher can assign a latent data generating process, while simultaneously allowing for observational error on that process. The classic algorithm for fitting non-Gaussian SSMs is given by the particle filter. Although many variations exist, we generally refer to the sampling importance re-sampling (SIR) filter when discussing particle filtering. Although a powerful inference tool, particle filtering suffers from several well known drawbacks. The first is the problem of filter degeneracy. This occurs when the observations are far from the state predicted by the latent dynamics. The second is the excessive run-times on longer time series with complex dynamics.
We propose an alternative approach that we hope will do better than particle filtering in practice.  In this approach, Stein Variational Gradient Descent (SVGD) is used to sequentially estimate the distribution of state variables in each time step, conditional on observed data up through that time.

\subsection*{Overview of SVGD}
Stein Variational Gradient Descent can be used to estimate a continuous distribution by a set of particles. By iteratively transporting samples from an initial distribution in the direction of the likelihood, we are able to generate compute Monte Carlo estimates of the posterior. The usefulness of this approximation is apparent in Bayesian statistics, where the usually intractable normalizing constant disappears in the particle update step. The particles are subject to the following gradient ascent procedure.

$$x_i^{l+i} \leftarrow x_i^{l}+\epsilon_l\hat{\phi^*(x_i^l)}   $$
$$\hat{\phi^*(x)} = \frac{1}{n}\sum_{j=1}^n[k(x_j^l,x)\nabla_{x_j^l}log\ p(x_j^l) + \nabla_{x_j^l}k(x_j^l,x)]$$

for an arbitrary positive definite kernel function $k(.,.)$ usually chosen to be a Gaussian kernel.

\subsection*{State Space Models}
Suppose we are given a time series $Y_1,Y_2,...,Y_t$ for $Y \in \mathbb{R}$. We model the sequence as a state-space model parameterized by an observation density $p(y_t | x_t)$ and a transition density $p(x_t | x_{t-1})$ Figure 1.

\begin{center}
\includegraphics[scale=.5]{/home/gcgibson/ssm.png}
\end{center}

We are interested in the filtering distribution $p(x_1,...,x_n | y_1,...,y_n)$ which by Bayes formula is $$p(x_1,...,x_n | y_1,...,y_n) = \frac{p(y_1,...,y_n | x_1,...,x_n) p(x_1,...,x_n)}{Z}$$.

Because computing the normalizing constant $Z$ is intractable for many choices of $p(y_t | x_t)$ and $p(x_t | x_{t-1})$, we must resort to Monte Carlo algorithms. The classic approach that incorporates the sequential nature of the data is given by the particle filtering algorithm. Particle filtering approximates the filtering density using sequential importance sampling. We instead focus on the following recursion.

$$p(x_t | y_{1:t}) = \int p(x_{0:t} | y_{1:t})d_{x_0:t-1}$$
$$=\frac{p(y_t | x_t)}{\int p(y_t|x_t)p(x_t | y_{1:t-1})dx_t}p(x_t | y_{1:t-1})$$

$$\propto p(y_t|x_t)p(x_t | y_{1:t-1})$$
$$\propto p(y_t|x_t)p(x_t | y_{1:t-1})$$
$$\propto p(y_t|x_t)\int_{x_{t-1}}p(x_t,x_{t-1} | y_{1:t-1})d_{x_{t-1}}$$

$$\propto p(y_t|x_t)\int_{x_{t-1}}p(x_t |x_{t-1} )p(x_{t-1}| y_{1:t-1})d_{x_{t-1}}$$

which we can approximate using svgd as
$$\approx p(y_t|x_t) \frac{1}{n}\sum_{i=1}^n p(x_t | x_{t-1}^{(i)})$$
We can now estimate $p(x_{t+1}|y_{1:t+1})$ using the same algebra as above.
(proof in apendix A)

\subsection*{Locally Level Gaussian Noise Model}
In order to demonstrate that the approximation is reasonable we evaluate the predictive accuracy under an analytically tractable model, the locally level Gaussian model. This model takes the form
$$X_t \sim N(X_{t-1},\sigma_1^2)$$
$$Y_t \sim N(X_t, \sigma_2^2)$$

\begin{figure}[!tbp]
\centering
\subfloat[SSVGD]{\includegraphics[scale=.25]{/home/gcgibson/ssvgd/manuscript/ssvgd_locally_level.pdf}\label{fig:f1}}
  \hfill
  \subfloat[PF]{\includegraphics[scale=.25]{/home/gcgibson/ssvgd/manuscript/pf_locally_level.pdf}
\label{fig:f2}}
  \caption{Comparison of locally level Gaussian model}
\end{figure}

\subsection*{Poisson Observation Model With Seasonal State-Space Dynamics}

In order to evaluate the performance on more involved dynamics we consider the following state-space model.
$$\begin{pmatrix} X_{t,1} \\ X_{t,2} \end{pmatrix} = \begin{pmatrix} cos(2\pi/s) & sin(2\pi/s) \\ -sin(2\pi/s) & cos(2\pi/s) \end{pmatrix} \begin{pmatrix} X_{t-1,1} \\ X_{t-1,2} \end{pmatrix} $$
$$Y_t \sim Pois(e^{X_{t,1}})$$

\begin{figure}[!tbp]
\centering
\subfloat[SSVGD]{\includegraphics[scale=.25]{/home/gcgibson/ssvgd/manuscript/ssvgd_seasonal.pdf}\label{fig:f1}}
  \hfill
  \subfloat[PF]{\includegraphics[scale=.25]{/home/gcgibson/ssvgd/manuscript/pf_seasonal.pdf}
\label{fig:f2}}
  \caption{Comparison of seasonal Poisson model}
\end{figure}

\subsection*{Divergent Particle Filter}

We next investigate the ability of SSVGD to perform in the presence of poor initialization. This is a well known issue with current particle filter implementations: starting far from a plausible value of $x_0$ forces all particles to receive weight $0$ under the likelihood, leading to a degenerate filtering distribution. However, under SSVGD, we can simply increase the number of iterations, allowing for arbitrarily poor starting points. Standard particle filtering algorithms use effective sample size as a measure of degeneracy. This is commonly defined as $$S^{pf}_{eff} = \frac{1}{\sum_i (w_t^i)^2}$$. The common rule of thumb is to not allow this quantity to drop below 50. The natural translation of this metric into particle filtering is compute the same metric based on the samples obtained by SSVGD.

\subsection*{Results}
Standard particle filtering algorithms use effective sample size as a measure of degeneracy. This is commonly defined as $$S_{eff} = \frac{1}{\sum_i (w_i)^2}$$. The common rule of thumb is to not allow this quantity to fall below 50. Indeed, software implementations such as Biips throws an error if the number of effective particles falls below 50. We compute the effective sample size in an analogous way to the particle filter, where $w_i$ is defined as in the SIR particle filter.

\subsection*{Discussion}

\cite{liu_stein_2016-4}

\printbibliography

\end{document}


\documentclass[10pt]{article}
\usepackage{amsmath}

\begin{document}
\section{Inroduction}
 [ ... ]
\section{Objects types for Extension of Parser}

 We describe objects which we want to put in an extended version of Benchmark file format in the following table. The first column lists the nonterminal symbol. The second column lists grammar rules where several alternative choices are listed below each other. The third column gives a description of the object.

\begin{tabular}{|c|c|c|}  \hline Type & syntax & description  \\ \hline
\hline\hline
Circle\_2 & Circle\_2 (Point\_2,Rational) & Squered radius can be rational\\
\hline
CircularPoint\_2 &  CircularPoint\_2(Point\_2)     &\\
              &  CircularPoint\_2(AlgebraicReal,&\\
	      &  AlgebraicReal) 	     &\\
\hline
 CircularArc\_2  &  CircularArc\_2(Circle\_2) &  Constructs an arc from a full circle. \\
		 &CircularArc\_2(Circle\_2,	  &Circular\_arc\_2(Circle\_2 c,\\
		 &CircularPoint\_2,		  &CircularPoint p1,  \\
		 &CircularPoint\_2)		  &CircularPoint p2);Constructthe\\
		 &				  &linesegment supported by c, thatis \\
		 &				  &oriented counterclockwise, whose \\
		 &				  &source is p1 and whose target is p2.\\
		 &				  &Precondition: p1 and p2 lie on c.\\
	         &CircularArc\_2(Point\_2,      &Circular\_arc\_2(begin, end, bulge).\\
		 &Point\_2,			  &\\
		 &Rational) 			  &\\
\hline
 LineArc\_2  & LineArc\_2(LineSegment)        &\\
	       &  LineArc\_2(CircularPoint,	  &\\
	       &  CircularPoint)	          &\\
 	       & LineArc\_2(Point\_2, 	  &\\
	       &  Point\_2),          	          &\\

\hline
\end{tabular}

\section{Extention of the Parser}
  In following we describe necessary changes to add our new tokens and rules to the parser. First, we describe new Benchmark Visitor functions. Second, we explain how to make changes in Parser source to make possible parsing our new objects.
\subsection{New Benchmark Visitors functions}

In the following table are listed functions that do not exist in the Benchmark\_visitor class and must be added . The statements in curly braces \{...\} are function calls to the visitor. There are always a pair of functions that enclose the parsing parameters.
\\
\begin{tabular}{|c|c|}  \hline Object & grammar rule with visitor function  \\ \hline
\hline\hline
Circle\_2 &Circle\_2\{begin\_circle\_2();\}\\
          &(Point\_2,Rational)\\
 	  &\{end\_circle\_2();\}\\
\hline
CircularPoint\_2 &CircularPoint\_2\{begin\_CircularPoint\_2();\}\\
		      &(Point\_2)\\
		      &\{end\_circular\_CircularPoint\_2();\}\\
		      &CircularPoint\_2\{begin\_CircularPoint\_2();\}\\
		      &(AlgebraicReal,AlgebraicReal)\\
		      &\{end\_circular\_CircularPoint\_2();\}\\

\hline

 CircularArc\_2    & CircularArc\_2 \{begin\_CircularArc\_2();\}\\
      		   &(Circle\_2)\\
                   &\{end\_CircularArc\_2();\}\\
		   & CircularArc\_2 \{begin\_CircularArc\_2();\}\\
      		   &(Circle\_2,CircularPoint\_2,CircularPoint\_2)\\
                   &\{end\_CircularArc\_2();\}\\
		   & CircularArc\_2\{begin\_CircularArc\_2();\}\\
      		   &(Point\_2,Point\_2,Rational)\\
                   &\{end\_CircularArc\_2();\}\\

\hline

LineArc\_2  &LineArc\_2\{begin\_LineArc\_2();\}\\
            &(LineSegment)\\
            &\{end\_LineArc\_2();\}\\\
	    &LineArc\_2\{begin\_LineArc\_2();\}\\
            &(CircularPoint\_2,CircularPoint\_2)\\
            &\{end\_LineArc\_2();\}\\
	    &LineArc\_2\{begin\_LineArc\_2();\}\\
            &(Point\_2,Point\_2)\\
            &\{end\_LineArc\_2();\}\\
 \hline
\end{tabular}

\subsection{Extending of Parser by new types}
Here we describe how to add new tokens and rules to the parser.
\subsubsection{Extend the Scanner in benchmark\_lexer.l}
First thing that is needed to extend parser is to put new tokens in section with Token in coments. It is looks  like this:

\begin{verbatim}
 /* Tokens    */
 /* --------- */
"FileFormat"                    { return FileFormat;}
"BenchmarkName"                 { return BenchmarkName; }
.......
\end{verbatim}

In the end of this section add these lines:

\begin{verbatim}
"CircularArc_2"              { return CircularArc_2;}
"LineArc_2"                    { return LineArc_2;}
"CircularPoint_2"          {return CircularPoint_2;}
\end{verbatim}

The left string is representation in file format, the right word is its indentifier in the program code.
\subsubsection{Extended the Parser in benchmark\_parser.y}
 In a section with words Structure tokens in coments, which looks like this:

\begin{verbatim}
/* Structure tokens */
/* ---------------- */
%token FileFormat
%token BenchmarkName
%token Classification
....
\end{verbatim}
 add anywhere new lines with new tokens:
\begin{verbatim}
%token CircularArc_2
%token LineArc_2
%token CircularPoint_2

\end{verbatim}

Now go to Grammar section and add new rules. In the and of stmt block add new lines with rules:

\begin{verbatim}
  | CircularPoint_2                 {visitor->begin_CircularPoint_2();}
             '(' circular_arc_point ')'
                                        {visitor->end_CircularPoint_2();}
  | LineArc_2                          {visitor->begin_LineArc_2();}
              '(' line_arc_2 ')'
                                        {visitor->end_LineArc_2();}
  | CircularArc_2                      {visitor->begin_CircularArc_2();}
               '('circular_arc_2 ')'
                                        { visitor->end_CircularArc_2();}
\end{verbatim}

And after stmt block add new lines with definition for circular\_arc\_point ; line\_arc\_2 ; circular\_arc\_2 :

\begin{verbatim}
circular_arc_point:
error_rules{}
 | point_2
 | AlgebraicReal, AlgebraicReal
;
line_arc_2:
error_rules {}
 | LineSegment
 | point_2 ',' point_2
 | CircularPoint_2 '(' circular_arc_point ')'
       ',' CircularPoint_2 '(' circular_arc_point ')'
;
circular_arc_2:
error_rules {}
 | Circle_2 '(' circle ')'
 | Circle_2 '(' circle ')' ',' CircularPoint_2 '(' circular_arc_point ')'
       ',' CircularPoint_2 '(' circular_arc_point ')'
 | point_2 ',' point_2 ',' rational
;
\end{verbatim}

For add new rule for circle\_2 (Point\_2, Rational) change in stmt block this lines :

\begin{verbatim}
 | Circle_2                      { visitor->begin_circle_2(); }
        '(' point_2 ',' INTEGER  { visitor->accept_integer( $6); } ')'
                                 { visitor->end_circle_2(); }
\end{verbatim}

By this :

\begin{verbatim}
 | Circle_2      		 { visitor->begin_circle_2(); }
       '(' circle_2 ')'   	 { visitor->end_circle_2(); }
\end{verbatim}

And add after stmt block this lines:

\begin{verbatim}
circle_2:
error_rules {}
|  point_2 ',' rational
|  point_2 ',' INTEGER  { visitor->accept_integer($3); }
\end{verbatim}

\subsection{extend the Visitor in benchmark\_visitor.h}
All what is needed for extending the Visitor is to add new virtual functions. It can be easyly made by addition
 of these lines in end of definition of benchmark\_visitor class :

\begin{verbatim}
    virtual void begin_CircularArc_2(){
        tnh("begin_CircularArc_2");
        }
    virtual void end_CircularArc_2(){
        tnh("end_CircularArc_2");
        }
   virtual void begin_LineArc_2(){
        tnh("begin_LineArc_2");
        }
    virtual void end_LineArc_2(){
        tnh("end_LineArc_2");
        }
   virtual void begin_CircularPoint_2(){
        tnh("begin_CircularPoint_2");
        }
    virtual void end_CircularPoint_2(){
        tnh("end_CircularPoint_2");
        }
\end{verbatim}

Congratulation! Now you have extended vertion of Parser of Benchmark File format.
\end{document}


\documentclass{article}

\usepackage[main=english,vietnamese]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[sexy]{evan}
\usepackage{matchsticks}
\usepackage{wrapfig}
\usepackage{listings}

\title{The Power of Mathematical Reasoning - Part Two}
\author{Nghia Doan \& Catherine Doan}
\date{\today}

\begin{document}

\maketitle

\section*{Casework}

Sometimes, when the problem at hand is more complicated,
looking at all possible cases, or caseworking, can help to find the correct answer.

\begin{example*}[Who stole what?]
    \label{example:pi-2022-4-p8}
    Father was not happy when he heard that Mother could not make his favourite cake because butter, eggs and milk all were stolen.
    Mother told him that she saw Chipmunk, Groundhog, and Sparrow sneaking out of the kitchen.
    Everyone was carrying something, and it was not clear who was carrying what.
    After a brief investigation all stolen ingredients were found at the places of Chipmunk, Groundhog, and Sparrow.
    Here were what they said,
    \begin{itemize}[topsep=0pt, partopsep=0pt, itemsep=0pt]
        \ii Chipmunk: Groundhog stole the butter.
        \ii Groundhog: Sparrow stole the eggs.
        \ii Sparrow: I stole the milk.
    \end{itemize}
    As it happened, \textit{the one, who stole the butter, told the truth} and \textit{the one, who stole the eggs, lied.}

    Who stole what?
\end{example*}

\begin{soln} \nameref{example:pi-2022-4-p8}
    Let's try casework on \textit{who stole the butter.}
    \begin{itemize}[topsep=0pt, partopsep=0pt, itemsep=0pt]
        \ii \textit{Case 1:} Assume that Sparrow have stolen the butter.
        Then she would told the truth, but she said she stole the milk. So it was not possible.
        \ii \textit{Case 2:} If Chipmunk stole the butter, then what she said about Groundhog is true,
        thus Groundhog stole the butter, which is a contradiction.
        \ii \textit{Case 3:} Groundhog must have stolen the butter.
        Thus what Groundhog said was true, so Sparrow stole the eggs, therefore Chipmunk stole the milk.
    \end{itemize}
    The answer is \framebox{Groundhog stole the butter, Sparrow stole the eggs, and Chipmunk stole the milk.}
\end{soln}

\section*{Knights and Liars, Patients and Doctors, and other stories}

Classic stories have some twists. Inductive reasoning leads us to a general conclusion.
Deductive reasoning applies a general assumption to a specific case.

\begin{example*}[Who killed the dragon?]
    \label{example:pi-2022-4-p10}
    On the Island of Knights and Liars, there are two types of people:
    the knights who always tell the truth and the liars who always lie.

    Three mighty warriors live on the island.
    Their names are Albert, David, and Victor.
    Two of them are Liars, and one is a Knight.
    The friends keep their secrets so nobody know who was what.

    One of their great deeds was a battle with a terrible dragon
    that was terrorizing the students of the Math, Chess, and Codding Club.
    Not much is known about this battle except that the dragon was slayed by a Knight.
    In a recently discovered letter, Albert stated that Victor had slayed the dragon
    and David were merely watching.

    Who actually killed the dragon?
\end{example*}

\begin{soln} \nameref{example:pi-2022-4-p10}
    If Albert is a Knight, then Victor slayed the dragon.
    Because the dragon slayer was a Knight, this would make Victor a Knight,
    which is impossible because only one of them is a Knight.
    Therefore Albert is a Liar, which means that Victor did not kill the dragon.

    Thus, \framebox{David was the dragon-slayer.}
\end{soln}

\begin{example*}[Who were removed?]
    \label{example:pi-2022-4-p11}
    In the Mental Hospital of Geniuses there are only doctors and patients.
    Each of these inhabitants is sane or insane, but cannot be both.
    The sane people were a hundred percent accurate in all of their beliefs,
    and the insane people were a hundred percent inaccurate in all of their beliefs.

    After being in the hospital for a while, some patients got cured and became sane.
    Unfortunately some doctors lost their minds and became insane.
    The sane patients and insane doctors, if found, were removed from the hospital.

    One day, Inspector Melanie visited the hospital in order to determine who should be removed.
    She interviewed three people $A$, $B$, and $C$:
    \begin{itemize}[topsep=0pt, partopsep=0pt, itemsep=0pt]
        \ii $A$ said $B$ was insane.
        \ii $B$ said $A$ is a doctor.
        \ii $C$ said $B$ is a patient and $A$ is insane.
    \end{itemize}

    Did Inspector Melanie remove $A$, $B$, or both of them?
\end{example*}

\begin{soln} \nameref{example:pi-2022-4-p11}
    Suppose that $A$ was sane. Then, what $A$ said was true, so $B$ was insane, and therefore $B$'s belief that $A$ was a doctor
    was false, thus, $A$ is a sane patient and should be removed.
    $C$ said $A$ was insane, so $C$ was insane, thus $B$ was a doctor, thus $B$ should be removed as well.

    Now, if $A$ was insane, then $B$ was sane, and therefore $A$ was a insane doctor and should be removed.
    $C$ said $A$ was insane, so $C$ was sane, thus $B$ was patient, so $B$ should also be removed.

    Thus, \framebox{both $A$ and $B$ should be removed.}
\end{soln}

\section*{Exercises}

\begin{exercise*}[Which room has the tiger?]
    \label{exercise:pi-2022-4-p9}
    Karl was captured while sneaking into the Kingdom of the Hungry Tigers.
    He was lead in front of three rooms, each with a separate door marked with a sign,
    as shown below in \Cref{fig:pi-2022-4-p9}.
    \begin{figure}[h]
        \centering
        \begin{tabular}{|c|c|c|}
        \hline
        I & II & III \\
        Room III is empty & The tiger is in Room I & This room is empty \\ \hline
        \end{tabular}
        \caption{\nameref{exercise:pi-2022-4-p9}}
        \label{fig:pi-2022-4-p9}
    \end{figure}
    A large treasure chest was placed in one of the rooms and a hungry tiger in another.
    A beautiful girl told him that,
    \begin{enumerate}[topsep=0pt, partopsep=0pt, itemsep=0pt]
        \ii The sign on the door of the room containing the treasure was true,
        \ii The sign on the door of the room with the tiger was false, and
        \ii The sign on the door of the empty room could be either true or false.
        \ii If he opens the room with the tiger, he will be eaten.
        \ii If he opens the room with the chest, they will set him free and give him the chest.
    \end{enumerate}

    Which room has the tiger?
\end{exercise*}

\begin{soln} \nameref{exercise:pi-2022-4-p9}
    Instead of looking for the tiger, let's \textit{look for the treasure, because the sign on its room is true.}

    It cannot be in room II, because then according to the sign, room I has the tiger, room III is empty.
    Thus, the sign on room I is true, which contradicts that the sign on the room with the tiger is false.

    It cannot be in room III, because the according to the sign, room III is empty.
    Therefore the treasure is in room I, room III is empty, and the tiger is in room II.
\end{soln}

\begin{exercise*}[Was Sam awake?]
    \label{exercise:pi-2022-4-p12}
    Whenever Rob the bandit is asleep, everything he believes is wrong.
    In other words, everything Rob believes in his sleep is false.
    On the other hand, everything he believes while he is awake is true.
    Last night at $10$ o'clock sharp,
    while guarding the newly captured treasure chest,
    Rob believed that he and Sam the thug were asleep at that time.

    Was Sam asleep or awake at that time?
\end{exercise*}

\begin{soln} \nameref{exercise:pi-2022-4-p12}
    If Rob the bandit was awake at the time, he could not have had \textit{the false belief
    that both he and Sam the thug were asleep.}
    Therefore he was asleep. This means that his belief was false,
    so it is not true that both were asleep.
    Therefore Sam was awake.
\end{soln}

\end{document}


\chapter{Parameter Estimation}\label{ch:parameterEstimation}
In this chapter, we discuss our approach toward parameter estimation.
Specifically, we aim to address the problem of maximum likelihood.

\section{Intractable Likelihood Functions}\label{sec:intractableLikelihoodFunctions}
\begin{figure}[t]
    \centering{\input{include/floats/likelihood-general.tex}}
    \caption{General figure depicting a smooth likelihood distribution (blue).
    The maximum likelihood point of this distribution is the intersection of the black dashed line and the blue line.
    }\label{fig:likelihoodGeneral}
\end{figure}

We denote $\theta$ to be a set of parameters values, $\Theta$ to be the space all of our parameters values reside in,
$\mathcal{D}$ to be a collection of observed data, and $\mathcal{D}'$ to
be a collection of generated data.
The \emph{likelihood} of some parameter values $\theta \in \Theta$ is the joint probability that $\theta$ produces
some observed data $\mathcal{D}$.
Let $\mathcal{M},\mathcal{V} : \theta \mapsto \mathcal{D}'$ define a function that maps parameter values $\theta$ and random variables
$\mathcal{V}$ to generated data $\mathcal{D}'$.
Given that $\mathcal{V}$ is random, different $\mathcal{D}'$ may be returned for the same parameter values
$\theta$.
%In other words, $\mathcal{M}$ represents some stochastic simulator model which produces some random data.
Given \emph{discrete and countable} observations $\mathcal{D}$, the likelihood of parameter values $\theta \in \Theta$
is the probability that our generated data equals our observed data~\cite{lintusaariFundamentalsRecentDevelopments2017}.
\begin{equation}\label{eq:likelihood1}
    \mathcal{L}(\theta) = \Pr(\mathcal{D} = \mathcal{M}(\theta))
\end{equation}

One technique to calculate a maximum likelihood for our parameter values involves finding the critical points of
$\mathcal{L}$ (where $\frac{d\mathcal{L}}{d\theta} = 0$) and choosing the point $\hat{\theta}$ with the largest value
of $\mathcal{L}$.
In~\autoref{fig:likelihoodGeneral}, the maximum of such a likelihood is displayed at the intersection of the blue and
black dashed lines.
There are however, several problems with this approach:
\begin{enumerate}
    \item A large range $\mathcal{D}'$ for simulator $\mathcal{M}$ indicates that the frequency of exact observed --
        generated matches will be too low to make inferences.
    \item This assumes that we can explicitly express $\mathcal{L}$.
        For simulator based $\mathcal{M}$ like ours, this is not trivial to do.
\end{enumerate}
Consequently, we must look into other approaches to \textit{infer} $\mathcal{L}$.
The two problems this chapter aims to address are (a) how to efficiently compute $\mathcal{L}$ for a single $\theta$
and (b) how to infer $\mathcal{L}$ for all $\theta$.

\section{Approximate Bayesian Computation}\label{sec:approximateBayesianComputation}
In this section, we discuss an approximate method to compute the likelihood $\mathcal{L}$ for some parameter values
$\theta$.

As previously mentioned, to find $\mathcal{L}$ is to find the joint probability that our model and parameters produce
the observed data.
We expand~\autoref{eq:likelihood1} to make this explicit for $r$ sets of observed data
in~\autoref{eq:jointProbabilityLikelihood}.
$\theta$ remains the same, however the randomness of $\mathcal{V}$ may result in different probabilities.
For brevity, $\mathcal{V}$ is implicit in $\mathcal{M}$ from this point forward.
\begin{equation}\label{eq:jointProbabilityLikelihood}
    \mathcal{L}(\theta) = \prod_{i=1}^{r} \Pr\left(\mathcal{M}(\theta) = \mathcal{D}_i \right)
\end{equation}

Let $\mathcal{D}$ represent the set of observed samples from the Columbian populace.
How do we determine the probability of our model generating some $\mathcal{D}_i \in \mathcal{D}$ to
determine $\mathcal{L}(\theta)$?
Here, we take a frequentist approach and perform the following steps:
\begin{enumerate}
    \item Run our simulator once to get $\mathcal{D}'_1$.
    \item Check if $\mathcal{D}'_1$ matches $\mathcal{D}_1$.
    \item Repeat steps 1 and 2 some number of times $T_1$, for different simulated samples but the same
        observed sample.
        We define $\Pr\left( \mathcal{M}(\theta) = \mathcal{D}_1 \right)$ as the frequency of exact matches.
    \item Repeat step 3 for all observed samples to get $\Pr\left( \mathcal{M}(\theta) = \mathcal{D}_2 \right)$,
        \ldots, $\Pr\left( \mathcal{M}(\theta) = \mathcal{D}_r \right)$.
    \item To find the $\mathcal{L}$ is to multiply all $r$ probabilities together.
\end{enumerate}

This approach seems simple enough, but there exists one caveat: the frequency of exact matches is too low to interpret
anything meaningful.
The microsatellite repeat length set $\mathbb{M}$ consists of roughly 30 elements, meaning that roughly 30 dimensions
must exactly match.
In addition to this, each frequency resides in some large set whose elements are between $[0, 1]$.
The solution we propose here is a technique known as \emph{Approximate Bayesian Computation}, or ABC for short.
ABC has two parts: the use of \emph{approximate} matches and the use of summary
statistics~\cite{lintusaariFundamentalsRecentDevelopments2017}.
In the following sections, I discuss how we define approximate, what summary statistics are, and why we are not using
them for this problem.

\begin{figure}[t]
    \centering{\input{include/floats/approximate-likelihood.tex}}
    \caption{General figure depicting a true likelihood surface (blue) and an approximate surface (red).
    The true likelihood may not be found in a reasonable amount time, whereas the approximate likelihood is wider but
    taller (making it more tractable, but less defined).
    }\label{fig:approximateLikelihood}
\end{figure}

\subsection{Approximate Matches: $\epsilon$}\label{subsec:approximateMatches}
Let us dissect $\mathcal{D}$ and $\mathcal{D}'$ further.
A given $\mathcal{D}_i \in \mathcal{D}$ and $\mathcal{D}'_i \in \mathcal{D}'$ define $| \mathbb{M} |$-sized tuples,
whose values exist in $[0, 1]$.
To compare a given $\mathcal{D}_i$ and $\mathcal{D}'_i$ is to iterate through each element (repeat unit) in both
tuples and measure their proximity to each other.
Let $\delta : \mathcal{D}_i,\mathcal{D}'_i \mapsto [0, 1]$ represent some function that accepts the observed and
generated sample, and outputs some distance between 0 and 1.
The comparison between our observed and generated samples is given by $\delta(\mathcal{D}_i, \mathcal{D}'_i)$.

We were only able to explore one $\delta$ function: the angular (or Cosine) distance.
The angular distance treats $\mathcal{D}_i$ and $\mathcal{D}'_i$ as $| \mathbb{M} |$-dimensional vectors
and aims to quantify some difference between the two.
An output of 0 indicates that both samples are completely similar, while an output of 1 indicates that two vectors
are maximally dissimilar (orthogonal).
The angular distance $\delta_A$ is defined below~\cite{chaComprehensiveSurveyDistance2007a}:
\begin{equation}
    \delta_A(\mathcal{D}_i, \mathcal{D}'_i) = \frac{2}{\pi} \arccos \left(
    \frac{\sum_{\ell=\kappa}^{\Omega} \mathcal{D}_i[\ell] \cdot \mathcal{D}'_i[\ell]}{
        \sqrt{\sum_{\ell=\kappa}^{\Omega} \left(\mathcal{D}_i[\ell]\right)^2} \cdot
        \sqrt{\sum_{\ell=\kappa}^{\Omega} \left(\mathcal{D}'_i[\ell]\right)^2}
    } \right)
\end{equation}
where $\mathcal{D}_i[\ell]$ and $\mathcal{D}'_i[\ell]$ represent the frequency of repeat length $\ell$ for the observed
and generated samples respectively.

With some distance is quantified, the next step is defining what ``approximate'' means.
According to ABC, two samples $\mathcal{D}_i$ and $\mathcal{D}'_i$ are approximate matches if their distance falls below
some threshold $\epsilon \in [0, 1]$~\cite{marjoramMarkovChainMonte2003}:
\begin{equation}
    \left(\delta(\mathcal{D}_i, \mathcal{D}'_i) < \epsilon \right) \Leftrightarrow
    \left(\mathcal{D}_i \text { and } \mathcal{D}'_i
    \text{ are approximate matches} \right)
\end{equation}
By increasing $\epsilon$, the frequency of exact observed -- generated matches increases as well.
%By making this problem more tractable though, we increase the noise associated with drawing from $\mathcal{L}$.
This results in a flatter curve, as seen in~\autoref{fig:approximateLikelihood}.

The next question that follows is ``How do we know which $\epsilon$ to use?''
If $\epsilon$ is too small, the problem becomes intractable.
If $\epsilon$ is too large, we draw values that are not representative of the original distribution.
There is no clear answer to this question, and Lintusaari et.\ al.\ states this choice is typically made by
experimenting with different $(\mathcal{D}, \theta)$ pairs~\cite{lintusaariFundamentalsRecentDevelopments2017}.
We define our threshold $\epsilon$ as a \emph{hyperparameter}, a parameter we must specify and often experiment with)
to find the parameters of interest $\theta$.

\subsection{Dimension Reduction: Summary Statistics}\label{subsec:dimensionReductionSummaryStatistics}
An alternative to using a distance function $\delta$ that deals with $| \mathbb{M} |$-dimensional tuples is to use a
function that reduces, or \emph{summarizes} the data into two points $\bar{\mathcal{D}}, \bar{\mathcal{D}'}$ of lower
dimensionality and finds a distance between both $\bar{\mathcal{D}}, \bar{\mathcal{D}'}$.
We specify a distance function $\delta_S$ that performs this transformation using functions
$h : \mathcal{D}_i \mapsto \bar{\mathcal{D}_i}$ and $h' : \mathcal{D}'_i \mapsto \bar{\mathcal{D}'_i}$ as such:
\begin{equation}
    \bar{\delta_S}(\mathcal{D}_i, \mathcal{D}'_i)  = \bar{\delta}(h(\mathcal{D}_i), h'(\mathcal{D}'_i))
\end{equation}
A common choice for $h, h'$ is the mean or median.
For us, it may make sense to use the focal unit computation $\hat{\ell}$ as our summary statistic.

Using summary statistics avoids the curse of dimensionality (see~\cite{bellmanDynamicProgramming2013}) for high
dimension distance functions, but this adds yet another item we must specify: ``Which summary statistic is the best?''.
If we summarize our data wrong, we again run into the problem of drawing values that do not represent our original
distribution.
We ran several trials without reducing our dimensionality and have not run into any problems thus far.
To reduce noise, we are only using the angular distance $\delta_A$ for $| \mathbb{M} |$-dimensional vectors.

\section{Markov Chain Monte Carlo}\label{sec:markovChainMonteCarlo}
In this section, we discuss the Markov Chain Monte Carlo (MCMC) approach to approximating a likelihood function.

\begin{figure}[t]
    \centering{\input{include/floats/likelihood-mcmc.tex}}
    \caption{General figure depicting the random walk of Metropolis sampler around some surface poportional to our
    likelihood (the posterior).
    We start at initial state $\theta^{(1)}$.
    We accept $\theta^{(2)}$ and $\theta^{(3)}$ which leads to regions of higher likelihood but later accept
    $\theta^{(4)}$, a less likely point due to the randomness of $\mathcal{V}$.
    }\label{fig:metropolisAlgorithm}
\end{figure}

\subsection{Monte Carlo}\label{subsec:monteCarlo}
In~\autoref{sec:approximateBayesianComputation}, we explored how to determine the likelihood of a single point $\theta$.
We are now interested in the most likely $\theta$ out of all possible parameter values $\Theta$.
We considered a naive approach to determining the most likely point $\hat{\theta}$
in~\autoref{sec:intractableLikelihoodFunctions}, which involved determining the derivative of some function we can
explicitly express.
Given that we cannot express our function as such, this is not an option.
The solution Monte Carlo algorithms propose is choosing $\theta$ randomly and select the most likely $\theta$ out of
all runs.

Let $p$ define a probability distribution that determines how we draw $\theta$.
$p$ is more commonly known as a \emph{prior distribution}, and allows us to insert any prior beliefs we have about our
likelihood before finding $\mathcal{L}(\theta)$ itself.
In Bayesian inference, the characterization of the uncertainty of some $\theta$ given observations $\mathcal{D}$ is
given by another distribution known as the
\emph{posterior distribution}~\cite{lintusaariFundamentalsRecentDevelopments2017}:
\begin{equation}
    \Pr(\theta \mid \mathcal{D}) \propto \mathcal{L}(\theta) p(\theta)
\end{equation}
According to Baye's law, the posterior is proportional to likelihood function we are trying to find.
If we can explicitly express our posterior, then the $\hat{\theta}$ that maximizes $\Pr(\theta \mid \mathcal{D})$ also
maximizes $\mathcal{L}(\theta)$.

\subsection{Markov Chains}\label{subsec:markovChainMonteCarlo}
With the Monte Carlo strategy, our general procedure now becomes:
\begin{enumerate}
    \item Draw $\theta_i$ from our prior $p(\theta)$.
    \item Determine the likelihood of this point $\mathcal{L}(\theta_i)$.
    \item Repeat until we have a representative set of samples.
    \item Fit our samples to a curve, and return the $\hat{\theta}$ that maximizes $\mathcal{L}(\theta)$.
\end{enumerate}
The main problem with this approach is our reliance on the prior.
A misinformed prior will produce samples that are not representative of the posterior.
As an example if $E(p(\theta)) = 500$ but our posterior is centered around $\theta = 1$, we will end up with a small or
nonexistent posterior.
\emph{Markov Chain Monte Carlo} methods solve this by sampling more often from regions of higher likelihood.

Markov Chain Monte Carlo methods work by constructing a Markov chain such that the posterior distribution is its
equilibrium distribution.
We start by defining a $\Theta$-sized vector $Y$, indexed by all distinct $\theta \in \Theta$ and whose values represent
probabilities associated with each $\theta$.
$Y$ is said to be a distribution here.
Next we define a matrix $G$ of size $\Theta \times \Theta$, whose entries describe the probability of transitioning
from one $\theta$ (row) to another $\theta$ (column).
$G$ is known as a \emph{transition matrix}.
We are able to move from distribution $Y^{(i)}$ to $Y^{(i + 1)}$ using $G$:
\begin{equation}
    Y^{(i + 1)} = Y^{(i)} G
\end{equation}
$Y$ is said to be at \emph{equilibrium} if the following holds true for some transition matrix $G$:
\begin{equation}
    Y^{(i)} = Y^{(i)} G
\end{equation}
The goal of MCMC is to draw samples $X$ from $Y$ such that $Y$ represents our posterior $\Pr (\theta \mid \mathcal{D})$.
Let $X$ represent this \emph{chain} of states, or parameter values $\theta$, that satisfy the
conditions below to draw from such a distribution~\cite{hanadaMarkovChainMonte2018}:
\begin{enumerate}
    \item \emph{$X$ is a Markov chain}.
        The probability of obtaining $X^{(i)} \in X$ from $X^{(i - 1)} \in X$ does not depend on any other configuration
        $X^{(i - 2)}, X^{(i - 3)}, \ldots, X^{(1)}$ other than $X^{(i - 1)}$ itself.
    \item \emph{$X$ is irreducible}.
        This states that we are able to travel to all of $\Theta$ from any given $\theta$ in a finite number of
        transitions.
    \item \emph{$X$ is aperiodic for all configurations}.
        A state $\theta$ is aperiodic if there exists a $i$ such that for all $j \geq i$:
        \begin{equation}
            \Pr \left( X^{(j)} = \theta \mid X^{(1)} = \theta \right) > 0
        \end{equation}
    \item \emph{$X$ is positive recurrent}.
        The states that the expected number of transitions to move to back to the same state is finite.
\end{enumerate}
MCMC comprises a class of algorithms that are able to produce $X$ that satisfy these conditions.

\subsection{Metropolis Algorithm}\label{subsec:metropolisAlgorithm}
As per our last section, we want to generate some chain of states $X$ such that the given conditions are satisfied.
In this section, we describe the Metropolis algorithm-- a procedure that is able to generate a chain of states such that
these conditions above are met.
There are three main steps to the Metropolis algorithm:
\begin{enumerate}
    \item \emph{Proposal}: We define some function $g : \Theta,\mathbb{V} \rightarrow \Theta$ which generates a
        new and random $\theta_i$ given an old $\theta'$.
        This relates to the transition matrix $G$ from~\autoref{subsec:markovChainMonteCarlo}, and constructs different
        $G$ for different values of $\theta_i$.
        The Metropolis algorithm is a special case of the \emph{Metropolis-Hastings algorithm} in which this proposal is
        \emph{symmetric}.
        A symmetric proposal indicates that the probability of drawing our new value given our current value is equal to
        the probability of drawing our current value given our new value.
    \item \emph{Calculate}: We determine the acceptance ratio $\alpha$, which is a ratio of the proposed $\theta^{(i)}$
        to the old $\theta'$.
    \begin{equation}
        \alpha = \frac{\mathcal{L}(\theta_i)}{\mathcal{L}(\theta)}
    \end{equation}
    \item \emph{Accept}: We save $\theta_i$ and $\mathcal{L}(\theta_i)$ to our collection of states if and only if
        $\theta_i$ is more likely than the old $\theta'$ \emph{or} the ratio of proposed to old likelihoods is greater
        than some uniform random variable $U(0, 1)$.
        If this is not true, then we go back to step (1) until we have run $T_2$ iterations.
\end{enumerate}

\begin{algorithm}[t]
    \SetAlgoLined
    \DontPrintSemicolon
    \Fn{MetropolisSampler \ {$(T_2, \mathcal{L}, \theta^{(1)}, g)$}} {
        \KwIn{number of algorithm iterations $T_2$, likelihood function $\mathcal{L}$, initial state $\theta_1$,
        proposal function $g$}
        \KwOut{samples from our posterior distribution $\Pr(\theta \mid \mathcal{D})$}
        $X \gets \emptyset$, $\theta' \gets \theta^{(1)}$ \;
        \For{$i \gets 1$ \KwTo $T_2$}{
            $\theta^{(i)} \gets g(\theta')$ \;

            \If{$\mathcal{L}(\theta^{(i)}) \cdot \mathcal{L}(\theta')^{-1} \leq \ \sim U(0, 1)$}{
                $\theta' \gets \theta_i$, $X \gets X \cup \{ \theta^{(i)} \}$ \;
            }
        }

        \Return $X$ \;
    }
%    \textbf{end} \;
    \caption{The Metropolis algorithm, used to produce samples from a posterior distribution proportional to our
    likelihood.}
    \label{alg:metropolis}
\end{algorithm}

Note that we have introduced three new hyperparameters here: our initial Markov chain position $\theta^{(1)}$,
our proposal function $g$, and the number of Metropolis sampler iterations $T_2$.
If $\theta^{(1)}$ is nowhere near the regions of high likelihood, if $g$ is too tightly or loosely distributed, or if we
do not run our sampler for enough iterations, we say that our Markov chain has not \emph{converged}.
Nonconvergence means that we cannot interpret anything meaningful from $X$, making the selection of these
hyperparameters \emph{and} some convergence verification process critical.

\section{Maximum Likelihood Estimation}\label{sec:maximumLikelihoodEstimation}
In this section, we explore a high level view of our approach to maximum likelihood estimation.
Using the Metropolis sampler, we are able to get a collection of states $X$ from a distribution proportional to our
likelihood.
We now want to tie this back into our original question: ``Which parameter values $\theta \in \Theta$ are the most
likely to produce our observations $\mathcal{D}$?''.
Given states $X$ from our posterior, we determine this most likely point $\theta$ by (a) constructing histograms, (b)
fitting the histograms to the equation of some distribution, and (c) determining the mean of this distribution.

We start by constructing our histogram.
For this project, each $\theta$ represents a 2-tuple of $c$ and $d$.
We construct sets $C, D$ which consist of each $c$ and $d$ element for all $\theta \in X$:
\begin{align}
    C &= \{c \mid c \in \theta \land \theta \in X \} \\
    D &= \{d \mid d \in \theta \land \theta \in X \}
\end{align}
We now want to partition each set $C$ and $D$ sets into consecutive, non-overlapping intervals or \emph{bins}
$C^\star$ and $D^\star$ respectively.
The partitioning itself is governed by the boundaries of our results $[\min(C), \max(C)]$,
$[\min(D),\max(D)]$, and the \emph{bin widths} $b_c$ and $b_d$ for the $c$ and $d$ parameters respectively.
This gives us the number of bins:
\begin{equation}
    \begin{aligned}
        | C^\star | &= \left\lceil \frac{\max(C) - \min(C)}{b_c} \right\rceil \\
        | D^\star | &= \left\lceil \frac{\max(D) - \min(D)}{b_d} \right\rceil
    \end{aligned}
\end{equation}
We build our histogram for $c$ by constructing the function $w_c : [0, |C^\star |] \rightarrow [0, 1]$ that accepts
an integer that enumerates our bins and outputs the frequency of associated with that bin.
The end result must follow the property in~\autoref{eq:densityFunction} to ensure our histogram
represents some probability density function.
\begin{equation} \label{eq:densityFunction}
    \int_{i=C^\star} w(i) di = 1
\end{equation}

The next step is to fit our histogram $w_c$ to some known distribution.
We explored two distributions here: the normal distribution and the gamma distribution.
If we assume that our posterior for some $C$ is normally distributed, we can use the function below:
\begin{equation}\label{eq:normalDistribution}
    w_{cN}(c) = \frac{\exp(\frac{\left( \sfrac{(c - \mathit{loc})}{\mathit{scale}} \right)^2}{2} )}
    {\mathit{scale} \cdot \sqrt{2\pi}}
\end{equation}
To get the point of maximum likelihood point $\hat{c}$ using $w_{N}(c)$ is to obtain its mean.
For the distribution in~\autoref{eq:normalDistribution}, this is the $\mathit{loc}$ parameter with variance
$\mathit{scale}$.
If we instead assume our posterior for some $C$ is gamma distributed, we can use the function below:
\begin{equation}
    w_{c\Gamma}(c) = \frac{(x-\mathit{loc})^{a-1}\exp(-\frac{c-\mathit{loc}}{\mathit{scale}})}{\mathit{scale}^a
    \cdot \Gamma(a)}
\end{equation}
where $\mathit{loc}$ represents a horizontal shifting parameter, $\mathit{scale}$ represents the scaling parameter of
our distribution, and $a$ represents the gamma distribution \emph{shape} or skew parameter.
Again, the maximum likelihood $\hat{c}$ using this $w_\Gamma(c)$ is the mean.
For the distribution given above, this is equal to $a \cdot \mathit{scale} + \mathit{loc}$ with variance
$a \cdot \mathit{scale}^2$.
For both cases, these steps are then repeated for $D$ to obtain $\hat{d}$.


%\section{Physical Human Factors Report: Tristan Griffith}
\rhead{\today}
\begin{center}
{\large  Tristan Griffith}\\
\vspace{2mm}
{\large Dr. James Hubbard Jr.}
\noindent\rule{\textwidth}{2pt}
\end{center}
\setcounter{section}{1}

%\begin{wrapfigure}{r}{0.45\textwidth}
%\centering
%\includegraphics[scale=.3]{../../../figures/demo_map.png}
%\caption{Modal Heatmap for Subject 32}
%\end{wrapfigure}
\subsection{Introduction}
We inquire concerning the nature of traveling waves in the brain. Under this head there are three points of inquiry:
\begin{enumerate}
\item Whether the brain has traveling waves?
\item Whether fMRI waves are connected to EEG waves?
\item If traveling waves exist, are they relevant to clinical outcomes?
\end{enumerate}
\subsection{Whether the brain has traveling waves?}
\textbf{Keyword differences:} First, note that the notion of a traveling wave is different for neuroscience and engineering. Neuroscientists would denote any brain wave that is observable across the sensor locations as a traveling wave. Engineers reserve traveling wave for behavior which is not in phase across the spatial sensors. In phase behavior is called a standing wave, while out of phase is a traveling wave. Neuroscientists would call both traveling waves. Going forward, I will use traveling wave in the engineering sense, denoting standing waves where needed. \\
\textbf{Objection 1:} Prior work has shown repeated decoherence among spatially distributed recordings of brain activity. Theta oscillations in humans are postulated to have only local mechanisms \cite{doi:10.1152/jn.00409.2005}.
\begin{displayquote}
 We found that, whereas nearby gated sites $(<20 \textit{mm})$ were often but not always coherent, distant gated sites were almost never coherent. Our results imply that there are local mechanisms for the generation of cortical theta.
\end{displayquote}
\textbf{Objection 2:} While inter-electrode spatial correlations in the gamma band have been discovered in animals, the same was not found in humans \cite{MENON199689}.
\begin{displayquote}
The findings suggest that the surface diameters of domains of spatially correlated activity underlying perceptual categorization in human gamma band ECoG are limited to less than 2 cm and that the intermittent synchronization observed across separations of 1 cm and 1.4 cm is not solely due to volume conduction. Thus, if such gamma band spatial patterns exist in the human brain, no existing technology would be capable of measuring them at the scalp, and subdural electrode arrays for cortical surface recording would have to have spacings under 5 mm.
\end{displayquote}
\textbf{Objection 3:} Using statistical methods, EEG coherence was found to decline substantially in space across all frequency bands \cite{BULLOCK1995161}.
\begin{displayquote}
In both the subdural surface samples and those from temporal lobe depth electrode arrays coherent declines with distance between electrodes of the pair, on the average quite severely in millimeters. This is nearly the same for all frequency bands.
\end{displayquote}
\textbf{On the contrary,} it has been found most recently that when \textbf{phase} is considered as part of the spatial coherence, traveling and standing waves are observed across a broad spectrum for most subjects \cite{ZHANG20181269}.\\

I argue that, in each of the objections above, the possibility of complex traveling waves was ignored. In each of these studies, it was assumed that the spatial activity of the brain's electrical activity would be described by perfect sine and cosine waves in two dimensions. This excludes the possibility of damping in the oscillatory behavior of the electrical activity. Many mechanical systems have damping, so why should we exclude this possibility in the analysis of the brain? To this end, our output only modal analysis has shown significant spatial dependence when both proportional and non-proportional damping is considered. Unlike the objections above, the naiveté of our engineering first approach is a strength, because it does not exclude the possibility of complex eigenmodes. Further, studies \cite{doi:10.1152/jn.00409.2005} and \cite{BULLOCK1995161} argue that low correlation of the band power is sufficient evidence to exclude the possibility of spatial dependence in the activity of the brain. I argue that a single, simple statistical tool is not sufficient proof for such a broad claim. There is no consideration of phase or damping.  Ultimately, we discovered that 20\% of the eigenmodes are damped on average, with 50\% showing some out of phase behavior. At present this issue is \textbf{closed.}
\subsection{Whether fMRI waves are connected to EEG waves?}
\textbf{Objection 1:} Using band power and statistical tests, EEG and fMRI were found to be inversely correlated on average, but not significantly enough to report \cite{LAUFS20031463}:
\begin{displayquote}
A more general problem is that our current understanding of EEG and fMRI (or PET) signals does not allow us to extrapolate whether and, if so, how the oscillatory synchronization of electrical synaptic activity in the alpha band translates into hemodynamic signals. The mere fact that synaptic activity takes on the temporal structure of an oscillation does not mean that net synaptic activity changes over time, and the oscillation frequencies of physiological rhythms themselves are beyond the temporal resolution of hemodynamic signals.
\end{displayquote}
\textbf{Objection 2:} In a comprehensive survey, \cite{SALEKHADDADI2003110} reports that despite improvements in sensing technology, disparate studies considering many different hypotheses have been unable to realize a unified connection between fMRI and EEG. Questions even arise concerning the nature of spontaneous EEG (e.g. is the rest state actually a rest state?). Because it is difficult to define consistent operating conditions from subject to subject a connection between fMRI and EEG is non-trivia:
\begin{displayquote}
We have reviewed the existing literature on this topic and have explored both the theoretical and practical limitations of EEG/fMRI with specific emphasis on studying the generators of IEDs. We envisage that further characterization of the BOLD correlates of spontaneous EEG activity and the development of ever more sophisticated fMRI models will constitute a significant effort over the next few years.
\end{displayquote}
\textbf{Further,} A despite a great amount of effort, experimental and theoretical work has been unable to explain the link between EEG and BOLD signals, as discussed in \cite{10.3389/fneur.2013.00001}:
\begin{displayquote}
The most consensual evidence comes from the recording of electrical activity using micro-electrodes implanted in the cortex of (non-human) animals, simultaneously with fMRI, indicating that the BOLD signal reflects mostly slow, post-synaptic input activity measured by local field potentials (LFPs), rather than fast, spiking output activity measured by single/multi-unit activity (S/MUA; Logothetis et al., 2001). In humans, a growing number of simultaneous EEG-fMRI studies on healthy subjects as well as epilepsy patients have now been reported (Goldman et al., 2002; Laufs et al., 2003, 2006; Moosmann et al., 2003; de Munck et al., 2009), and biophysical models of the neurovascular coupling have been proposed (Riera et al., 2006, 2007). Overall, reports in the literature do not provide a clear picture of the link between EEG and BOLD signals. In particular, contradictory results have been presented regarding the dependency of BOLD changes on the EEG power and spectral profiles. These include, for example, positive and negative BOLD correlations with specific frequency band power changes in the human EEG (de Munck et al., 2009), BOLD decoupling from LFP power in mice (Ekstrom, 2010), and negative BOLD associated with large increases in LFP and MUA during seizures also in mice (Schridde et al., 2008). Rosa et al. (2010b) addressed this topic by comparing different models of the transfer function between EEG and BOLD signals, in the prediction of fMRI data, in a visual stimulation experiment with human healthy subjects. The models explored included the EEG total power (TP; Wan et al., 2006); linear combinations of the power from different frequency bands (Goense and Logothetis, 2008); and several variations of a heuristic model proposed by Kilner et al. (2005) in which BOLD changes are assumed to be proportional to the root mean square frequency (RMSF) of the EEG spectrum. The results obtained showed a clear superiority of the RMSF metrics in predicting the BOLD signal, when compared to power-weighted metrics.
\end{displayquote}
\textbf{At present,} I argue that our modal decomposition method offers a compelling spatial representation of the data which may be more easily compared with a BOLD time series. \textcolor{red}{I estimate it would take approximately 3 weeks to process a data set with EEG and fMRI signals in order to compare the modes.} We have seen some empirical evidence that the shapes are similar, but more work is needed to verify frequencies and mode shapes are significant. At present this issue is \textbf{\textcolor{red}{open}} in both our work and the broader literature.

\subsection{If traveling waves exist, are they relevant to clinical outcomes?}
\textbf{Objection 1:} \cite{Massimini6862} found that while a standing wave was present during sleep, there was not enough evidence to say if it was a function of the cognitive state or the natural resting state of the brain.
\begin{displayquote}
The pattern of origin and propagation of sleep slow oscillations is reproducible across nights and subjects and provides a blueprint of cortical excitability and connectivity. The orderly propagation of correlated activity along connected pathways may play a role in spike timing-dependent synaptic plasticity during sleep.
\end{displayquote}
\textbf{Objection 2:} \cite{Takahashi0} found that as in animal brains, there are standing waves in human brains that propagate 180\degree to each other during motor tasks. However, the same wave was observed in the ``rest" state.
\begin{displayquote}
This study shows that the two properties of propagating beta waves are present in MI of a tetraplegic human patient while he was instructed to perform an instruction delay center-out task using a cursor controlled by the chin. Moreover, we show that beta waves are sustained and have similar properties whether the subject was engaged in the task or at rest.
\end{displayquote}
\textbf{Objection 3:} While local bursts of gamma activity were found to generate standing alpha waves, they were not connected to a task as subjects were in the ``rest" state\cite{Bahramisharif18849}:
\begin{displayquote}
In short, we have demonstrated here that bursts of gamma activity propagate over neocortex and the propagating gamma bursts are locked to the phase of traveling alpha waves. Our findings suggest that not only do alpha oscillations serve to coordinate the gamma activity in time, but also in space. In future work to uncover the functional role of this phenomenon would be of great interest.
\end{displayquote}
\textbf{On the contrary,} it was found that standing waves are generated reliably during a memory task, and accordingly return to a baseline level a few hundred milliseconds after the stimulus has passed \cite{doi:10.1152/jn.00409.2005}:
\begin{displayquote}
We confirmed that these patterns were reliable by measuring the time course of mean traveling wave DC at the group level. Following cue onset, traveling waves in the temporal and frontal lobes showed increases in DC above baseline levels (Figure 4E). Inversely, traveling waves from occipitoparietal clusters showed decreased DC during this same period, which was significantly different from the DC increase in the frontal and temporal lobes. Because frontal and temporal regions specifically show increased DC following cue onset, it indicates that traveling waves in these areas move more consistently during memory retrieval.
\end{displayquote}
I argue that simply observing a consistent pattern of traveling and standing waves is insufficient to draw conclusions from. Using our modal decomposition technique, we should seek to find mathematical connections between certain modes and certain tasks. As with the fMRI comparison, this is something we can look at in the coming months that has not been resolved in the larger neuroscience community. At present this issue is \textbf{\textcolor{red}{open}} in both our work and the broader literature.

%\begin{displayquote}
%The class of monotone DNF expressions is learnable via an algorithm $B$ that uses $L=L(h,d)$ calls of examples and $dt$ calls of oracle, where $d$ is the degree of the DNF expression $f$ to be learnt and $t$ the number of variables.
%\end{displayquote}

%\begin{wrapfigure}{r}{0.55\textwidth}
%\centering
%\includegraphics[scale=.5]{../figures/complexity.png}
%\caption{The Error-Complexity Trade Off}
%\end{wrapfigure}


\chapter{parreset}

\section{Introduction}

An LPE may have parameters of which the values are not used anymore after a particular state.
If such parameters can have different values after that state, they continue to add states to the state space for each of those values -- \emph{without} adding any new behavior!

The \texttt{parreset} command tries to determine whether the value of a parameter is used by an LPE after a particular summand.
If this is the case, the parameter is said to be \emph{relevant} for that summand; otherwise, the summand can `reset' the parameter, meaning that it can be assigned a default value.

To determine the relevance of parameters, \texttt{parreset} analyzes the reachability of summands in a generalized, symbolic manner.
The \texttt{datareset} command, serving a similar purpose (see \ref{datareset}), does a control-flow analysis instead.

\section{Formal background}

\subsection{Possible successors} \label{possiblesuccessors}

Consider summands $s_\alpha$ and $s_\beta$, referencing their elements conform \ref{summandelements}.
Summand $s_\beta$ is said to be a \emph{possible successor} of $s_\alpha$ if the following expression \emph{could be} satisfiable:
\begin{align*}
g_\alpha \land {g_\beta}[v \rightarrow q(v) \;|\; v \in \varsof{g_\beta} \setminus P][p \rightarrow v_\alpha(p) \;|\; p \in P]
\end{align*}

where $q(v)$ is a bijective function that relates variable $v$ to a fresh variable.

\section{Algorithm}

The algorithm is a generalization of an existing algorithm \cite{van2009state}.
It consists of two phases.

During the first phase (the preparation phase), we determine all successors of each summand of the LPE using the equation from the previous section.

The second phase (the iteration phase) follows these steps:

\begin{enumerate}

\item For each summand $s_\alpha$ of the LPE, create a set $R_\alpha$ that contains all parameters of the LPE.
This means that, initially, we assume that all parameters of the LPE are used by one or more of the successors of $s_\alpha$; that is, \emph{relevant} to $s_\alpha$.

\item For each summand $s_\alpha$ of the LPE, set the value of $R_\alpha$ to $\bigcup\limits_{s_\beta \in S_\alpha}^{} r(s_\beta)$ where $S_\alpha$ is the set of all successors of $s_\alpha$ (as determined during the preparation phase) and where $r$ is the function
\begin{align*}
r(s_\beta) = \left( \text{vars}(g_\beta) \cup \bigcup\limits_{x \in R_\beta}^{} \text{vars}(v_\beta(x)) \right) \setminus C_\beta
\end{align*}

\item Repeat the previous step until the fixpoint of $R_\alpha$ is reached for each summand $s_\alpha$ of the LPE.

\item For each summand $s_\alpha$ and for all $p \in P \setminus R_\alpha$, change the expression $v_\alpha(p)$ (which defines the value of LPE parameter $p$ after the application of $s$) to $v_I(p)$, the value of $p$ in this initial state of the LPE.

\end{enumerate}

\section{Example}

Consider the following LPE:

\begin{lstlisting}
//Process definition:
PROCDEF example[A :: Int, B](x, y :: Int)
  = A ? i [[x==0]] >-> example[A, B](1, i)
  + A ? i [[x==1 && i==y]] >-> example[A, B](2, y)
  + B [[x==2]] >-> example[A, B](3, y)
  + B [[x==3]] >-> example[A, B](0, y)
  ;

//Initialization:
example[A, B](0, 0);
\end{lstlisting}

Let the summands be represented by $s_1$ from $s_4$ (from top to bottom).

Finding the successors of each summand is easy: each summand has exactly one successor, namely the next one, except in case of $s_4$, where the $s_1$ is the successor.

It is also obvious that $x$ will always be in $R_\alpha$ for each summand $s_\alpha$, because each summand $s_\alpha$ uses $x$ in its guard.

Process parameter $y$ will always be in $R_1$ because $y$ is used in the guard of $s_1$'s successor, $s_2$.
After a few iterations, however, $y$ is removed from $R_2$, $R_3$, and $R_4$.
This means that $y$ is assigned a default value in $s_2$, $s_3$, and $s_4$.
Choosing the initial value of $y$ as its default value gives

\begin{lstlisting}
//Process definition:
PROCDEF example[A :: Int, B](x, y :: Int)
  = A ? i [[x==0]] >-> example[A, B](1, i)
  + A ? i [[x==1 && i==y]] >-> example[A, B](2, 0)
  + B [[x==2]] >-> example[A, B](3, 0)
  + B [[x==3]] >-> example[A, B](0, 0)
  ;

//Initialization:
example[A, B](0, 0);
\end{lstlisting}

\section{Benchmark results}

The following durations were measured with a benchmark for several models:
\begin{itemize}
\item The average duration of \txs{} to make 500 steps in a model after it has been converted to LPE form;
\item The average duration of \txs{} to make 500 steps in a model after it has been converted to LPE form and after the \texttt{parreset} operation has been applied.
\end{itemize}

When plotting the second series of measurements against the first (see Figure~\ref{parreset-vs-lpe-only:fig}), it is easy to see that the impact is insignificant in most cases.

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=0.7\linewidth]{charts/parreset-vs-lpe-only}
\caption{Benchmark results: parreset vs LPE transformation}
\label{parreset-vs-lpe-only:fig}
\end{center}
\end{figure}


\subsection{Implementing Change Calculator in C} % (fold)
\label{sub:implementing_simple_change_in_c}

Section \ref{sec:using_these_concepts_storing_using_data} of this chapter introduced the `Change Calculator' program, and its design. Its implementation requires the definition of functions as well as procedures. These functions and procedures accepted parameters and use local variables.

This section of the chapter introduces the C syntax rules for implementing these concepts using the C language. The C implementation of the Change Calculator is shown in Listing \ref{lst:storing-data-c-simple-change}. To get support for pass by reference you need to use C++, an extended version of the C language. This means that the C version is an alternate design, with \texttt{Give Change} becoming a function so that it can return the new change value. The C++ implementation is shown in \sref{sub:implementing_change_calculator_using_cpp}.

\straightcode{\ccode{lst:storing-data-c-simple-change}{C code for the Change Calculator}{code/c/storing-using-data/simple-change.c}}

\mynote{
\begin{itemize}
  \item Save the C code in a file named \texttt{simple-change.c}.
  \item Compile this using \bashsnipet{gcc -o SimpleChange simple-change.c}.
  \item Run the resulting program using \bashsnipet{./SimpleChange}.
  \item Perform each of the Test Cases from Table \ref{tab:simple_change_test_data} and check that the output matches the expected values.
  \item Look over the code and examine how the Variables, Parameters, Constants, and Function are being used.
  \item The c-string parameter should be coded as \csnipet{const char *coin\_desc} to allow you to pass literal values to it.
  \item Notice how the indentation makes it easy to see where each Function and Procedure starts and ends. Always lay your code out so that it is easy to see its structure.
  \item See how the Function and Procedure are declared before they are used. This is important as the C compiler reads the code from the start, and must know about the artefacts before you use them.
\end{itemize}
}

% subsection implementing_simple_change_in_c (end)

\clearpage
\subsection{Implementing Change Calculator using C++} % (fold)
\label{sub:implementing_change_calculator_using_cpp}

C++ contains a number of extensions that can make programming in C easier. One of these extensions is the ability to use pass by reference. The code in \lref{lst:storing-data-cpp-simple-change} shows the C++ implementation of the Change Calculator. In this code \texttt{Give Change} is a procedure with the \texttt{change\_value} parameter being passed by reference.

\straightcode{\ccode{lst:storing-data-cpp-simple-change}{C++ code for the Change Calculator}{code/c/storing-using-data/simple-change.cpp}}

\mynote{
\begin{itemize}
  \item Save the C++ code in a file named \texttt{simple-change.cpp}.
  \item Compile this using \bashsnipet{g++ -o SimpleChange simple-change.cpp}.
  \item Run the resulting program using \bashsnipet{./SimpleChange}.
  \item Perform each of the Test Cases from Table \ref{tab:simple_change_test_data} and check that the output matches the expected values.
  \item Look over the code and examine how the Variables, Parameters, Constants, and Function are being used.
\end{itemize}
}

% subsection implementing_change_calculator_using_c_ (end)


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

\title{Weekly Report}
\author{Junior Team }
\date{June 2020}

\usepackage{natbib}
\usepackage{graphicx}

\begin{document}

\maketitle

\section*{IRB Data Analysis}
Once we had the IRB model set up and could optimize over $P_t$, $P_n$, and the maximum width, our goal was to begin to identify trends in the data.

\section{Normal and Tangential Impulses}
The first interesting correlation we found was between the tangential impulse ($P_t$) and the optimal patch width, which can also be interpreted as the moment applied due to the patch width.

\begin{figure}[h!]
\centering
\caption{Tangential Impulse vs Optimal Width}
\includegraphics[scale=0.2]{tanImpulse}
\label{fig:tanImpulse}
\end{figure}

\noindent In the figure above, the constraint $\mbox{width} \leq 1 \mbox{cm}$ was used for 1000 different impacts. The correlation coefficient between $P_t$ and width was $ -0.9283$. \\

\noindent  When examining normal impulse ($P_n$) we did not find a clear linear trend, however there seemed to be an impulse threshold below which the optimal width was only zero. From this, we hypothesized that perhaps, those cases to the left of the threshold were below a certain energy threshold, or were lower energy impacts. This would lead to a smaller increase in angular velocity after impact, and less energy in the restitution phase. As a consequence, a patch width which creates a moment and greatly increases the angular velocity ($\dot\theta$) would not be optimal.\\

\noindent To test this hypothesis, we plotted pre- and post-impact kinetic energy versus the optimal patch width. The plots seem to disprove the idea that there is any relationship between zero patch width being optimal and a lower energy collision.

\begin{figure}[ht]
    \caption{Kinetic Energy Analysis}
    \centering
    \begin{subfigure}[b]{0.45\linewidth}
        \includegraphics[scale=0.12]{preImpactEnergy.jpg}
        \caption{Pre Impact KE}
        \label{fig:preKE}
    \end{subfigure}
    \quad
    \begin{subfigure}[b]{0.45\linewidth}
       \includegraphics[scale=0.12]{postImpactEnergy.jpg}
        \caption{Post Impact KE}
        \label{fig:postKE}
    \end{subfigure}
\end{figure}

\noindent Additionally, we took a look at the correlation between the net moment and impulses generated from the impact. When inspecting the normal impulse, we found no correlation between the normal impulse and the net moment generated by the ellipse. This is expected, since the configuration of the ellipse as it contacts the surface can be varied greatly, so there should be no definite correlation if the trajectory of the ellipse is not meant to be uniform. \\

\noindent On the other hand, when inspecting the tangential impulse of the ellipse, we find an interesting scatter plot that illustrates a negative correlation between net moment and tangential impulse. Since we assume that the tangential impulse mostly consists of frictional forces and we know that friction tends to oppose motion, we would expect the tangential impulse to be negative when the ellipse has a positive rotation and vice versa. Hence the negative correlation which can be depicted in Fig \ref{fig:tanImpulse2}.

\begin{figure}[ht]
  \begin{subfigure}[b]{0.4\linewidth}
    \includegraphics[scale=0.35]{netMomentvsNormImpulse.jpg}
    \caption{Normal Impulse}
    \label{fig:normImpulse}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{0.4\linewidth}
    \includegraphics[scale=0.35]{netMomentvsTanImpulse.jpg}
    \caption{Tangential Impulse}
    \label{fig:tanImpulse2}
  \end{subfigure}
  \caption{Impulse vs Net Moment}
\end{figure}

\newpage
\section{Pre-Impact Angle}
The next thing we chose to explore was the relationship between the pre-impact angle ($\theta^+$) and the optimal width. After a plot with a clear trend whose shape resembled an X and Dr. Posa's recommendation, we adjusted the angle transformation to get a cleaner range of angles (wrapped from [$-\pi, \pi$]). We then found another interesting correlation, when the pre-impact angle was plotted with the optimal width, the curve resembled a sin curve.

\begin{figure}[h!]
\centering
\caption{Pre-Impact Angle vs. Optimal Width}
\includegraphics[scale=0.2]{preImpactAngle}
\label{fig:preAngle}
\end{figure}

\noindent The red curve Width $= \frac{1}{100}(sin(2\theta)+0.3)$ clearly correlates with the data. The next thing we checked was whether there was a similar relationship with angular velocity (either $\dot\theta^+$ or $\dot\theta^-$), but there appeared to be nothing. \\

\noindent Interestingly, when we plotted error vs. pre-impact angle for the AP Poisson model and the change in rotational velocity vs. pre-impact angle for the IRB model, the plots also followed a $sin(2\theta)$ trend. \\

\noindent We wanted to explore whether the width depended on the moment arms (Tangential moment arm: vertical distance from the contact point to the COM, normal moment arm: horizontal distance from the contact point to the COM). \\

\noindent The following figures were made without any sort of optimization or considering any impulses. These are just geometric relationships that occur because of the elliptical shape of the object. Whenever the optimal width graphs are mentioned, Figure \ref{fig:preAngle} of Optimal width vs Angle is referenced. \\

\noindent Figure \ref{fig:TanMomentArmVsAngle} shows the relation between the orientation of the ellipse and the tangential moment arm. It shows how that the optimal width is at its max when the tangential moment arm is at its minimum and vice versa, since the optimal width takes the form of a sine wave and the tangential moment arm takes the form of a flipped cosine wave. They both have the same frequency, y-offset, and scaling. The only difference is the amplitude.

\noindent Figure \ref{fig:NormMomentArmVsAngle} shows the relation between the orientation of the ellipse and the normal moment arm. It shows that the optimal width and the normal moment arm are \textbf{\textit{identical}} in every way, except for the y offset and the reflection of the sine graph of the normal moment arm on the x-axis. This means that there is a direct correlation between the horizontal distance between the contact point and the COM, and the optimal width to account for the rotational impulse.

\begin{figure}[ht]
  \begin{subfigure}[b]{0.4\linewidth}
    \includegraphics[scale=0.14]{TanMomentArmVsAngle.jpg}
    \caption{ Tangential Moment Arm}
    \label{fig:TanMomentArmVsAngle}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{0.4\linewidth}
    \includegraphics[scale=0.14]{NormMomentArmVsAngle.jpg}
    \caption{Normal Moment Arm}
    \label{fig:NormMomentArmVsAngle}
  \end{subfigure}
  \caption{Moment Arms vs Angle}
\end{figure}

\noindent These relations agree with our predictions and reason.

\section{Moment and Patch Size}
\noindent Initially, we investigated patch size by taking the absolute value of moment. With this, we would see a plot fairly symmetric about $x = 0$ which makes sense since extending the patch from either direction of the center of the contact point should theoretically yield moments equal in magnitude but opposite in sign. However, when we remove this restriction, we can see a linear relationship between net moment and width (Fig \ref{fig:momentPSize}). Dr.\ Posa believed that all of this was pointing towards the idea that error and net moment are correlated, and predicted moment is essentially off by a linear factor:
\begin{align}
    M_{actual} = k * M_{predicted}
\end{align}

\begin{figure}[h!]
\centering
\caption{Net Moment vs. Optimal Patch Size}
\includegraphics[scale=0.55]{momentPSize}
\label{fig:momentPSize}
\end{figure}

\begin{align}
    \mbox{Best Fit Line: } width = 10.06 * M_{net} - 0.0345
\end{align}
\begin{center}
    Where width and the net moment match the units from the axes in Fig \ref{fig:momentPSize}.
\end{center}

\newpage

\section{Clumping and Convexity}
When we were investigating different potential correlations we began to notice clumping around a patch width of 0 (Fig \ref{fig:tanImpulse}, Fig \ref{fig:preKE}, Fig \ref{fig:postKE}) when we capped the maximum width. For the optimal patch width to be around zero for a given trial when the width is capped below the optimal width, but then have a nonzero optimal width when the range is increased means our solutions were non-convex. This goes against expectations for this sort of problem.To look more closely into why the clumping was occurring, we made fixed width vs error plots for different trials. The shapes of the graphs however, did not give us much insight on why we found clumping, since they seemed to point towards a convex solution.

\begin{figure}[ht]
  \centering
  \caption{Set Width vs Error Plots for Individual Trials}
  \begin{subfigure}[b]{0.4\linewidth}
    \includegraphics[scale=0.4]{Nat1.jpg}
    \caption{Trial 8}
    \label{fig:cov1}
  \end{subfigure}
  \begin{subfigure}[b]{0.4\linewidth}
    \includegraphics[scale=0.4]{Nat2.jpg}
    \caption{Trial 31}
    \label{fig:cov2}
  \end{subfigure}
\end{figure}

\noindent This is something we will continue to investigate, but for now we will stick to not capping the width at the previously used $1cm$ since we know nearly all of the clumping can be avoided if the cap is raised just half a centimeter to $width_{max} = 1.5cm$.

\newpage

\section{AP Poisson and Wang Mason}
Another thing we did this week was see if we could replicate some of our findings from the IRB model in the two models we had previously worked on and whether we would see similar trends. For the Wang Mason model, we checked for a $x_1$ position we could apply the impulsive forces to minimize error that was within 30\% of it's original value. The plots involving tangential or normal impulse vs. moment matched nicely with those from the IRB model (Fig \ref{fig:normImpulse}, Fig \ref{fig:tanImpulse2}). \\

\noindent A similar approach was taking with the AP Poisson model, where the $x_1$ position was shifted to add an additional moment, also within 30\% of the original value. The tangential and normal impulse plots resembled both Wang and IRB but were not quite as similar. We did observe the same trend between error and pre-impact angle:

\begin{figure}[h!]
\centering
\caption{Error vs Pre-Impact Angle (AP Poisson)}
\includegraphics[scale=0.25]{andy1}
\label{fig:andy1}
\end{figure}

\noindent The figure shows how the normalized velocity error follows a similar $sin(2\theta)$ trend to what was observed in the IRB model.

\end{document}

Weekly Reports/Weekly Report 621/main.tex