\chapter{Conclusions and Recommendations}\label{chap:conclusions}
\section{Summary}
In this thesis we investigated new methods for computing the target photometric variables based on \textit{phase space ray tracing}. The aim was to understand how light propagates through non-imaging optical systems in order to calculate the target photometric variables, e.g., luminance and intensity.
The core of this work was to use the \textit{phase space} (PS) which provides a full description of geometric optics. In this thesis we restricted ourselves to two-dimensional optical systems, the PS of which is a two-dimensional space. For every ray traced inside the system its path can be considered where a path is the sequence of the optical lines that it encounters. The PS representation of the optical system shows that all the rays that follow the same path are located inside the same region in PS which is therefore divided into patches.
Those parts of the target PS that are illuminated by the source are the positive luminance regions, on the others parts the luminance is equal to zero. Our idea was to determine the boundaries of the positive luminance regions to reduce the number of rays needed for obtaining the photometric variables. In particular, assuming a Lambertian source, the coordinates of the rays located on the boundaries give all the information needed to compute the output luminance and therefore the intensity.
To this purpose, we developed two methods: \emph{PS ray tracing} and \emph{backward ray mapping} in PS. The goal of both is to trace only the rays close to the boundaries reducing the total number of rays traced compared to existing methods, for example Monte Carlo (MC) and Quasi-Monte Carlo (QMC) ray tracing.
\\ \\ \indent \emph{PS ray tracing} exploits the PS of the source and the target of the optical system. %In Chapter \ref{chap:PS}
We introduced an accurate procedure to construct a triangulation on source PS which allows tracing most of the rays close to the boundaries of the positive luminance regions.
The boundaries of those regions were approximated using two different approaches: the $\alpha$-shapes method and a technique based on triangulation refinement. \\ \indent
The $\alpha$-shapes method relies on a parameter $\alpha$ which establishes which triangles have to be kept in the PS triangulation and which have to be removed to approximate the boundaries correctly. We developed a procedure based on \'{e}tendue conservation to determine the value of $\alpha$ that gives a good approximation of the boundaries.
%The $\alpha$-shape method was explained in Chapter \ref{chap:boundaries_alpha} and
Numerical results were provided for two different kinds of TIR-collimators showing that PS ray tracing using $\alpha$-shapes is much faster and more accurate than MC ray tracing. However, we observed that the speed of convergence depends on the smoothness of the shape of the regions in target PS and, therefore, on the optical system. \\ \indent To eliminate the parameter $\alpha$ from the calculation of the boundaries, we developed a new approach for the boundaries computation based on triangulation refinement.
%explained in Chapter \ref{chap:triangulation}.
This technique is able to determine the boundary triangles (triangles crossed by at least one boundary) of a given triangulation. Connecting the vertices of the boundary triangles corresponding to rays that follow the same path, a good approximation of all the boundaries is obtained. Tracing more rays leads to smaller triangles resulting in a better accuracy of the boundary computation. The stopping criterion employs \'{e}tendue conservation.
The method was applied to several optical systems with reflective and refractive optical lines. The results show that the boundaries of all the regions with positive luminance in target PS are calculated correctly even for complicated systems such as the parabolic reflector for which multiple reflections of the rays with the mirrors can occur.

Assuming a Lambertian source, the intensity was computed from the coordinates of the rays on the boundaries.
The intensity profile obtained using PS ray tracing based on the triangulation refinement is compared to the two intensities found with MC and QMC ray tracing. PS ray tracing allows us tracing far less rays compared to MC ray tracing resulting in a significant reduction of the computational time. Our method has an order of convergence proportional to the reciprocal of the number of rays traced versus an error convergence proportional to the inverse of the square root of the number of rays traced for MC ray tracing. The results showed that PS ray tracing and QMC ray tracing are comparable in terms of the computational time, indeed the corresponding convergence errors are proportional to the inverse of the number of rays traced. For the TIR-collimator, for example, PS ray tracing outperforms also QMC ray tracing while it is slower than QMC for some other systems as, for example, the parabolic reflector. However, we demonstrated in simulations that PS ray tracing is bin-free while MC and QMC errors depend on the number of bins in which the target is divided.
In order to further improve PS ray tracing we developed a second method, \emph{backward ray mapping}, which allows tracing only the rays located \emph{exactly} on the boundaries of the regions with positive luminance.
\\ \\ \indent The key idea of this method is to construct an inverse map from target to source connecting the coordinates of the rays on the PS of each optical line encountered. \\ \indent
%In Chapter \ref{chap:raymapping1}
We presented \emph{concatenated backward ray mapping} applicable to systems formed by straight line segments. It considers \textit{all} the lines that form the system. We showed that the boundaries of the regions in every PS can be calculated \textit{analytically}. Therefore, assuming a Lambertian source, concatenated backward ray mapping calculates the intensity \textit{exactly}. Compared to QMC ray tracing the new method is much more accurate and also faster.

%In Chapter \ref{chap:raymapping2}
Next, we introduced direct backward ray mapping which is a modification of concatenated backward ray mapping to systems formed by curved lines. In this case the boundaries of the positive luminance regions in all the phase spaces cannot be calculated analytically, therefore a bisection procedure combined with backward ray tracing is developed. As a consequence the \textit{exact} target intensity cannot be obtained for systems formed by curved lines. Nevertheless, the method remains very accurate and numerical results showed that it is also able to detect \textit{unphysical} paths due to numerical error, where we referred to physical paths as those from the source to the target. Direct backward ray mapping provides a more accurate intensity distribution in less time compared to QMC ray tracing. To achieve an error of around $10^{-6}$, direct backward ray mapping is approximately $10^3$ times faster than QMC ray tracing for the TIR-collimator and $10^2$ times faster for the parabolic reflector. In Figure \ref{fig:error_comparison} we show an error comparison between all the methods applied to the TIR-collimator (left figure) and the parabolic reflector (right figure).
We remark that while MC and QMC ray tracing are binning procedures, thus, the averaged intensity is computed, PS ray tracing and direct backward ray mapping compute the intensity point-wise. To compare the methods we calculated the averaged intensities also for PS ray tracing and direct backward ray mapping. Therefore, also for the PS procedures the target was divided into bins and the mean value of the intensity over every bin was computed. This mean value was given by the integral of the intensity over every bin divided by the size of the bin. In the simulations showed in this thesis, the integral was approximated by the trapezoidal rule discretizing the bin into $10$ sub-intervals of equal length. The CPU-times of the PS methods shown in Figure \ref{fig:error_comparison}, is divided by $10$ to obtain the real CPU-time when the PS methods are not compared with binning procedures.
\begin{figure}[t]
\label{fig:error_comparison}
 \begin{subfigure}[t]{0.49\textwidth}
\centering
    \includegraphics[width = \textwidth]{error_time_tir_all_methods}
    \caption{Error plot for the TIR-collimator.}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.49\textwidth}
\centering
    \includegraphics[width = \textwidth]{error_time_pr_all_methods}
    \caption{Error plot for the parabolic reflector.}
\end{subfigure}
\caption{\textbf{Comparison between MC, QMC, PS ray tracing and direct backward ray mapping.}}
\label{fig:error_comparison}
\end{figure}
\\ \indent
%in Chapter \ref{chap:fresnel}
Finally, we investigated systems where also Fresnel reflections are involved. Fresnel reflection leads to multiple paths due to the fact that, at every interaction with a line, each ray is split in two rays (the reflected and the transmitted) each of them carries a fraction of the energy transported by the incident ray. Direct backward ray mapping is able to detect \textit{all} the possible paths that can occur. Moreover, we showed that only the rays located on the boundaries of the positive luminance regions in target PS related to the \textit{physical} paths are traced from target to source. To validate our method we traced forward a set of rays using MC ray tracing and we showed that the boundaries found with direct backward ray mapping enclose all the rays traced. The power associated to each ray on the boundary is calculated. For Fresnel systems the output luminance is not constant as it depends on the angles of incidence of every line and on the path followed. Therefore a sample of rays inside the positive luminance regions needs to be traced back to compute the luminance and the intensity.
\\ \\ \indent To conclude we claim that PS methods might constitute alternative approaches to conventional ray tracing. The advantages are that far less rays are needed for computing the target photometric variables resulting in a reduction of the computational time. In particular, PS ray tracing is easy to implement and faster than MC ray tracing. For some systems it outperforms also QMC ray tracing while for some others the boundaries of the positive luminance regions could be difficult to approximate and more rays are required. Because of this, in some cases PS ray tracing can be slightly slower than QMC ray tracing. Direct backward ray mapping can be seen as an improvement of PS ray tracing as it is much more accurate. It allows tracing far less rays compared to MC, QMC and PS ray tracing, directly determining the rays on the boundaries of the positive luminance regions. Direct backward ray mapping is a very elegant method and, compared to MC and QMC ray tracing it is faster and much more accurate. This method could be used also to detect and minimize ghost stray light.
\section{Recommendations}
%For every boundary and along every direction, a sample of rays with position coordinates located between the rays on the boundaries need to be traced back in order to obtain the profile of the partial luminance along every direction. The total luminance is the sum of all the partial luminance related to each path. Finally the intensity cou
%\\ \\ \indent In this thesis we showed that phase space is a powerful concept that fully characterize the optical systems. We presented two new methods based on phase space which allow traced far less rays than existing procedures to obtain the desired accuracy. This results in a significant reduction of the computational time. We evaluated the method for several optical systems in two-dimensions.
This work is far from finished. In the future, it might be useful to investigate in more details the two-dimensional case. The two-dimensional case is particularly relevant because it is a good test for new methods. Moreover it gives a complete analysis of three-dimensional rotationally symmetric systems as it fully describe of the meridional plane.\\ \indent
Regarding PS ray tracing, it could be interesting to analyze systems with a non-Lambertian source. Our proposal is to calculate the boundaries as we have done for a Lambertian source. Next, the profile of the luminance can be obtained by tracing a sample of rays with corresponding coordinates in the interior of the boundaries found. The intensity can be obtained by merely integrating the luminance over all the possible positions. \\ \indent
Regarding direct backward ray mapping, we are interested in providing simulations for systems with Fresnel reflection. The results shown in Chapter \ref{chap:fresnel} give the expectation that the direct backward ray mapping method is suitable also for such systems and that it is much more precise and faster than both MC and QMC ray tracing. Scattering phenomena could be described by generalizing direct backward ray mapping for Fresnel systems. More paths would occur because, at every intersection, each ray can be split in more than two rays as it scatters in multiple directions. The range of possible directions can be discretized and a path can be associated to each direction. We expect that the same algorithm used for Fresnel's reflections can be applied to every single path in case of scattering.
%Furthermore colour
 \\ \indent
Future research should address the three-dimensional case. The first step could be to consider rotationally symmetric optical systems, i.e., systems invariant under rotations around the optical axis. Such systems are often used in illumination optics as they are easy to manufacture. They can be described by only considering the meridional rays, that is rays that propagate inside the plane containing the optical axis. This reduces the three-dimensional case to the two-dimensional one.
For rotationally symmetric systems PS ray tracing and backward ray mapping might constitute design tool for optical designers, greatly reducing the time to design the optical systems.
\\ \indent  Next, it can be useful to analyze asymmetric optical systems \cite{ries1997performance}. Every ray is described by three position and two direction coordinates. The corresponding PS is therefore a four dimensional space described by two of the position coordinates $\variabile{q}_1$ and $\variabile{q}_2$ of the intersection point between the ray and the optical surface and two direction coordinates $\variabile{p}_1$ and $\variabile{p}_2$, expressed with respect to the normal of the surface.
The target luminance in PS is a function of all these coordinates, while the intensity only depends on the direction coordinates and is given by a two-dimensional integral of the luminance over all the position coordinates $\variabile{q}_1$ and $\variabile{q}_2$.
Therefore, for fixed directions $\variabile{p}_1$ and $\variabile{p}_2$, we need to compute the boundaries of the positive luminance regions in the $(\variabile{q}_1, \variabile{q}_2)$-plane.
%In PS line in the two-dimensional case will become a surface in the three-dimensional case.

To clarify our idea, we report a picture of the structure of the target of a three-dimensional system showed in \cite{winston2005nonimaging} by Winston, Mi\~nano and Benitez.
In particular, they show the target of a CPC seen from above (constant direction). For example, Figure \ref{fig:melettaC} shows the regions in the $(\variabile{q}_1, \variabile{q}_2)$-plane at the target of rays that leave the source with given angular coordinates. The regions labeled $0, 1, 2,$... correspond to the regions that arrive at the target after after $0, 1, 2, \cdots$ reflections; $F2, F3,$... indicate the regions of the rays that begin to turn back after two, three, $\cdots$ reflections. The blank regions are formed by the rays that
still be traveling toward the exit aperture after five reflections.
\begin{figure}[h]
\centering
    \includegraphics[width = 0.6\textwidth]{MelettaD}
    \caption{Regions at the target of a CPC of rays that leave the source with a fixed direction found using ray tracing. \cite{winston2005nonimaging}.}
\label{fig:melettaC}
\end{figure}
%In target PS the luminance is positive inside four dimensional objects. Hence the $2$D positive luminance regions at the target PS of two-dimensional systems become $4$D objects at the target PS of three-dimensional systems. The intensity along fixed directions $(\variabile{p}_1, \variabile{p}_2)$ is given by the integral of the luminance over all the possible positions $(\variabile{q}_1, \variabile{q}_2)$. Assuming a Lambertian source, we only need to compute the rays located on the boundaries of the $4$D positive luminance regions. Those boundaries are now surfaces instead of lines. Phase space ray tracing should deal with $5$-cell, that is a four-dimensional object bounded by $5$ tetrahedra cells. The boundaries of the regions with positive luminance (now triangular faces instead of lines) can be approximated either using four-dimensional $\alpha$-shapes (see for instance \cite{cazals2005conformal, teichmann1998surface}) or considering those triangular faces of each tethraedron located on one side of the boundaries of the region corresponding to a given path. Using the edge-ray principle the target boundaries are found and, therefore, the target photometric variables can be computed. Although the three-dimensional case will imply a more complicated structure of the PS and of the algorithm for surface reconstruction, we believe that phase space ray tracing is suitable in three dimensions.
%We expect that for the boundaries reconstruction based on the triangulation refinement the speed of convergence will remain proportional to the inverse of the square root of the number of rays traced as every time that the tethraeda are halved the difference between the approximated \'{e}tendue at the target and the real \'{e}tendue should half.
%%
%\\ \indent
%On the other hand, direct backward ray mapping extended to three-dimensional systems would be more complicated in a four dimensional target PS. Our idea is to discretize the hypercube into planes fixing both direction coordinates. Next, the bisection procedure can be applied fixing one of the two position $\variabile{q}_2$ coordinates and varying the other $\variabile{q}_1$. Repeating the procedure for all the possible values of $\variabile{q}_2$ would allow tracing back the rays located on the boundaries of the regions with positive luminance in the plane $(\variabile{q}_1, \variabile{q}_2)$ for fixed directions. In case of non Lambertian source, the luminance along those directions can be obtained tracing back a sample of rays inside those regions. Varying the direction coordinates $(\variabile{p}_1, \variabile{p}_2)$ and repeating the procedure for all the possible directions, the luminance can be calculated. The intensity profile is finally obtained by a two-dimensional integral over all the possible position coordinates.
%\\ \indent

We expect that both methods presented in this thesis can be extended to the three-dimensional case. PS ray tracing will be based on a triangulation reconstruction on the $(\variabile{q}_1, \variabile{q}_2)$-plane. The same procedure applied for the two-dimensional case in the $(\variabile{q}_1, \variabile{p}_1)$-plane can be applied to the $(\variabile{q}_1, \variabile{q}_2)$-plane for the three-dimensional case. This will allow to detect the boundaries of the positive luminance regions along the fixed directions $\variabile{p}_1$ and $\variabile{p}_2$. Repeating the triangulation refinement procedure for all the possible directions, all the boundaries can be determined. Also, for the direct backward ray mapping in three-dimensions, we can apply the same bisection procedure combined with the backward ray mapping used for the two-dimensional case. The only difference is that in $2$D we detected the boundaries of the positive luminance regions in the $(\variabile{q}_1, \variabile{p}_1)$-plane, while in $3$D we need to compute those boundaries in the $(\variabile{q}_1, \variabile{q}_2)$-plane and repeat the procedure for every $\variabile{p}_1$ and $\variabile{p}_2$.

Although, the results showed for the two-dimensional case are very promising, we cannot predict the speed of convergence for the three-dimensional asymmetric optical systems. We expect that this would depend on the complexity of optical devices and of the corresponding regions in target PS. More research should be oriented on this topic.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{FCN-DenseNet model}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FCN-DenseNet which was introduced in~\cite{Jegou} was applied in our previous work~\cite{Ijjeh2021} for image segmentation.
The results were promising since it outperformed the conventional damage detection technique i.e (adaptive wavenumber filtering method).
FCN-DenseNet has a U-shape of the encoder-decoder scheme with skip connections between the downsampling and the upsampling paths to increase the resolution to the final feature map.
The main component in FCN-DenseNet is the dense block.
The dense block is constructed from \(n\) varying number of layers, each layer consists of a series of operations as shown in Table~\ref{layers}.
The purpose of the dense block is to concatenate the input (\(x\)) (feature maps) of a layer with its output (feature maps) to emphasize spatial details information.
In this work, we have updated the FCN-DenseNet model by increasing the number of dense blocks and the learnable parameters (filters).
The architecture of the dense block is presented in Fig.~\ref{dense_block}.
\begin{figure} [h!]
	\begin{center}
		\includegraphics[scale=1.0,angle=-90]{DenseBlock_layer.png}
	\end{center}
	\caption{Dense block architecture.}
	\label{dense_block}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
To reduce the spatial dimensionality of the produced feature maps, a transition down layer was added to perform a (\(1\times 1\)) convolution followed by (\(2\times2\)) Maxpooling operation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Consequently, to recover the spatial resolution, a transition-up layer was added.
It applies a transpose convolution operation to upsample feature maps from the previous layer.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Feature maps emerging from upsampling are concatenated with the ones resulting from the skip connection forming the input to a new dense block.
During the upsampling, the input to the dense block is not concatenated with its output to overcome the overhead of memory shortage since the upsampling path expands the spatial resolution of the feature maps.
%(hint:- We can refer to previous paper and say that the same architecture was applied here. Than we can skip Fig.~\ref{fcn}).
%\begin{figure} [h!]
%	\begin{center}
%		\includegraphics[scale=1.0]{FCN_dense_net.png}
%	\end{center}
%	\caption{FCN-DenseNet architecture.}
%	\label{fcn}
%\end{figure}
Table~\ref{layers} presents the architecture of a single layer, the transition down  and transition up layers in details.
%Figure~\ref{fcn} illustrates the FCN-DenseNet architecture for image segmentation used for delamination detection.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{table}[h!]
	\renewcommand{\arraystretch}{1.3}
	\centering
	\scriptsize
	\resizebox{\textwidth}{!}
	{
	\begin{tabular}{ccccc}
		\hline
		Layer &  &  Transition Down &  &  Transition Up \\
		\hline
		Batch Normalization &  & Batch Normalization &  &  \(3\times 3\) Transposed Convolution  \\
		Relu &  & Relu &  & strides = (\(2\times2\))  \\
		(\(3\times3\)) Convolution &  & (\(1\times1\)) Convolution &  &  \\
%		&  &   \\
		Dropout \(p=0.2\) &  &Dropout \(p=0.2\)  &  &  \\
		 &  & (\(2\times2\)) Maxpooling &  &  \\
	    \hline
	\end{tabular}
	}
	\caption{Layer, Transition Down and Transition Up layers.}
	\label{layers}

\end{table}\\


\chapter{Einleitung}\label{einleitung}
Es ist oft möglich, Probleme als eine Sequenz $x_{1}, x_{2}, x_{3} \dots x_{n}$, für
welche die Bedingung $P_{n}(x_{1}, x_{2}, x_{3} \dots x_{n})$ gelten soll, darzustellen.
Damit Backtracking zu deren Lösung eingesetzt werden kann, müssen außerdem noch
Untereigenschaften $P_{v}(x_{1}, x_{2}, x_{3} \dots x_{v})$ für alle $v \in [ \, 0, n) \,$
mit folgenden Eigenschaften existieren:
\begin{enumerate}
  \item $P_{0}()$ gilt immer
  \item $P_{v + 1}(x_{1}, x_{2}, x_{3} \dots x_{v + 1})$ gilt nur, wenn $P_{v}(x_{1}, x_{2}, x_{3} \dots x_{v})$ gilt
  \item wenn $P_{v}(x_{1}, x_{2}, x_{3} \dots x_{v})$ gilt, ist $P_{v + 1}(x_{1}, x_{2}, x_{3} \dots x_{v+1})$ einfach zu testen
\end{enumerate}

Somit kann man alle Sequenzen $x_{1}, x_{2}, x_{3} \dots x_{v} \dots x_{q}$ mit $q > v$ ignorieren,
falls $P_{v}(x_{1}, x_{2}, x_{3} \dots x_{v})$ nicht gilt.
Der darauf basierende Backtracking Algorithmus \textbf{B} kann nun wie folgt implementiert werden:
\begin{minted}[linenos, fontsize=\small]{rust}
pub fn b<T: Sequence>(initial: T, n: usize) -> Vec<T> {
    if !initial.satisfies_condition() {
        return Vec::new();
    } else if n == 0 {
        return vec![initial];
    }

    // all sequences of length n which satisfy the condition
    let mut results = Vec::new();

    // the current sequence, starts with just the initial state
    let mut states = Vec::new();

    let steps = initial.next_steps().into_iter();
    states.push((initial, steps));

    // run while there is still a state with an unchecked next step
    while let Some((state, steps)) = states.last_mut() {
        // take the next unchecked possible step of the current state,
        // in case there are no unchecked steps left,
        // simply discard the current state as all possible
        // sequences have already been tried.
        if let Some(step) = steps.next() {
            // compute the result of this step
            let next_state = state.apply_step(step);
            // does this new state still satisfy the condition,
            // if not we can simply discard it
            if next_state.satisfies_condition() {
                // if the sequence is already n elements long,
                // it is correct and can be added to results.
                // Otherwise we push it onto the stack.
                if states.len() < n {
                    let next_steps = next_state.next_steps().into_iter();
                    states.push((next_state, next_steps));
                } else {
                    results.push(next_state);
                }
            }
        } else {
            states.pop();
        }
    }

    results
}
\end{minted}

Um ein Problem mit diesem Algorithmus lösen zu können, benötigt man einen Datentyp, welcher den momentanen Zustand
der Sequenz speichern kann und das folgende Interface implementiert:
\begin{minted}[linenos, fontsize=\small]{rust}
/// A required set of methods needed for the generic backtracking algorithms.
pub trait Sequence {
    type Step;
    type Steps: IntoIterator<Item = Self::Step>;

    /// Checks if this sequence satisfies its condition.
    ///
    /// This function can assume that the  parent of `self` satisfied this condition.
    fn satisfies_condition(&self) -> bool;

    /// generates all possible next steps at this current state.
    fn next_steps(&self) -> Self::Steps;

    /// applies a `step` to `self`, returning the resulting sequence.
    ///
    /// this function will only be called if `self.satisfies_condition() == true`.
    fn apply_step(&self, step: Self::Step) -> Self;
}
\end{minted}


\documentclass[notes,11pt, aspectratio=169]{beamer}
\usepackage[default]{lato}

\input{lec_style.tex}

%----------------------------------------------------------------------------------------
  %	TITLE PAGE
%----------------------------------------------------------------------------------------
\title[DAR]{Data Analytics with R}  % The short title appears at the bottom of
\author{Sumit Mishra} % Your name
\institute[IFMR] % Your institution as it will appear on the bottom of every slide, may be shorthand to save space
{
  Institute for Financial Management and Research, Sri City \\ % Your institution for the title page
  \medskip
  \medskip
  \textbf{Linear Regression} % Your email address
}
\date{23 December 2020} % Date, can be changed to a custom date

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 {
    \addtocounter{framenumber}{-1}
    {\removepagenumbers
      %\usebackgroundtemplate{\includegraphics[width=\paperwidth]{../OpenIntro_Grid_4_3-01.jpg}}
      \begin{frame}

      %\hfill \includegraphics[width=20mm]{../oiLogo_highres}

      \titlepage

      \end{frame}
    }
  }

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Sections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

\section{Line fitting, residuals, and correlation}

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

\subsection{Fitting a line to data}

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

\begin{frame}
\frametitle{Modeling numerical variables}

In this unit we will learn to quantify the relationship between two numerical variables, as well as modeling numerical response variables using a numerical or categorical explanatory variable.

\end{frame}

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

\begin{frame}
\frametitle{Asset Poverty vs. Literacy Rate}

The \hl{scatterplot} below shows the relationship between literacy rate in all 640 Indian districts and the \% of households who don't own any assets.

\twocol{0.55}{0.45}{
\begin{center}
\includegraphics[width=\textwidth]{graphs/l08f01}
\end{center}
}
{
\dq{Outcome variable?}
\pause
\soln{proportion of households without any assets}
\pause
\dq{Predictor variable?}
\pause
\soln{literacy proportion}
\pause
\dq{Relationship?}
\pause
\soln{linear, negative, moderately strong}
}

\end{frame}

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

\subsection{Using a linear regression to predict poverty}

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

\begin{frame}

The linear model for predicting asset-poverty from literacy rate in India is

\[ \hat{\text{poverty}} = 0.618 - 0.66 * prop_{Lit} \]

The ``hat" is used to signify that this is an estimate.

\end{frame}

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

\begin{frame}

\dq{The literacy rate in Akola is 77.8\%. What asset-poverty level does the model predict for this district?}

\pause

\[ 0.618 - 0.66 * 0.778 = 0.102 \]

\end{frame}

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

\subsection{Eyeballing the line}

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

\begin{frame}
\frametitle{Eyeballing the line}

\twocol{0.3}{0.7}
{
\pq{Which of the following appears to be the line that best fits the linear relationship between \% in poverty and \% literate? Choose one.}
\soln{\only<2>{\orange{
(a)
}}}
}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/l08f02}
\end{center}
}
\end{frame}

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

\subsection{Residuals}

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

\begin{frame}
\frametitle{Residuals}

\hl{Residuals} are the leftovers from the model fit: Data = Fit + Residual

\begin{center}
\includegraphics[width=0.5\textwidth]{graphs/l08f03}
\end{center}

\end{frame}

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

\begin{frame}
\frametitle{Residuals (cont.)}

\formula{Residual}{
Residual is the difference between the observed ($y_i$) and predicted $\hat{y}_i$.
\[ e_i = y_i - \hat{y}_i \]
}
\vspace{-0.5cm}
\twocol{0.6}{0.4}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/l08f04}
\end{center}
}
{
\pause
\begin{itemize}
\item \% living in poverty in Akola is 21\% more than predicted.
\pause
\item \% living in poverty in Nashik is 4\% less than predicted.
\end{itemize}
}

\end{frame}

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

\subsection{Describing linear relationships with correlation}

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

\begin{frame}
\frametitle{Quantifying the relationship}

\begin{itemize}

\item \hl{Correlation} describes the strength of the \orange{linear} association between two variables.

\pause

\item It takes values between -1 (perfect negative) and +1 (perfect positive).

\pause

\item A value of 0 indicates no linear association.

\end{itemize}

\end{frame}

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

\begin{frame}
\frametitle{Guessing the correlation}

\pq{Which of the following is the best guess for the correlation between propn in asset poverty and propn literate?}
\twocol{0.4}{0.6}
{
\begin{enumerate}[(a)]
\item 0.6
\solnMult{-0.54}
\item -0.1
\item 0.02
\item -1.5
\end{enumerate}
}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/l08f05}
\end{center}
}

\end{frame}

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

\begin{frame}
\frametitle{Guessing the correlation}

\pq{Which of the following is the best guess for the correlation between propn in asset poverty and propn of SC-ST in a district?}

\twocol{0.4}{0.6}
{
\begin{enumerate}[(a)]
\item 0.1
\item -0.6
\item -0.4
\item 0.9
\solnMult{0.55}
\end{enumerate}
}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/l08f06.pdf}
\end{center}
}

\end{frame}

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

\begin{frame}
\frametitle{Assessing the correlation}

\pq{Which of the following is has the strongest correlation, i.e. correlation coefficient closest to +1 or -1?}

\twocol{0.8}{0.2}
{
\begin{center}
\includegraphics[width=0.65\textwidth]{graphs/l08f07}
\end{center}
}
{
\soln{\only<2>{\orange{
(b) $\rightarrow$ correlation means \underline{linear} association
}}}
}

\end{frame}

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

\section{Fitting a line by least squares regression}

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

\subsection{An objective measure for finding the best line}

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

\begin{frame}
\frametitle{An objective measure for finding the best line}

\begin{itemize}

\item We want a line that has small residuals:
\pause
\begin{enumerate}
\item Option 1: Minimize the sum of magnitudes (absolute values) of residuals
\[ |e_1| + |e_2| + \cdots + |e_n| \]
\pause
\item Option 2: Minimize the sum of squared residuals -- \hl{least squares}
\[ e_1^2 + e_2^2 + \cdots + e_n^2 \]
\end{enumerate}

\pause

\item Why least squares?
\pause
\begin{enumerate}
\item Most commonly used
\pause
\item Easier to compute by hand and using software
\pause
\item In many applications, a residual twice as large as another is usually more than twice as bad
\end{enumerate}

\end{itemize}

\end{frame}

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

\begin{frame}
\frametitle{The least squares line}

\[ \mathhl{ \hat{y} = \beta_0 + \beta_1 x } \]

\begin{itemize}
\item $\hat{y}$: Predicted value of the outcome variable, $y$
\item $\beta_0$: Intercept, parameter
\begin{itemize}
\item $b_0$: Intercept, point estimate
\end{itemize}
\item $\beta_1$: Slope, parameter
\begin{itemize}
\item $b_1$: Slope, point estimate
\end{itemize}
\item $x$: Predictor variable
\end{itemize}

\end{frame}

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

\subsection{Conditions for the least squares line}

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

\begin{frame}
\frametitle{Conditions for the least squares line}

\begin{enumerate}

\item Linearity

\pause

\item Nearly normal residuals

\pause

\item Constant variability

\end{enumerate}

\end{frame}

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

\begin{frame}
\frametitle{Conditions: (1) Linearity}

\begin{itemize}

\item The relationship between the predictor and the outcome variable should be linear.

\pause

\item Methods for fitting a model to non-linear relationships exist, but are beyond the scope of this class. If this topic is of interest, an \href{http://www.openintro.org/download.php?file=os2_extra_nonlinear_relationships&referrer=/stat/textbook.php}{Online Extra is available on openintro.org} covering new techniques.

\pause

\item Check using a scatterplot of the data, or a \hl{residuals plot}.

\end{itemize}

\begin{center}
\includegraphics[width=0.7\textwidth]{graphs/l08f08}
\end{center}

\end{frame}

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

\begin{frame}
\frametitle{Anatomy of a residuals plot}

\twocol{0.5}{0.5}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/l08f09}
\end{center}
}
{
\textcolor{red}{{\LARGE $\blacksquare$}} \hl{Akola:}
\begin{align*}
pLit &= 0.778 \qquad pNoAssets = 0.318 \\
\widehat{pNoAssets} &= 0.619 - 0.664 * 0.778 = 0.102 \\
e &= pNoAssets - \widehat{pNoAssets} \\
&= 0.318 - 0.108 = \textcolor{red}{0.217}
\end{align*}
$\:$
\pause
\textcolor{green}{{\Large $\blacktriangle$}} \hl{Nashik:}
\begin{align*}
pLit &= 0.761 \qquad pNoAssets = 0.071 \\
\widehat{pNoAssets} &= 0.619 - 0.664 * 0.761 = 0.113 \\
e &= pNoAssets - \widehat{pNoAssets} \\
&= 0.071 - 0.113 = \textcolor{green}{-0.042}
\end{align*}
}

\end{frame}

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

\begin{frame}
\frametitle{Conditions: (2) Nearly normal residuals}

\begin{itemize}

\item The residuals should be nearly normal.

\pause

\item This condition may not be satisfied when there are unusual observations that don't follow the trend of the rest of the data.

\pause

\item Check using a histogram.

\end{itemize}

\begin{center}
\includegraphics[width=0.35\textwidth]{graphs/l08f10}
\end{center}

\end{frame}

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

\begin{frame}
\frametitle{Conditions: (3) Constant variability}

\twocol{0.5}{0.5}
{
\begin{center}
\includegraphics[width=\textwidth]{graphs/l08f11}
\end{center}
}
{
\begin{itemize}

\item The variability of points around the least squares line should be roughly constant.

\pause

\item This implies that the variability of residuals around the 0 line should be roughly constant as well.

\pause

\item Also called \hl{homoscedasticity}.

\pause

\item Check using a residuals plot.

\end{itemize}
}

\end{frame}

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

\begin{frame}
\frametitle{Checking conditions}

\twocol{0.5}{0.5}
{
\pq{What condition is this linear model obviously violating?}
\begin{enumerate}[(a)]
\item Constant variability
\solnMult{Linear relationship}
\item Normal residuals
\item No extreme outliers
\end{enumerate}
}
{
\begin{center}
\includegraphics[width=0.7\textwidth]{graphs/nonlinear}
\end{center}
}

\end{frame}

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

\begin{frame}
\frametitle{Checking conditions}

\twocol{0.5}{0.5}
{
\pq{What condition is this linear model obviously violating?}
\begin{enumerate}[(a)]
\solnMult{ Constant variability}
\item Linear relationship
\item Normal residuals
\item No extreme outliers
\end{enumerate}
}
{
\begin{center}
\includegraphics[width=0.7\textwidth]{graphs/heteroscedastic}
\end{center}
}

\end{frame}

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

\subsection{Finding the least squares line}

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

\begin{frame}
\frametitle{Given...}

\twocol{0.5}{0.5}
{
\begin{center}
\includegraphics[width=0.7\textwidth]{graphs/l08f01}
\end{center}
}
{
\begin{tabular}{l r r}
\hline
		& propn literate		& propn in poverty \\
		& $(x)$			& $(y)$ \\
\hline
mean	& $\bar{x} = 0.6248 $	& $\bar{y} = 0.2036$  \\
sd		& $s_x = 0.105$		& $s_y = 0.129$ \\
\hline
		& correlation		& $R = -0.54$ \\
\hline
\end{tabular}
}

\end{frame}

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

\subsection{Interpreting regression model parameter estimates}

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

\begin{frame}
\frametitle{Slope}

\formula{Slope}
{The slope of the regression can be calculated as
\[ b_1 = \frac{s_y}{s_x} R \]
}

\pause

\hl{In context...}
\[ b_1 = \frac{0.129}{0.105} \times -0.54 = -0.664 \]

\pause
$\:$ \\
\hl{Interpretation} \\
For each additional percentage point in literacy rate, the asset poor rate would be lower on average by 0.66\% points.

\end{frame}

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

\begin{frame}
\frametitle{Intercept}

\formula{Intercept}
{The intercept is where the regression line intersects the $y$-axis. The calculation of the intercept uses the fact the a regression line always passes through $(\bar{x},\bar{y})$.
\[ b_0 = \bar{y} - b_1 \bar{x} \]
}

\pause

\begin{align*}
b_0 &= 0.2036 - (-0.664) \times 0.6248 \\
&= 0.619
\end{align*}

\end{frame}

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

\begin{frame}
\frametitle{}

\pq{Which of the following is the correct interpretation of the intercept?}

\begin{enumerate}[(a)]
\item For each \% point increase in literacy rate, \% living in poverty is expected to increase on average by 61.9\%.
\item For each \% point decrease in literacy rate, \% living in poverty is expected to increase on average by 61.9\%.
\item Having no literate person leads to 61.9\% of households living without any assets.
\solnMult{Districts with no literate population are expected on average to have 61.9\% of households living in asset-poverty.}
\item In districts with no literate population \% living in asset-poverty is expected to increase on average by 61.9\%.
\end{enumerate}

\end{frame}

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

\begin{frame}
\frametitle{More on the intercept}

Since there are no districts in the dataset with no literate population, the intercept is of no interest, not very useful, and also not reliable since the predicted value of the intercept is so far from the bulk of the data.

\end{frame}

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

\begin{frame}
\frametitle{Regression line}

\[ \widehat{pNoAssets} = 0.619 - 0.664\times pLit \]

\begin{center}
\includegraphics[width=0.5\textwidth]{graphs/l08f05}
\end{center}

\end{frame}

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

\subsection{Recap: Interpreting the slope and the intercept}

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

\begin{frame}
\frametitle{Interpretation of slope and intercept}

\twocol{0.5}{0.5}{
\begin{itemize}

\item \hl{Intercept:} When {$x = 0$}, {$y$} is expected to equal {the intercept}. \\

$\:$ \\

\item \hl{Slope:} For each {unit} in {$x$}, {$y$} is expected to {increase / decrease} on average by {the slope}.

\end{itemize}
}
{
\begin{center}
\includegraphics[width=\textwidth]{graphs/diagram}
\end{center}
}

\vspace{1cm}

\Note{These statements are not causal, unless the study is a randomized controlled experiment.}

\end{frame}

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

\subsection{Prediction}

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

\begin{frame}
\frametitle{Prediction}

\begin{itemize}

\item Using the linear model to predict the value of the response variable for a given value of the explanatory variable is called \hl{prediction}, simply by plugging in the value of $x$ in the linear model equation.

\item There will be some uncertainty associated with the predicted value.

\end{itemize}

\begin{center}
\includegraphics[width=0.9\textwidth]{graphs/l08f12}
\end{center}

\end{frame}

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

\subsection{Using $R^2$ to describe the strength of a fit}

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

\begin{frame}
\frametitle{$R^2$}

\begin{itemize}

\item The strength of the fit of a linear model is most commonly evaluated using \mathhl{R^2}.

\pause

\item $R^2$ is calculated as the square of the correlation coefficient.

\pause

\item It tells us what percent of variability in the response variable is explained by the model.

\pause

\item The remainder of the variability is explained by variables not included in the model or by inherent randomness in the data.

\pause

\item For the model we've been working with, $R^2 = -0.54^2 = 0.29$.

\end{itemize}

\end{frame}

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

\begin{frame}
\frametitle{Interpretation of $R^2$}

\pq{{\small Which of the below is the correct interpretation of $R = -0.54$, $R^2 = 0.29$?}}

\twocol{0.65}{0.35}{
\begin{enumerate}[(a)]

\item 29\% of the variability in the \% of literates among the 640 districts is explained by the model.

\solnMult{ 29\% of the variability in the \% of households living in assets poverty among the 640 districts is explained by the model.}

\item 29\% of the time \% literates predict \% living in asset poverty correctly.

\item 71\% of the variability in the \% of households living in poverty among the 640 districts is explained by the model.

\end{enumerate}
}{
\begin{center}
\includegraphics[width=\textwidth]{graphs/l08f01}
\end{center}
}

\end{frame}

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

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

\section{Types of outliers in linear regression}

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

\begin{frame}
\frametitle{Types of outliers}

\twocol{0.5}{0.5}
{
\dq{How do outliers influence the least squares line in this plot?}

To answer this question think of where the regression line would be with and without the outlier(s). Without the outliers the regression line would be steeper, and lie closer to the larger group of observations. With the outliers the line is pulled up and away from some of the observations in the larger group.
}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/out4}
\end{center}
}

\end{frame}

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

\begin{frame}
\frametitle{Types of outliers}

\twocol{0.4}{0.6}
{
\dq{How do outliers influence the least squares line in this plot?} \\
\soln{\only<2>{Without the outlier there is no evident relationship between $x$ and $y$.}}
}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/out5}
\end{center}
}

\end{frame}

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

\begin{frame}
\frametitle{Some terminology}

\begin{itemize}

\item \hl{Outliers} are points that lie away from the cloud  of points.

\pause

\item Outliers that lie horizontally away from the center of the cloud are called \hl{high leverage} points.

\pause

\item High leverage points that actually influence the \underline{slope} of the regression line are called \hl{influential} points.

\pause

\item In order to determine if a point is influential, visualize the regression line with and without the point. Does the slope of the line change considerably? If so, then the point is influential. If not, then it's not an influential point.

\end{itemize}

\end{frame}

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

\begin{frame}
\frametitle{Influential points}

Data are available on the log of the surface temperature and the log of the light intensity of 47 stars in the star cluster CYG OB1.

\twocol{0.7}{0.3}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/star}
\end{center}
}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/cyg}
\end{center}
}

\end{frame}

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

\begin{frame}
\frametitle{Types of outliers}

\twocol{0.4}{0.6}
{
\pq{Which of the below best describes the outlier?}
\begin{enumerate}[(a)]
\item influential
\solnMult{high leverage}
\item none of the above
\item there are no outliers
\end{enumerate}
}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/out6}
\end{center}
}

\end{frame}

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

\begin{frame}
\frametitle{Types of outliers}

\twocol{0.4}{0.6}
{
\dq{Does this outlier influence the slope of the regression line?}
\soln{\only<2>{Not much...}}

}
{
\begin{center}
\includegraphics[width=0.75\textwidth]{graphs/out1}
\end{center}
}

\end{frame}

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

\begin{frame}
\frametitle{Recap}

\pq{Which of following is \underline{true}?}

\begin{enumerate}[(a)]
\item Influential points always change the intercept of the regression line.
\item Influential points always reduce $R^2$.
\item It is much more likely for a low leverage point to be influential, than a high leverage point.
\item When the data set includes an influential point, the relationship between the explanatory variable and the response variable is always nonlinear.
\solnMult{None of the above.}
\end{enumerate}

\end{frame}

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

\begin{frame}
\frametitle{Recap (cont.)}

\vspace{-1cm}

\twocol{0.5}{0.5}
{
\begin{center}
\[ R = 0.08, R^2 = 0.0064 \]
\includegraphics[width=0.75\textwidth]{graphs/out5-1}
\end{center}
}
{
\begin{center}
\[ R = 0.79, R^2 = 0.6241 \]
\includegraphics[width=0.75\textwidth]{graphs/out5}
\end{center}
}

\end{frame}

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

\section{Inference for linear regression}

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

\subsection{Understanding regression output from software}

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

\begin{frame}
\frametitle{Nature or nurture?}

{\small In 1966 Cyril Burt published a paper called ``The genetic determination of differences in intelligence: A study of monozygotic twins reared apart?" The data consist of IQ scores for [an assumed random sample of] 27 identical twins, one raised by foster parents, the other by the biological parents.}

\begin{center}
\includegraphics[width=0.55\textwidth]{graphs/twins_IQ}
\end{center}

\end{frame}

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

\begin{frame}[fragile]
\frametitle{}

\pq{Which of the following is \underline{false}?}

{\footnotesize
\begin{verbatim}
Coefficients:
                 Estimate Std. Error t value Pr(>|t|)
(Intercept)       9.20760    9.29990   0.990    0.332
bioIQ             0.90144    0.09633   9.358  1.2e-09

Residual standard error: 7.729 on 25 degrees of freedom
Multiple R-squared: 0.7779,	Adjusted R-squared: 0.769
F-statistic: 87.56 on 1 and 25 DF,  p-value: 1.204e-09
\end{verbatim}
}

\begin{enumerate}[(a)]
\item Additional 10 points in the biological twin's IQ is associated with additional 9 points in the foster twin's IQ, on average.
\solnMult{Roughly 78\% of the foster twins' IQs can be accurately predicted by the model.}
\item The linear model is $\widehat{fosterIQ} = 9.2 + 0.9 \times bioIQ$.
\item Foster twins with IQs higher than average IQs tend to have biological twins with higher than average IQs as well.
\end{enumerate}

\end{frame}

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

\begin{frame}
\frametitle{Testing for the slope}

\pq{Assuming that these 27 twins comprise a representative sample of all twins separated at birth, we would like to test if these data provide convincing evidence that the IQ of the biological twin is a significant predictor of IQ of the foster twin. What are the appropriate hypotheses?}

\begin{enumerate}[(a)]
\item \mathhl{H_0:} $b_0 = 0$; \mathhl{H_A:} $b_0 \ne 0$
\item \mathhl{H_0:} $\beta_0 = 0$; \mathhl{H_A:} $\beta_0 \ne 0$
\item \mathhl{H_0:} $b_1 = 0$; \mathhl{H_A:} $b_1 \ne 0$
\solnMult{ \mathhl{H_0:} $\beta_1 = 0$; \mathhl{H_A:} $\beta_1 \ne 0$ }
\end{enumerate}

\end{frame}

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

\begin{frame}
\frametitle{Testing for the slope (cont.)}

{\footnotesize
\begin{center}
\begin{tabular}{rrrrr}
  \hline
 & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\
  \hline
(Intercept) & 9.2076 & 9.2999 & 0.99 & 0.3316 \\
  bioIQ & 0.9014 & 0.0963 & 9.36 & 0.0000 \\
   \hline
\end{tabular}
\end{center}
}

\pause

\begin{itemize}

\item We always use a $t$-test in inference for regression. $\:$ \\

\pause

\Remember{Test statistic, $T = \frac{point~estimate - null~value}{SE}$}

\pause

\item Point estimate = $b_1$ is the observed slope.

\pause

\item $SE_{b_1}$ is the standard error associated with the slope.

\pause

\item Degrees of freedom associated with the slope is $df = n - 2$, where $n$ is the sample size. $\:$ \\
\pause
\Remember{We lose 1 degree of freedom for each parameter we estimate, and in simple linear regression we estimate 2 parameters, $\beta_0$ and $\beta_1$.}

\end{itemize}

\end{frame}

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

\begin{frame}
\frametitle{Testing for the slope (cont.)}

{\small
\begin{center}
\begin{tabular}{rrrrr}
  \hline
 & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\
  \hline
(Intercept) &  9.2076 & 9.2999 & 0.99 & 0.3316 \\
  bioIQ & \orange{0.9014}  &   \green{0.0963} & \orange{9.36} & \textcolor{blue}{0.0000} \\
   \hline
\end{tabular}
\end{center}
}

\pause

\begin{eqnarray*}
T &=& \frac{\orange{0.9014} - 0}{\green{0.0963}} = \orange{9.36} \\
\pause
df &=& 27 - 2 = 25 \\
\pause
p-value &=& P(|T| > \orange{9.36}) < \textcolor{blue}{0.01}
\end{eqnarray*}

\end{frame}

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

\begin{frame}
\frametitle{\% in Poverty vs. \% SC-ST}

\dq{What can you say about the relationship between \% in poverty and \% SC-ST in a sample of 100 districts in India?}

\begin{center}
\includegraphics[width=0.5\textwidth]{graphs/l08f13.pdf}
\end{center}

\end{frame}

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

\begin{frame}
\frametitle{\% in Poverty vs \% SC-ST - linear model}

\pq{Which of the below is the best interpretation of the slope?}

{\small
\begin{center}
\begin{tabular}{rlrrrr}
  \hline
 & term & estimate & std.error & statistic & p.value \\
  \hline
1 & (Intercept) & 0.10 & 0.02 & 5.75 & 0.00 \\
  2 & pSCST & 0.03 & 0.06 & 0.50 & 0.62 \\
   \hline
\end{tabular}
\end{center}
}

\begin{enumerate}[(a)]
\item A 1\% increase in SC-ST population in a district is associated with a 3\% increase in \% of asset poor.
\solnMult{A 1\% increase in SC-ST population in a district is associated with a 0\% increase in \% of asset poverty.}
\item An additional 1\% of SC-ST population increases the \% of asset poor in a district by 10\%.
\item In districts with zero SC-ST population, \% of asset poor is expected to be 75\%.
\end{enumerate}

\end{frame}

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

\begin{frame}
\frametitle{\% in Poverty vs. \% SC-ST - linear model}

\dq{Do these data provide convincing evidence that there is a statistically significant relationship between \% SC-ST and \% asset poor in randomly chosen Indian districts?}

{\small
\begin{center}
\begin{tabular}{rrrrr}
  \hline
 & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\
  \hline
(Intercept) & 0.1049 & 0.0182 & 5.75 & 0.0000 \\
  pSCST & 0.0301 & 0.0602 & 0.50 & 0.6179 \\
   \hline
\end{tabular}
\end{center}
}
\soln{\only<2->{No, the p-value for \% SCST is low, indicating that the data does not provide convincing evidence that the slope parameter is different than 0.
}}

$\:$ \\

\dq{How reliable is this p-value if these zip code areas are not randomly selected?}
\soln{\only<3->{Not very...
}}

\end{frame}

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

\subsection{CI for the slope}

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

\begin{frame}
\frametitle{Confidence interval for the slope}

\pq{{\small Remember that a confidence interval is calculated as $point~estimate \pm ME$ and the degrees of freedom associated with the slope in a simple linear regression is $n - 2$. Which of the below is the correct 95\% confidence interval for the slope parameter? Note that the model is based on observations from 27 twins.}}

{\footnotesize
\begin{center}
\begin{tabular}{rrrrr}
  \hline
 & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\
  \hline
(Intercept) & 9.2076 & 9.2999 & 0.99 & 0.3316 \\
  bioIQ & 0.9014 & 0.0963 & 9.36 & 0.0000 \\
   \hline
\end{tabular}
\end{center}
}

\vspace{-0.5cm}

\twocol{0.4}{0.6}
{
\begin{enumerate}[(a)]
\item $9.2076 \pm 1.65 \times 9.2999$
\solnMult{ $0.9014 \pm 2.06 \times 0.0963$}
\item $0.9014 \pm 1.96 \times 0.0963$
\item $9.2076 \pm 1.96 \times 0.0963$
\end{enumerate}
}
{
\soln{\onslide<2->{\orange{
\begin{eqnarray*}
\pause
n &=& 27 \qquad df = 27 - 2 = 25 \\
\pause
95\%:~t^\star_{25} &=& 2.06 \\
\pause
0.9014 &\pm& 2.06 \times 0.0963 \\
\pause
(0.7 &,& 1.1)
\end{eqnarray*}
}}}}

\end{frame}

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

\begin{frame}
\frametitle{Recap}

\begin{itemize}

\item Inference for the slope for a single-predictor linear regression model:
\pause
\begin{itemize}
\item Hypothesis test:
\[ T = \frac{b_1 - null~value}{SE_{b_1}} \qquad df = n - 2 \]
\pause
\item Confidence interval:
\[ b_1 \pm t^\star_{df = n - 2} SE_{b_1} \]
\end{itemize}

\pause

\item The null value is often 0 since we are usually checking for \hl{any} relationship between the explanatory and the response variable.

\pause

\item The regression output gives $b_1$, $SE_{b_1}$, and \hl{two-tailed} p-value for the $t$-test for the slope where the null value is 0.

\pause

\item We rarely do inference on the intercept, so we'll be focusing on the estimates and inference for the slope.

\end{itemize}

\end{frame}

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

\begin{frame}
\frametitle{Caution}

\begin{itemize}

\item Always be aware of the type of data you're working with: random sample, non-random sample, or population.

\pause

\item Statistical inference, and the resulting p-values, are meaningless when you already have population data.

\pause

\item If you have a sample that is non-random (biased), inference on the results will be unreliable.

\pause

\item The ultimate goal is to have independent observations.

\end{itemize}

\end{frame}

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

\end{document}


%!TEX root = ../main.tex

\section{Math problems}
\label{sec:math_problems}

	We've now reached the first section of problems in this book.
	The purpose of these problems is to give you a way to comprehensively practice your math fundamentals.

{\small

\begin{problems}{ch1}

	\vspace*{3mm}

	%%%  SOLVING EQUATIONS     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	\begin{problem}
		Solve for $x$ in the equation $x^2-9=7$.
		\begin{answer}$x=\pm 4$.\end{answer}
	\end{problem}

	\begin{problem}
		Solve for $x$ in the equation $\cos^{-1}\!\left( \frac{x}{A} \right) - \phi = \omega t$.
		\begin{answer}$x=A\cos(\omega t+\phi)$.\end{answer}
	\end{problem}

	\begin{problem}		\label{mathprob:ch1:fractions2}
		Solve for $x$ in the equation $\frac{1}{x}=\frac{1}{a}+\frac{1}{b}$.
		\begin{answer}$x=\frac{ab}{a+b}$.\end{answer}
	\end{problem}

	\begin{problem}
		Use a calculator to find the values of the following expressions:
		\fourcol
			\textbf{a)}~$\sqrt[4]{3^3}$

			\textbf{b)}~$2^{10}$

			\textbf{c)}~$7^{^{\frac{1}{4}}}-10$

			\textbf{d)}~$\frac{1}{2}\ln(e^{22})$
		\endfourcol
		%\begin{hint}
		%\end{hint}
		\begin{answer}\textbf{a)}~$2.2795$.
					\textbf{b)}~$1024$.
					\textbf{c)}~$-8.373$.
					\textbf{d)}~$11$.\end{answer}
		%\begin{solution}
		%\end{solution}
	\end{problem}

	%% FRACTIONS    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	\begin{problem}
		Compute the following expressions involving fractions:
		\threecol
			\textbf{a)}~$\dfrac{1}{2} + \dfrac{1}{4}$

			\textbf{b)}~$\dfrac{4}{7} - \dfrac{23}{5}$

			\textbf{c)}~$1\frac{3}{4} + 1\frac{31}{32}$
		\endthreecol
		\begin{answer}\textbf{a)}~$\frac{3}{4}$.
					\textbf{b)}~$\frac{-141}{35}$.
					\textbf{c)}~$3\frac{23}{32}$.\end{answer}
		\begin{solution}
			For \textbf{c)},
			$1\frac{3}{4} + 1\frac{31}{32}
				= \frac{7}{4} + \frac{63}{32}
				= \frac{56}{32} + \frac{63}{32} = \frac{119}{32}=3\frac{23}{32}$.
		\end{solution}
	\end{problem}

\end{problems}

} %/small


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

\marginpar{Friday\\ 2020-4-10, \\ compiled \\ \today}

We define the \textbf{ellipticity} \(\epsilon = (I_1 - I_2 ) / I_3 \). Typical values of this parameter for astrophysical objects are at most of the order of \num{e-6}, which can be calculated as \(\epsilon \sim ( \delta R / R_0 )^2\), where \(\delta R\) is the scale of the radial anomaly while  \(R_0 \) is the scale of the radius of the object.
For a neutron star this corresponds to ``mountains'' of about \(\delta R \sim \SI{10}{m}\).

Then, we can define a typical amplitude \(h_0 \) as:
%
\begin{align} \label{eq:typical-amplitude-rigid-nonprecessing-body}
h_0 = \frac{4 \pi^2G}{c^{4}} \frac{f_{GW}^2}{r} I_3 \epsilon
\,,
\end{align}
%
where, as usual, \(f_{GW} = \omega_{r} / \pi = 2 f _{\text{rotation}}\).

In terms of typical orders of magnitude, this variable looks like
%
\begin{align}
h_0 \sim \num{e-25} \qty(\frac{\epsilon }{\num{e-6}})
\qty( \frac{I_3}{\SI{e38}{kg m^2}})
\qty( \frac{\SI{10}{kpc}}{r})
\qty( \frac{f_{GW}}{\SI{1}{kHz}})^2
\,.
\end{align}

With this, we can rewrite the amplitudes in the two polarizations as
%
\boxalign{
\begin{align}
h_{+} &= h_0 \frac{1 + \cos^2 \iota }{2} \cos(2 \pi f_{GW} t) \\
h_{ \times } &= h_0 \cos \iota  \sin(2 \pi f_{GW} t)
\,.
\end{align}}

To find the radiated power by this mechanism we can use the quadrupole formula \eqref{eq:radiated-power-GW}:
%
\begin{align}
\dv{E_{GW}}{t} &= \frac{G}{5 c^{5}} \expval{
    \dot{\ddot{M}}_{ij} \dot{\ddot{M}}_{ij} - \frac{1}{3} \underbrace{\qty(\dot{\ddot{M}}_{kk})^2}_{= 0}
}  \\
&= \frac{G}{5c^{5}} 2 \expval{ \dot{\ddot{M}}_{11}^2 + \dot{\ddot{M}}_{12}^2}  \\
&= \frac{2G}{5c^{5}} \qty(4 \omega_{r}^3 (I_1 - I_2 ))^2 \underbrace{\expval{ \cos^2(2 \omega_{r}t) + \sin^2(2 \omega_{r}t)}}_{= 1/2 + 1/2}  \\
&= \frac{32 G}{5 c^{5}} \omega_{r}^{6} \epsilon^2 I_3^2
\,,
\end{align}
%
so by conservation of energy the neutron star will lose just as much energy.
The rotational energy is given by \(E _{\text{rot}} = I_{3} \omega_{r}^2 / 2\), so we have
%
\begin{align}
\dv{E _{\text{rot}}}{t} = - \dv{E_{GW}}{t} &= I_3 \omega_{r} \dot{\omega}_{r}  \\
- \frac{32 G}{5 c^{5}} \omega_{r}^{6} \epsilon^2 I_3^2 &= I_3 \omega_{r} \dot{\omega}_{r}  \\
\dot{\omega}_{r} &= - \frac{32G}{5 c^{5}} \omega_{r}^{5} \epsilon^2 I_3 <0
\,,
\end{align}
%
so, \emph{as opposed to binaries}, the orbit \textbf{slows down} because of GW emission.
Observations of binaries show \(\dot{\omega} \sim - \omega^{n} \) with \(n < 5\), meaning that there probably is another breaking mechanism contributing.

\subsection{Precession}

Now, let us consider a body whose angular momentum \(\vec{J}\) is \emph{not aligned} with its axes of inertia \cite[sec.\ 4.2.2]{maggioreGravitationalWavesVolume2007}.

We want to proceed like we did before, so we will need two reference frames.
The first reference, \(S\), is a frame in which \(\vec{J} = J \hat{z}\); this will be at least approximately an inertial reference frame, so \(\vec{J}\) will be conserved.
The second reference, \(S'\), is the \emph{body frame} of the object, in which it is stationary, and whose axes coincide with the principal axes of rotation.

The transformation between these two frames will be a rotation matrix \(R\) (such that \(x' = R x\)), which we decompose as
%
\begin{align}
R = R_{\gamma }^{(z)} R_{\alpha }^{(x)} R_{\beta }^{(z)}
= \left[\begin{array}{ccc}
\cos \gamma  & \sin \gamma  & 0 \\
- \sin \gamma  & \cos \gamma  & 0 \\
0 & 0 & 1
\end{array}\right]
\left[\begin{array}{ccc}
1 & 0 & 0 \\
0 & \cos \alpha  & \sin \alpha  \\
0 & -\sin \alpha  & \cos \alpha
\end{array}\right]
\left[\begin{array}{ccc}
\cos \beta  & \sin \beta  & 0 \\
- \sin \beta  & \cos \beta  & 0 \\
0 & 0 & 1
\end{array}\right]
\,.
\end{align}

We call the \emph{line of nodes} the intersection between the plane orthogonal to \(x_3 \) and that orthogonal to \(x_3'\).
The \(\beta \) rotation brings \(x_1 \) on the line of nodes, the \(\alpha \) rotation brings \(x_3 \) onto \(x_3'\), the \(\gamma \) rotation aligns \(x_1 \) with \(x_1'\).
In order to understand this, it is customary to look at the figure \cite[fig.\ 4.15]{maggioreGravitationalWavesVolume2007} and fiddle around with your fingers in the ``right-hand-rule'' position.

All three of these angles will in general be time-dependent, and their time evolution will completely determine the motion of the body.

We can recover the angular velocity vector \(\vec{\omega}\) by looking at the components of the three angular velocity vectors in the body frame:
%
\begin{align}
\dv{\vec{\alpha}}{t} &= \dot{\alpha} \left[\begin{array}{ccc}
\cos \gamma  &  - \sin \gamma  &  0
\end{array}\right]^{\top}  \\
\dv{\vec{\beta}}{t} &= \dot{\beta}
\left[\begin{array}{ccc}
\sin \alpha \sin \gamma  & \sin \alpha \cos \gamma  & \cos \alpha
\end{array}\right]^{\top} \\
\dv{\vec{\gamma}}{t} &= \dot{\gamma} \left[\begin{array}{ccc}
0 & 0 & 1
\end{array}\right]^{\top}
\,,
\end{align}
%
so that then  \(\vec{\omega} = \vec{\dot{\alpha}} + \vec{\dot{\beta}} + \vec{\dot{\gamma}}\).
These expressions can be derived geometrically by looking at the figure.
So, in the body frame the components of the angular velocity are
%
\begin{align}
\vec{\omega} = \left[\begin{array}{c}
\dot{\alpha} \cos \gamma + \dot{\beta} \sin \alpha \sin \gamma  \\
- \dot{\alpha} \sin \gamma + \dot{\beta} \sin \alpha \cos \gamma  \\
\dot{\gamma} + \dot{\beta}\cos \alpha
\end{array}\right]
\,.
\end{align}

In the body frame the angular momentum \(\vec{J}\) is \emph{not} conserved: we can recover its time-dependent expression in the body frame \(J'\) by applying a rotation, and then we can use \(J'_i = I_i \omega'_i\): this gives us
%
\begin{align}
J'_1 &= I_1 \omega_1' &&\implies & J \sin \alpha \sin \gamma &= I_1 \qty(\dot{\alpha} \cos \gamma + \dot{\beta} \sin \alpha \sin \gamma ) \\
J'_2 &= I_2 \omega_2' &&\implies & J \sin \alpha \cos \gamma &= I_2 \qty(- \dot{\alpha} \sin \gamma + \dot{\beta} \sin \alpha \cos \gamma) \\
J'_3 &= I_3 \omega_3' &&\implies & J \cos \alpha  &= I_3 \qty(\dot{\gamma} + \dot{\beta} \cos \alpha )
\,.
\end{align}

Now we make the assumption that \(I_1 = I_2 \): we consider an \textbf{axisymmetric body}.
An astrophysical example of this will usually look like an ellipsoid.

Then, we perform the following manipulation (written in a formally peculiar way, which should make it easier to remember --- we are ``applying a rotation matrix to the system of equations''):
%
\begin{align}
&\left[\begin{array}{cc}
\cos \gamma  & \sin \gamma  \\
- \sin \gamma  & \cos \gamma
\end{array}\right]
\left[\begin{array}{c}
J \sin \alpha \sin \gamma = I_1 \qty(\dot{\alpha} \cos \gamma + \dot{\beta} \sin \alpha \sin \gamma ) \\
J \sin \alpha \cos \gamma = I_2 \qty(- \dot{\alpha} \sin \gamma + \dot{\beta} \sin \alpha \cos \gamma)
\end{array}\right] = \\
&= \left[\begin{array}{c}
I_1 \dot{\alpha} \qty(\cos^2 \gamma + \sin^2 \gamma ) = 0 \\
J \sin \alpha \qty(\cos^2\gamma + \sin^2 \gamma ) = \dot{\beta} I_1 \sin \alpha \qty(\sin^2\gamma + \cos^2\gamma )
\end{array}\right] =
\left[\begin{array}{c}
\dot{\alpha} = 0 \\
\dot{\beta} = J / I_1 \overset{\text{def}}{=} \Omega
\end{array}\right]
\,.
\end{align}

So, \(\alpha \) is constant while \(\beta \) changes linearly. We can substitute these relations into the third equation to get
%
\begin{align}
J \cos \alpha &= I_3 \qty(\dot{\gamma} + \frac{J \cos \alpha }{I_1 }) \\
\dot{\gamma} &= \frac{J \cos \alpha }{I_3 } - \frac{J \cos \alpha }{I_1 }
= J \cos \alpha \frac{I_1 - I_3 }{I_1 I_3 } = \Omega \cos \alpha \frac{I_1 - I_3 }{I_3 } \overset{\text{def}}{=} - \omega_{p}
\,,
\end{align}
%
where the sign is a convention, such that when \(I_3 > I_1 \) (an oblate object, like a grapefruit or a coin) we have \(\omega_{p} > 0\).

Now, what do these represent? The fact that \(\dot{\alpha} = 0\) means that the angle between \(x_3 \) and \(x_3'\) stays the same.
The rotation around \(\beta \) is the ``main'' one, as \(\vec{\beta} \) is aligned with \(\vec{J}\), and \(\dot{\beta}= \Omega \gg \abs{\omega_{p}} = \abs{\dot{\gamma}}\) typically.

The rotation around \(\vec{\gamma}\) corresponds to a \emph{precession} of the angular velocity vector around the \(x_3'\) axis: the body's rotation axis precesses around its third principal axis.

Not that this is not the same as the precession of the body axis around the angular momentum.
We should ``clean our minds'' from the idea of a spinning spintop precessing, this is not what is happening here.
This wobbling motion is similar to the one of a coin thrown on a table, although this is a \emph{free} wobble, happening without any external torque.

% Here, the axis going around is the faster motion, the rotation of the body around its axis is slower.

The time evolution of the inertia tensor reads
%
\begin{align}
I (t) = R^{\top} I' R =
R_{\beta }^{\top} R_{\alpha }^{\top} R_{\gamma }^{\top} I'
R_{\gamma } R_{\alpha } R_{\beta }
\,,
\end{align}
%
but the matrices \(R_{\gamma }\) and \(R_{\gamma }^{\top}\) rotate the \(xy\) components of a matrix between each other: if \(I_1 = I_2 \) the components \(I'_{11} = I'_{22}\), so we have \(R_{\gamma }^{\top} I' = I' = I' R_{\gamma }\). So, we can write the expression as
%
\begin{align}
I (t) =
R_{\beta }^{\top} R_{\alpha }^{\top}  I'
R_{\alpha } R_{\beta }
\,,
\end{align}
%
so the only time dependence which is left is inside \(\beta (t) = \Omega t\).
We can expand the calculation, the result is given by Maggiore \cite[eq.\ 4.245]{maggioreGravitationalWavesVolume2007}.
We are only interested in the projection of this variation onto the plane orthogonal to the direction of a propagation.
The amplitudes in the two GW polarizations are also given by Maggiore \cite[eq.\ 4.246 -- 252]{maggioreGravitationalWavesVolume2007}.

% If we compute the evolution of the inertial tensor, we get terms both at \(\omega \) and at \(2 \omega \).

What we find is both emission at \(\Omega \) and at \(2 \Omega \), while the frequency corresponding to the precession \(\omega_{p}\) does not appear:
%
\boxalign{
\begin{align}
h_{+} &= h_0' \qty[ \sin (2 \alpha) \sin \iota \cos \iota \cos(\Omega t)
+ 2 \sin^2\alpha \qty(1 + \cos^2\iota ) \cos(2\Omega t)]  \\
h_{ \times } &= h_0' \qty[\sin(2 \alpha  ) \sin \iota \sin(\Omega t)
+ 4 \sin^2 \alpha \cos \iota \sin(2 \Omega t)]  \\
h_0' &= - \frac{G}{c^{4}} \frac{I_3 - I_1 }{r} \Omega^2
\,,
\end{align}}
%
where this \(h_0'\) should be compared with \eqref{eq:typical-amplitude-rigid-nonprecessing-body}.

\todo[inline]{Not sure about what comparison should be drawn: the formulas are the same with \(\omega_{s} \to \Omega \) and \(I_2 \to I_3 \)\dots}

We have four measurable amplitudes (corresponding to two polarizations and two frequencies), and we need to reconstruct the unknowns \(\alpha \), \(\iota \), \(r\) and \(I_3 - I_1 \).
This would in general be possible, however because of correlations we need to measure one more parameter externally (like the distance \(r\)).

To get an \textbf{intuition} for the biperiodicity: if we have a distribution which looks like a coin (\(I_1 \sim I_2 \ll I_3 \)) then it looks to us like a binary if we look at it from the top (in terms of periodicity at least), so we expect \(2 \omega \) emission, since the system looks the same to us after a rotation of \(\pi \).

If, instead, we look at it from the side, the periodicity is the full period: after half a rotation the coin is edge-on (and this happens every \(\pi \)), but it will appear at two different angles with respect to the vertical direction, so the real periodicity is \(2 \pi \).
Therefore, we both have \(\omega \) and \(2 \omega \) emission.

% If we were able to determine the amplitude at different inclinations, we would be able to determine the inclination \(\iota \).

\subsubsection{Backreaction}

% [formula for back reaction is wrong!]

% In order to calculate the backreaction we assume that the motion is approximately constant during a single period.
The radiated power is given by \cite[eq.\ 4.254]{maggioreGravitationalWavesVolume2007}:
%
\begin{align}
\dv{E _{\text{rot}}}{t} &= - \frac{G}{5c^{5}}
\expval{\dot{\ddot{M}}_{ij} \dot{\ddot{M}}_{ij}}  \\
&= - \frac{2G}{5c^{5}}
(I_1 - I_3 )^2 \Omega^{6}
\sin^2\alpha  \qty(\underbrace{\cos^2\alpha}_{\mathclap{\text{at } \Omega }}  +\underbrace{16 \sin^2\alpha}_{\mathclap{\text{at }2 \Omega }} )
\,.
\end{align}
%
\todo[inline]{Wrong sign in the slides! }

So, we can see that the emission at \(\Omega \) is dominant for \(\alpha \sim 0\) (systems for which \(x_3\) and \(x_3'\) are almost aligned --- the ``coin seen head-on''), while the emission at \(2 \Omega \) is dominant for larger \(\alpha \) (the ``coin seen edge-on'').

The radiated angular momentum is instead given by
%
\begin{align}
\dv{J}{t} &= - \frac{2G}{5c^{5}} \epsilon_{3jk}\expval{\ddot{Q}_{jl} \dot{\ddot{Q}}_{kl}}  \\
&= - \frac{4G}{5c^{5}} \expval{\ddot{M}_{1a} \dot{\ddot{M}}_{2a}}  \\
&= - \frac{2G}{5c^{5}} (I_1 - I_3 )^2 \Omega^{5} \sin^2\alpha \qty(\cos^2\alpha  + 16 \sin^2\alpha ) = \frac{1}{\Omega } \dv{E _{\text{rot}}}{t}
\,,
\end{align}
%
where we swapped \(Q\) for \(M\) since the terms \(\epsilon^{3kl} \delta_{ka} Q_{la} \) and \(\epsilon^{3kl} Q_{kl}\) do not contribute (by symmetry and tracelessness of \(Q\) respectively); also we integrated by parts.\footnote{To move from \(\expval{\ddot{M}_{1a} \dot{\ddot{M}}_{2a} - \ddot{M}_{2a} \dot{\ddot{M}}_{1a}}\) to \(2 \expval{\ddot{M}_{1a} \dot{\ddot{M}}_{2a}}\).}

In order to understand how the rotation decays we need to express this in terms of the angles: recall the definition of \(\Omega = \dot{\beta} = J / I_1 \). This means that
%
\begin{align}
\ddot{\beta} = \frac{1}{I_1 } \dv{J}{t} =
- \frac{2G}{5c^{5}} \frac{(I_1-I_3)^2}{I_1 } \dot{\beta}^{5} \sin^2\alpha \qty(\cos^2\alpha  + 16 \sin^2\alpha )
\,,
\end{align}
%
which tells us that \(\dot{\beta} = \Omega \) is decreasing.

To find the evolution of \(\alpha \) we need to write the rotational energy as
%
\begin{align}
E _{\text{rot}} &= \frac{1}{2} I'_i \omega_{i}^{\prime 2} = \frac{1}{2} \frac{J_i^{\prime 2}}{I_i}
= \frac{J^2}{2} \qty(\frac{\sin^2\alpha \sin^2 \gamma }{I_1 }
+ \frac{\sin^2 \alpha \sin^2 \gamma }{I_2 } + \frac{\cos^2 \alpha }{I_3 } ) \\
&= \frac{J^2}{2} \qty(\frac{\sin^2\alpha }{I_1 } + \frac{\cos^2 \alpha }{I_3 }) \marginnote{\(I_1 = I_2 \).}
\,,
\end{align}
%
which can be differentiated to yield
%
\begin{align}
\dot{\alpha} = - \frac{2G}{5c^{5}} \frac{(I_1 - I_3 )^2}{I_1 }
\dot{\beta}^{4} \sin \alpha \cos \alpha \qty(\cos^2\alpha + 16 \sin^2 \alpha )
\,,
\end{align}
%
so \(\alpha \) also decreases due to GW emission.
This means that the wobble is decreasing, the rotation is aligning with the angular momentum.

However, the combination \(J \cos \alpha \) is constant:
%
\begin{align}
\dv{}{t} \qty(J \cos \alpha ) &= \dv{J}{t} \cos \alpha - J \dot{\alpha} \sin \alpha   \\
\begin{split}
&= - \frac{2G}{5c^{5}} (I_1-I_3)^2 \dot{\beta}^{5} \sin^2\alpha \qty(\cos^2\alpha  + 16 \sin^2\alpha ) \cos \alpha + \\
&\phantom{=}\
- \dot{\beta} I_1 \sin \alpha \qty(- \frac{2G}{5c^{5}} \frac{(I_1 - I_3 )^2}{I_1 }
\dot{\beta}^{4} \sin \alpha \cos \alpha \qty(\cos^2\alpha + 16 \sin^2 \alpha ))
\end{split}  \\
&= 0
\,,
\end{align}
%
which means that \(\omega_{3}' = J \cos \alpha  / I_3 \) is a constant: this is the rotation speed of the body around its axis; \(J \cos \alpha \) is the projection of the angular momentum of the body around its axis \(x_3'\).

% We find differential equations telling us that \(\dot{\beta}
% \) and \(\alpha \) both decrease: the first means that the motion is slowing down; the second means that the wobbling is decreasing, as the rotation is aligning with the angular momentum.

\subsubsection{Backreaction}

In order to study the differential equations for \(\ddot{\beta}\) and \(\dot{\alpha}\) we can define the parameter \(u(t) = \dot{\beta} / \dot{\beta}_{0}\), and a characteristic time \(\tau_0 \):
%
\begin{align}
\tau_0  = \qty( \frac{2G}{5 c^{5}} \frac{(I_1 - I_3 )^2}{I_1  } \dot{\beta}_{0}^{4})^{-1}
\,,
\end{align}
%
which has a typical value of
%
\begin{align}
\tau_0 = \SI{1.8e6}{yr} \qty(\num{e-7} \frac{I_3 }{I_1 - I_3 })^2 \qty( \frac{ \SI{1}{kHz}}{f_0 })^{4} \qty(\frac{\SI{e38}{kg m^2}}{I_1 })
\,,
\end{align}
%
and we can write differential equations for \(\dot{u}\) and \(\dot{\alpha}\) as
%
\begin{align}
\dot{u} &= - \frac{u^{5}}{\tau_0 } \sin^2\alpha  \qty(\cos^2 \alpha + 16 \sin^2\alpha ) \\
\dot{\alpha} &= - \frac{ u^{4}}{\tau_0 } \sin \alpha \cos \alpha
\qty(\cos^2 \alpha + 16 \sin^2\alpha )
\,,
\end{align}
%
with initial conditions at the origin \(u(0) = 1\) (meaning \(\beta = \beta_0 \)) and \(\alpha(0) = \alpha_0 \).

We have shown that \(J \cos \alpha \) is a constant: this means that we must have \(\dot{\beta} \cos(\alpha ) = \const\).
This can aid us in the search of a steady state, by providing a constraint. The constant can be calculated at any time, so we compute it at \(t = 0\): then we get \(\dot{\beta}_{0} \cos(\alpha_0 ) = \cos(\alpha_0 )=  \const\).

This implies that the boundary condition at infinity must satisfy \(u_{ \infty } \cos(\alpha_{ \infty }) = \cos \alpha_0 \), which in general is different from 0 (unless \(\alpha_0 = \pi /2\), but it can be shown that this is an unstable equilibrium).

Having a steady state means that we require \(\dot{\alpha} = \dot{u} = 0\).
Since the factor \(\cos^2 + 16 \sin^2 \) is always positive for \(\alpha \in [0, \pi ]\) this can be either satisfied by \(u = 0\) or \(\sin \alpha = 0\), meaning \(\alpha = 0\) or \(\pi \).

The condition \(u = 0\) cannot in general obey the \(J \cos \alpha \) constraint, so we are left with \(\alpha = 0, \pi \).

\todo[inline]{Can we discard \(\alpha > \pi /2\) because otherwise we could just flip the axes until it became \(\alpha < \pi /2\)?}

So, we get the asymptotic state
%
\begin{align}
\alpha_{ \infty } = 0
\qquad \text{and} \qquad
u_{ \infty } = \cos \alpha_0
\,,
\end{align}
%
and the way \(\alpha \) approaches this value asymptotically is
%
\begin{align}
\dot{\alpha} \sim \alpha \frac{ u^{4}_{ \infty }  }{\tau_0 }
\qquad \text{as} \qquad
t \to \infty
\,,
\end{align}
%
so asymptotically the decay is exponential, with a timescale \(\sim \tau_0 / u_{ \infty }^{4} \gtrsim \tau_0 \).

\subsection{Observations}

The conditions we discussed do not apply in general: first of all, neutron stars are not truly rigid bodies since they have an internal structure.
Even if they were, a generic rigid body's principal axes are all different. Maggiore discusses the triaxial case briefly \cite[pagg.\ 211--214]{maggioreGravitationalWavesVolume2007}.

In the triaxial case we will have emission at different frequencies, for example \(2 \omega_{r} \), \(2 \omega_{r} + \omega_{p} \), \(2 (\omega_{r} + \omega_{p})\).
There are even more: for each base frequency \(\omega \), radiation is emitted with decreasing amplitude for \(\omega + n \omega_{p}\), \(n \in \mathbb{N}\).

We have not seen pulsars yet in GW, but we can put upper bounds to the amplitude of their emission.
What we do is to search for \textbf{quasi-stationary} GW signals close to known pulsars, accounting for the modulations due to the proper motion of the Earth, of the source etc.
There are about 400 pulsars in the LIGO-Virgo bandwidth which would be eligible for this kind of observation.

``Beating the spin-down limit'' means that we know that we would be able to see the GW emission in a certain case if the spin-down was only due to GW.
We have beaten it by a factor 10 for the Crab and Vela pulsars: a very tiny fraction \(\lesssim \SI{1}{\percent}\) of the rotational energy is lost to GW.

\emph{Scorpius X-1} is low-mass X-ray binary: we see X-ray emission caused by accretion of the NS from the companion.
This is a plausible mechanism for the deformation of the NS.
We know its position and orbital period, not its spin frequency!
The amplitude of its GW emission is expected to be of the order of \(h_0 \sim \num{5e-25}\).

\todo[inline]{What is this bit about? It does not seem really relevant.}

Could we differentiate a pulsar rotating and seen head-on and a binary system?
Surely they are phenomena which happen in different frequency ranges, and last for different times.
If the binary is spinning at those frequencies it's evolving very rapidly, instead a pulsar can give out a stable signal.

Also, in full numerical relativity the waveform looks different.

\end{document}


\documentclass[12pt]{article}
\usepackage{fullpage}
\usepackage{framelab}
\usepackage{verbatim}

\title{FrameLab: Development Guide}
\date{\today}

\begin{document}
\maketitle

\section{Overall Design}
FrameLab 1.0 is designed to have an object-oriented, user friendly scripting interface with compute intensive routines written in compiled languages such as C and CUDA/C.  The current scripting language is Matlab, using MEX as an interface mechanism to pull in compiled libraries.  In the future we plan to implement Python/iPython as an alternative to Matlab, to keep the entire code open-source.

\section{Matlab Object Oriented System}
The current goal of Framelab is to solve approximate versions of linear inverse problems of the sort
\begin{align}
\mathcal{A}u = f \label{IDLIP}
\end{align}Through some discretization, \eqref{IDLIP} is approximated by a finite dimensional linear system
\begin{align}
A\textbf{u} = \textbf{f}\label{FDLIP}
\end{align}To handle more general and complicated problems of this type, we define an object-oriented system where $A$, $\textbf{u}$ and $\textbf{f}$ are \textbf{abstract} data types instead of simply matrices and vectors.
\begin{enumerate}
\item DataTypes: To allow for a flexible modeling system, for each problem of type \eqref{IDLIP},\eqref{FDLIP} we create an abstract data type for both $\textbf{u}$ and $\textbf{f}$.
\item Operators: To model the linear operator $A$, we again use abstract data types.  Thus we define a class for each $A$, for example the ConeBeamScanner transform class.
\end{enumerate}

\section{Compute Kernels}
\subsection{Computed Tomography}
From \cite{gaocode}

\paragraph{Compiling MEX Libraries}

\begin{verbatim}
mex -L"/usr/local/cuda/lib64" -lcudart -I"./" Ax_fan_mf.cpp Ax_fan_mf_cpu_siddon.cpp
 Ax_fan_mf_cpu_new.cpp Ax_fan_mf_cpu_new_fb.cpp Ax_fan_mf_gpu_siddon.cu
 Ax_fan_mf_gpu_new.cu Ax_fan_mf_gpu_new_fb.cu find_area.cpp sort_alpha.cpp
\end{verbatim}

Possible error message about invalid conversion fron int to mxComplexity: change

\begin{verbatim}
plhs[0]=mxCreateNumericMatrix(nx*ny*nt,1,mxSINGLE_CLASS,0);
\end{verbatim}

to

\begin{verbatim}
plhs[0]=mxCreateNumericMatrix(nx*ny*nt,1,mxSINGLE_CLASS,mxREAL);
\end{verbatim}

in any mex interface files

\paragraph{Alternating Direction Method of Multipliers}
Recall that ADMM is designed to solve problems of the sort
\begin{align}
(x^*,y^*) : = \argmin_{x,y} F(x)+G(y)\quad \st\quad  Ax+By = b \tag{$\mathcal{P}$}
\end{align} The approach is to consider the Augmented Lagrangian:
\begin{align*}
\L_\rho(x,y,\lambda) : = F(x)+G(y) + \left\langle \lambda, Ax+By-b\right \rangle +\frac{\rho}{2}\|Ax+By-b\|_2^2
\end{align*} We then consider the saddle point problem
\begin{align}
(x^*,y^*,\lambda^*)_\rho = \argmin_{(x,y)}\argmax_\lambda \L_\rho(x,y,\lambda)\label{saddlept}
\end{align}  Since we are interested in the saddle point itself and not the value of the functionals, we may complete the square in the definition of $\L_\rho$ to obtain
\begin{align*}
\eqref{saddlept} = \argmin_{(x,y)}\argmax_\lambda F(x) + G(y) +\frac{\rho}{2}\|Ax+By-(b-\lambda/\rho)\|_2^2
\end{align*}For notational convenience, we define
\begin{align*}
\L_\rho^*(x,y,\lambda): =  F(x) + G(y) +\frac{\rho}{2}\|Ax+By-(b-\lambda/\rho)\|_2^2
\end{align*}

 If we then perform coordinate descent/ascent, we arrive at the 3-step ADMM scheme:
\begin{align*}
\left\{\begin{array}{ll}
x^{(k+1)} &= \argmin_x \L_\rho^*(x,y^{(k)},\lambda^{(k)}) \\
y^{(k+1)} &= \argmin_y \L_\rho^*(x^{(k+1)},y,\lambda^{(k)})\\
\lambda^{(k+1)} &= \argmax_\lambda \L_{\rho}^*(x^{(k+1)},y^{(k+1)},\lambda)
\end{array}\right.
\end{align*} The method can be generalized in the particular case that $F(x)+G(y)$ is further separable, e.g. $F(x)+G(y) = F_1(x_1)+F_2(x_2)+\ldots+F_n(x_n)$, with $A\textbf{x}=\textbf{b}$, where $\textbf{x} = (x_1,\ldots,x_n)^T$.  The augmented Lagrangian then takes the form
\begin{align*}
\L_\rho (\textbf{x},\Lambda) : = \sum F_i(x_i) + \left\langle \Lambda,A\textbf{x}-\textbf{b}\right\rangle +\frac{\rho}{2}\|A\textbf{x}-\textbf{b}\|_2^2
\end{align*} where $\Lambda = (\lambda_1,\ldots,\lambda_n)^T$.

In FrameLab, we have implemented an ADMM object designed to solve problems of the type $\mathcal{P}$.
\section{Another Section}

\bibliographystyle{plain}
\bibliography{/home/nick/Documents/research/bib}

\end{document}


\documentclass{article}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\begin{document}
\title{Verification of SINR Values for Path Gain in the METIS Simulation}
\author{Michael Meier\\ Research Group Computer Networks\\ University of Paderborn}
\maketitle

\section{Introductory Notes}
	The following sections document the verification process for the \emph{Path Gain} computations in the METIS simulation. The goal is testing whether SINR values are computed correctly for uplink as well as downlink computations for a small scenario with only the path gain/path loss equations of the METIS model.
	\subsection{Simulations}
	The simulations were run with the slighly modified code from the \texttt{verify\_pathloss} branch of the simulator repository. In this branch, all compuations safe the path loss are commented out. Additionally, all BS/MS pairs are considered to have \emph{Line of Sight}.
	\subsection{Scenario}
	The scenario consists of two cells with one base station and two mobile stations each. Table \ref{trans:positions} shows the positioning of base and mobile stations. Multiple, randomized simulation runs were not necessary because all path loss based SINR compuations are deterministic.
	\begin{table}
		\centering
		\label{trans:positions}
		\caption{Transmitter positions in the simulated scenario.}
		\begin{tabular}{ccc}
			\toprule
			Transmitter & X & Y\\
			\midrule
			$BS_{0}$ & $30.0$ & $30.0$ \\
			$BS_{1}$ & $75.0$ & $75.0$ \\
			$MS_{00}$ & $30.0$ & $44.0$ \\
			$MS_{01}$ & $30.0$ & $49.0$ \\
			$MS_{10}$ & $75.0$ & $89.0$ \\
			$MS_{11}$ & $75.0$ & $94.0$ \\
			\bottomrule
		\end{tabular}
	\end{table}
	Also important to note is the carrier frequency $f_c=\SI{3.5}{\giga \hertz}$

	\subsection{Equations}
	Distances between senders and receivers were computed using the \emph{Pythagorean theorem}. The path loss calculations themselves were conducted manually using the equations given for the METIS model in Table 7-11 in \cite{METIS1.2}.

	Since the simulation software uses path gain instead of loss internally, the path loss values $P_l$ computed by hand had to be changed like this:
	\begin{equation}
	\label{gaineq}
	P_g = \frac{1}{10^{\frac{P_l}{10}}}
	\end{equation}

	To arrive at the interference value for a particular sender/receiver pair, the \emph{Johnson-Nyqist} noise of $7.4555035\cdot10^{-16}$ was added to the path gain values of all possible interferers. For the uplink, this would be the path gain between the base station and all mobile stations from neighbouring cells. Here, we assume all transmissions occur in the same frequency block and thus interference will always occur. For the downlink, the interference is equal to the path gain between the receiving mobile station and all base stations in neighbouring cells.

	The results of the computations can be found in tables \ref{downlink} and \ref{uplink}. Here, the \emph{SINR} column contains the manually computed values, while the \emph{SINR Simulation} column contains the values from the simulation run.

\begin{table}[h!]
  \begin{center}
    \caption{Verification of simulation values against manual computations for path gain on the downlink.}
    \label{downlink}
    \pgfplotstabletypeset[
      multicolumn names,
      col sep=tab,
      %skip first n=1,
	  %columns={MS,BS,d2d,d3d,},
	  columns/MS/.style={verb string type},
      every head row/.style={
		before row={\toprule},
		after row={\midrule}}, % have a rule at top
	  every last row/.style={after row=\bottomrule} % rule at bottom
    ]{computation_tables_down.txt} % filename/path to file
  \end{center}
\end{table}

\begin{table}[h!]
  \begin{center}
    \caption{Verification of simulation values against manual computations for path gain on the uplink.}
    \label{uplink}
    \pgfplotstabletypeset[
      multicolumn names,
      col sep=tab,
      %skip first n=1,
	  %columns={MS,BS,d2d,d3d,},
	  columns/MS/.style={verb string type},
      every head row/.style={
		before row={\toprule},
		after row={\midrule}}, % have a rule at top
	  every last row/.style={after row=\bottomrule} % rule at bottom
    ]{computation_tables_up.txt} % filename/path to file
  \end{center}
\end{table}

\begin{thebibliography}{9}

\bibitem{METIS1.2}
  METIS Project,
  Deliverable D1.2: Initial Channel Models Based on Measurements,
  2014.

\end{thebibliography}
\end{document}


\section{Digital Signal Processing}
Digital Signal processing (DSP) is an engineering field focused on analyzing and altering digital signals. It takes real-world signals like voice, audio, video and then mathematically manipulates them~\cite{dsp}. \par

Signals need to be processed so that the information they contain can be displayed, analyzed or converted to another type of signal. Analog-to-Digital converters take signals from the real-world and turn them into binary digital format. At this point, the DSP takes over by capturing the digitized information and processes it, later to be fed back for use in the real-world. \par

\subsection{Sound}
\par
Sound is produced when something vibrates. The vibration causes the medium around it to vibrate as well. Vibrations propagated through air are called traveling longitudinal waves~\cite{physics_of_sound}, which we can hear.
A sound wave is made out of two areas of high and low pressure called compressions and rarefactions (figure 3). \par

The pattern of the wave repeats after one wavelength. The height of the wave is called \textbf{amplitude}. It is what determines how loud the sound will be (the greater the amplitude, the louder the sound).

The wavelength and the speed of the wave determine the pitch (frequency of the sound). \par

\begin{equation}
c = f \cdot \lambda \textnormal{, where $c=speed$, $f=frequency$, $\lambda=wavelength$}
\end{equation}

\begin{figure}[h]
	\caption[Traveling Wave]{
		Traveling wave components~\cite{traveling_wave} }
	\centering
	\includegraphics[width=1\textwidth, height=\textheight, keepaspectratio]{Wavelength}
\end{figure}

\subsection{Pitch}
In music, the pitch tells how low or high a note is. In physics, it is measured in a unit called Hertz (Hz) and it is known as frequency. A note that vibrates at 256Hz will be caused by a sound wave vibrating at 256 times/second. \par

The speed is influenced by the medium in which the sound wave travels. Under standard conditions of temperature and pressure, sound is speed is 343 meters per second~\cite{speed_of_sound}.

The equation (5) can be rewritten as:
\begin{equation}
f = \dfrac{c}{\lambda} \textnormal{, where $c=speed$, $f=frequency$, $\lambda=wavelength$}
\end{equation}

\subsection{Discrete Fourier transformation}
The Discrete Fourier Transformation (DFT) is one of the most important operation of DSP. It is any quantity or signal that varies over time, such as the pressure of a sound wave, sampled over a finite time interval (often defined by a window function)~\cite{discrete}.
\par

\begin{equation}
X[k] = \dfrac{1}{N} \sum_{j=0}^{N-1}(x[j] \cdot e^ {-j \cdot( \dfrac{2\pi}{N}) ) \cdot n \cdot k }  \text{ for $k = 0...N$-1}
\end{equation}

The DFT shows what frequencies are present in your signal and in what proportions.
\par
It has a complexity of $O(n^2)$ so in practice, the Fast Fourier Transform (FFT) algorithm is used instead. FFT runs in $O(n\cdot log(n))$.

\subsection{Fast Fourier transform}
The fast Fourier transform(FFT) computes the DFT of a sequence, or its inverse (IDFT)~\cite{FFT}. It rapidly computes such transformations by factorizing the DFT matrix into a product of sparse factors. As a result, it manages to reduce the complexity of computing the DFT from $O(n^2)$ to $O(n\cdot log(n))$, where n is the data size. The difference in speed can be huge, especially for large data sets where n can reach thousands of millions. Because of this, FFTs are widely used for applications in engineering, science and mathematics.

\subsection{Short-Term Fourier transform}
While DFT is really good by itself, if used on an entire song it would only tell what frequencies exist, but not when they occur. This is where Short-Term Fourier Transform (STFT) comes in handy. It computes DFT over a full signal but in small segments. Because of this, we can see how frequencies change over time, which makes it a good way to compute spectrograms. (Figure 4)

\begin{figure}[h]
	\caption[Spectrogram using Short-Term Fourier Transform]{ Spectrogram using STFT~\cite{stft_fig}}
	\centering
	\includegraphics[width=1\textwidth, height=\textheight, keepaspectratio]{"resources/STFT_spectrogram"}
\end{figure}

\subsection{Constant-Q transform}
In general, the transform is well suited to musical data, and this can be seen in some of its advantages compared to the fast Fourier transform. As the output of the transform is effectively amplitude/phase against log frequency, fewer frequency bins are required to cover a given range effectively, and this proves useful where frequencies span over several octaves. As the range of human hearing covers approximately ten octaves from 20 Hz to around 20 kHz, this reduction in output data is significant~\cite{constant_q}. \par
 See Figure 5 for a comparison between the Constant-Q transform and STFT.
%work on this more

%maybe change this later
\begin{figure}[h]
	\caption[Constant Q vs STFT spectrogram of C major scale]{ Constant Q (left) vs STFT (right) spectrogram of C major scale}
	\centering
	\label{fig:cq_vs_stft}
	\includegraphics[width=1\textwidth, height=\textheight, keepaspectratio]{"resources/Q_vs_STFT"}
\end{figure}


\chapter{Abstract Refinement Types}\label{chapter:abstractrefinements}
\makequote
{The purpose of abstraction is not to be vague,\\
but to create a new semantic level in which one can be absolutely precise.}
{Edsger W. Dijkstra}

\renewcommand{\reft}{\ensuremath{e}\xspace}
\renewcommand\tref[2]{\ensuremath{\left\lbrace \vref : #1\mid #2\right\rbrace}}
\renewcommand\tref[2]{\ensuremath{\left\lbrace \vref : #1\mid #2\right\rbrace}}

\renewcommand\subt{\preceq}
\renewcommand\corelan{$\lambda_\downarrow$\xspace}
\renewcommand\sub[2]{\ensuremath{ \left[ #1 \mapsto #2 \right] }}
\renewcommand\shape{\ensuremath{\text{shape}}\xspace}
\renewcommand\tfun[3]{\ensuremath{{(#1:#2)} \rightarrow #3}}

\renewcommand\ecase[5]{\ensuremath{
	\mathtt{case}\ #5 = #1\ \mathtt{of}\ \{ #2\ #3 \rightarrow #4\}
}}

\renewcommand\corelan{$\lambda_{P}$\xspace}

\input{text/abstractrefinements/intro}
\input{text/abstractrefinements/overview}
\input{text/abstractrefinements/typechecking}
\input{text/abstractrefinements/experiments}
\input{text/abstractrefinements/conclusion}

\mypara{Acknowledgments}
The material of this chapter are adapted from the following publication:
\noindent N. Vazou, P. Rondon, and R. Jhala,
``Abstract Refinement Types'',
ESOP, 2013.