% ----------------------------------------------------------------
% Article Class (This is a LaTeX2e document)  ********************
% ----------------------------------------------------------------
\documentclass[11pt]{article}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm, amssymb}
\usepackage{amsfonts}
\usepackage{multirow}
\usepackage{threeparttable}

%Candelaria's favorite packages
\usepackage{setspace}	% Set the spacing for the document
\usepackage{xtab}		% Use for tables
\usepackage{comment}	% Use for block comments
\usepackage{rotating}	% Helpful for rotating figures
\usepackage{lscape}	% Change a page into landscape
\usepackage{hyperref}
\hypersetup{colorlinks=false,pdfborder={0 0 0},breaklinks=true}
\usepackage{graphicx}	% Load a graphic image
%\usepackage{url}		% Use for formatting URLS (nice for NatBib also)
\usepackage{booktabs}  	% Use for nice tables/ Works well with ESTOUT
\usepackage{longtable} 	% Used to break long tables over multiple pages
\usepackage{caption}
\usepackage{subcaption} 	% Used to create SubFloats
\usepackage{listings} 	% Use to enter code blocks, like a fancy verbatim
\usepackage{enumerate}
% ADD COLOR:
\usepackage{color}
\usepackage[usenames, dvipsnames, svgnames, table]{xcolor}

% Packages for the bibliography
\usepackage[longnamesfirst]{natbib}
%\usepackage{natbib}

% Set Page Margins
%\usepackage{fullpage}
\addtolength{\oddsidemargin}{-.875in}
\addtolength{\evensidemargin}{-.875in}
\addtolength{\textwidth}{1.75in}
\addtolength{\topmargin}{-.875in}
\addtolength{\textheight}{1.75in}

% Set line and table spacing
\renewcommand{\baselinestretch}{1.0}
\renewcommand{\arraystretch}{1.1}
\setlength\abovedisplayskip{0pt}
\setlength\belowdisplayskip{0pt}

% Redefine the cite command
\renewcommand\cite{\citet}

%\setlength{\parindent}{0in}

%\setlength{\leftmargin}{0pt} \setlength{\parskip}{1.1ex} \setlength{\parindent}{1em} \setlength{\itemsep}{0pt} \setlength{\footnotesep}{10pt}
%\renewcommand{\footnoterule}{\rule{3in}{.3pt}\vspace{-.3pt}}

% THEOREMS -------------------------------------------------------
\newtheorem{thm}{Theorem}[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\theoremstyle{remark}
\newtheorem{rem}[thm]{Remark}
%\numberwithin{equation}{section} %Number equations within section
% ----------------------------------------------------------------

%%%%%%TYPESET LINEAR EQUATIONS
\usepackage{environ}

\makeatletter

\newcommand{\LinearSystems@SetupLets}{%
  \let\col=&%
  \let\+=+%
  \let\-=-%
  \let\===%
}
\newcommand{\LinearSystems@SetupCatcodes}{%
  \catcode`\&=\active
  \catcode`\+=\active
  \catcode`\-=\active
  \catcode`\==\active
}
\newcommand{\LinearSystems@Setup}{}
\begingroup
  \LinearSystems@SetupCatcodes
  \gdef\LinearSystems@Setup{%
    \LinearSystems@SetupLets
    \LinearSystems@SetupCatcodes
    \newcommand&[1][0pt]{\col\hspace{##1}\col}%
    \def+{\col\+{}{}\col}%
    \def-{\col\-{}{}\col}%
    \def={\col\={}{}\col}%
  }
\endgroup

\NewEnviron{LinearSystems}[1]{\begin{alignat*}{#1}\BODY\end{alignat*}}
\let\LinearSystems@OriginalBegin\LinearSystems
\def\LinearSystems{\LinearSystems@Setup\LinearSystems@OriginalBegin}

\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% COMMANDS FOR JUSTIFYING MATRIX ELEMENTS AND FOR CREATING
%% AUGMENTED MATRICES
% The following code redefines the matrix environment, such
% that we can left or right justify the contents in a matrix

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%

% Commands for the differential in integration
\newcommand*\diff{\mathop{}\!\mathrm{d}}
\newcommand*\Diff[1]{\mathop{}\!\mathrm{d^#1}}

\begin{document}

\begin{center}
{\huge Calculus Lecture Notes\footnote{Contributor(s): Chris Candelaria, Erin Fahle, June John and Klint Kanopka. If you find errors, please let Klint know so that he may correct them. Thanks!}} \\[5pt]
{\Large Stanford GSE Math Camp 2019 \\[5pt]
Do Not Distribute Outside GSE}
\end{center}

\section{Motivation}

Calculus can be divided into two main branches: differential and integral calculus. It pertains to the study of (infinitesimal) change. The use of calculus spans a variety of disciplines including economics; for example, for optimization. Thus, it can be helpful to remember these fundamentals, as several courses (e.g. the 102 Econ sequence or 202N Econ) assume working knowledge of calculus.

\section{Differentiation}
\begin{itemize}
\item Our goal will be to find the rate of change of one quantity compared to another
\item \textbf{Key definitions/notations:}
\begin{itemize}
\item Slope: the concept of slope as rate of change is important. For a straight line, the slope is \begin{center} {\LARGE $\frac{\text{rise}}{\text{run}} $} = {\LARGE $\frac{\text{change in y}}{\text{change in x}} $} = {\LARGE
$\frac{\Delta{y}}{\Delta{x}}$ }\end{center}
However, for other functions, the slope will not be constant. Therefore, we use the derivative of the function.
\item Derivative: can be thought of as the slope of a tangent line at a point on a function. The derivative tells you the rate of change at a point. It is denoted by {\LARGE $ \frac{\textit{dy}}{\textit{dx}}$} or f'(x) or y'. The value of the derivative may change for different values of x. In the graph below, we see that the derivative of function f(x) is positive, then 0, then negative (from left to right).

\end{itemize}
\begin{center}
\includegraphics[scale=0.5]{img/calculus_differential1.jpg}\\
\end{center}

Consider the graph below. The derivative can be thought of as a limit of the difference in f(x) between a point of interest \textit{a} and another point, \textit{a+h}. A line through these two points is a secant with a slope, or the difference quotient: \begin{center}\LARGE{$\frac{f(a+h)-f(a)}{a+h-a} = \frac{f(a+h)-f(a)}{h}$} \end{center}
As \textit{h} gets smaller, this equation approximates the slope of a tangent at point \textit{a}, the derivative of f(x) at point \textit{a}. This will yield the derivative, as denoted below.\\
\begin{center}\LARGE{$\lim_{\Delta h\rightarrow 0}\frac{f(x+h)-f(x)}{h}$} \end{center}
\begin{center}
\includegraphics[scale=0.5]{img/calculus_diffquotient.jpg}\\
\end{center}
\item \textbf{Common differentiation rules}\\
\begin{enumerate}
\item $(af)'=a(f')$\\
\item $(f+g)'=f'+ g'$\\
\item $(f-g)'=f'- g'$\\
\item Product rule for $h(x)=f(x)g(x):  h'(x)=f'(x)g(x) + f(x)g'(x)$\\
\item Chain rule for $h(x)=f(g(x)): h'(x)=f'(g(x))g'(x)$\\
\item Exponents: If $f(x)=x^n$ then $f'(x)=nx^{n-1}$ and when n=0, f'(x)=0\\
\item Log rules: $\frac{d}{dx} ln\;x = \frac{1}{x}$ and $\frac{d}{dx}e^{cx}=ce^{cx}$
\\
\end{enumerate}
\end{itemize}

\section{Integration: Introduction}
\begin{itemize}
\item Our goal will be to find the area of a region $S$ that lies under the curve $f(x)$ from points $a$ to $b$.
\item Suppose our function of interest is $f(x) = x^2 + 1$ on $x\in[0,2]$. Let's define the shaded region under $f(x)$ as $S$. \\
\begin{center}
\includegraphics[scale=0.5]{img/integrals_mainfunction.pdf}\\
\end{center}
How can we find the area of $S$? We have a few options:
\begin{enumerate}
\item Rectangle method using right-hand endpoints: \\
\begin{center}
\includegraphics[scale=0.5]{img/integrals_rectangleR.pdf}
\end{center}
\begin{align*}
Area(S) &= \frac{1}{2}f\left(\frac{1}{2}\right) + \frac{1}{2}f\left(1\right) + \frac{1}{2}f\left(\frac{3}{2}\right) + \frac{1}{2}f\left(2\right) \\
&= \frac{1}{2}\left(\frac{5}{4}\right) + \frac{1}{2}\left(2\right) + \frac{1}{2}\left(\frac{13}{4}\right) + \frac{1}{2}\left(5\right) \\
&= 5.75
\end{align*}
\item Rectangle method using left-hand endpoints: \\
\begin{center}
\includegraphics[scale=0.5]{img/integrals_rectangleL.pdf}\\
\end{center}
Calculate $Area(S)$.
\item Rectangle method using midpoints: \\
\begin{center}
\includegraphics[scale=0.5]{img/integrals_midpoint.pdf}\\
\end{center}
Calculate $Area(S)$.
\item Which other shapes might we try?
\end{enumerate}
\item While we can use shapes like rectangles, our estimate of the area will be imprecise. One thing we might want to do is divide up our region into more parts. For example, using rectangles:
\begin{center}
\includegraphics[scale=0.5]{img/integrals_morerectangleR.pdf}
\includegraphics[scale=0.5]{img/integrals_morerectangleL.pdf}\\
\includegraphics[scale=0.5]{img/integrals_moremidpoint.pdf}\\
\end{center}
While dividing the region may get us closer to the true answer, it is still not exact.
\end{itemize}

\section{Indefinite Integrals: The Connection to Derivatives}
\begin{itemize}
\item We want to find a function $F$ for which $f$ is its derivative. Note that $F$ is called the \textit{antiderivative} of $f$. We can write this as:
$$
F' = f
$$
\item \textbf{Definition}: If $F$ is the antiderivative of $f$, then $F$ is called the indefinite integral of $f$:
$$
F(x) = \int f(x) \diff x
$$
Example. Let $f(x) = 6x$. We want to find $F(x) = \int 6x \diff x$. There are many potential solutions:
\begin{enumerate}
\item $3x^2 + 1$
\item $3x^2 + 2$
\item $3x^2 + 100$, etc.
\end{enumerate}
\textbf{IMPORTANT}: The derivative a function can have many antiderivatives. With any antiderivative, we need to add a constant $c$, unless we are told that the antiderivative passes through a particular point.

The correct solution to our example problem, in the absence of any additional information, is $3x^2 + c$

\item \textbf{Some rules for integration}
\begin{enumerate}
\item $\displaystyle
\int [(f(x) + g(x)] \diff x = \int f(x) \diff x + \int g(x) \diff x
$
\item $\displaystyle
\int c f(x) \diff x = c \int f(x) \diff x
$
\item $\displaystyle
\int x^n \diff x = \frac{x^{n+1}}{n+1} + c
$
\item $\displaystyle
\int \frac{1}{x} \diff x = \ln|x| + c
$
\item $\displaystyle
\int e^x \diff x = e^x + c
$
\item $\displaystyle
\int e^{f(x)} f'(x) \diff x = e^{f(x)}+c
$
\item $\displaystyle
\int [f(x)]^nf'(x) \diff x = \frac{1}{n+1}[f(x)]^{n+1}+c
$
\item $\displaystyle
\int \frac{f'(x)}{f(x)} \diff x = \ln f(x) + c
$
\end{enumerate}
\end{itemize}

\section{Definite Integrals: Calculating the Area under a Function}
\begin{itemize}
\item We return to our initial problem of trying to calculate the area under a curve. \item Using an approximation method (i.e., one of the rectangle methods), we get close, but we want an exact answer.
\begin{itemize}
\item The rectangle approximation method is an application of a Riemann sum
$$
Area(S) = \sum_{i=1}^n \underbrace{f(x_i)}_{height} \underbrace{\Delta x}_{base}
$$
\item How above making the base of the rectangles infinitesimally small? We can use limits:
$$
Area(S) = \lim_{\Delta x\rightarrow 0} \sum_{i=1}^n \underbrace{f(x_i)}_{height} \underbrace{\Delta x}_{base}
$$
\end{itemize}
\item The Riemann Integral is the solution to our problem!
$$
\int_a^b f(x) \diff x = \lim_{\Delta x\rightarrow 0} \sum_{i=1}^n f(x_i) \Delta x
$$
\item The Riemann Integral is often referred to as the definite integral in calculus textbooks. Formally,  $\displaystyle \int_a^b f(x) \diff x$  denotes integral of function $f$ from $a$ to $b$ (or the area under curve $f(x)$ from $x=a$ to $x=b$.
\end{itemize}
\section{The Relationship Between Integration and Differentiation}
\begin{itemize}
\item \textbf{Fundamental Theorem of Calculus I (FTC I)}: If $f$ is continuous on $[a,b]$, then the function $g$ defined by
$$
g(x) = \int_a^x f(t) \diff t \quad \text{for} \; a\leq x \leq b
$$
is an \textit{antiderivative} of $f$.

That is, $g'(x)=f(x)$ for $a\leq x \leq b$, which can also be written as:
$$
g'(x) = \frac{\diff g(x)}{\diff x} = \frac{\diff}{\diff x}\int_a^x f(t) \diff t = f(x)
$$
when $f$ is continuous.
\\[15pt]
Let's examine this graphically.
\begin{itemize}
\item In the figure below, notice that $g(x)$ is the light-shaded area under the curve $f(x)$ and above the interval $[a,x]$.
\item Also notice that $g(x+h)$ is the area under the curve $f(x)$ and above the interval $[a,x+h]$, which is represented as the area of the light shaded region plus the area of the dark shaded region.
\item Therefore, $g(x+h) - g(x)$ is the dark shaded region under the curve $f(x)$ above the interval $[x,x+h]$.
\item For small values of $h$, the area of the dark shaded region is \textit{approximately} equal to the area of the rectangle of height $f(x)$ with base $h$ (i.e., the area is $f(x)\cdot h$). On the figure, you can see the outline of the rectangle to which I am referring.
\item Why is this so special? Recall the formal definition of the derivative:
$$
g'(x) = \lim_{h \rightarrow 0} \frac{g(x+h)-g(x)}{h}
$$
We just argued that for small $h$, $g(x+h) - g(x) \approx f(x)h$.
Therefore, for small $h$,
$$
g'(x) \approx \frac{f(x)h}{h}=f(x)
$$
When we apply the limit (instead of small values of $h$), we obtain equality:
$$
g'(x) = \lim_{h \rightarrow 0} \frac{g(x+h)-g(x)}{h} = f(x)
$$
This is quite an incredible result!
\end{itemize}
\begin{center}
\includegraphics[scale=0.5]{img/FTC_I.pdf}
\end{center}
\item \textbf{Fundamental Theorem of Calculus II (FTC II)}: Suppose $f$ is continuous on $[a,b]$,
$$
\int_a^b f(x) \diff x = F(b) - F(a)
$$
where $F$ is any antiderivative of $f$. That is, $F' = f$.

FTC II provides a way to calculate a definite integral:
\begin{enumerate}
\item Find the indefinite integral $F(x)$
\item Evaluate $F(b) -F(a)$
\end{enumerate}

\item \textbf{Some properties of definite integrals}
\begin{enumerate}
\item $ \displaystyle
\int_a^a f(x) \diff x = 0 \quad \text{No area under a point.}
$
\item $ \displaystyle
\int_a^b f(x) \diff x = -\int_b^a f(x) \quad \text{Switching limits changes sign of the integral}
$
\item $ \displaystyle
\int_a^b [\alpha f(x) + \beta g(x)] \diff x = \alpha \int_a^b f(x) \diff x + \beta \int_a^b g(x) \diff x
$
\item $ \displaystyle
\int_a^b f(x) \diff x + \int_b^c f(x) \diff x = \int_a^c f(x) \diff x
$
\end{enumerate}
\end{itemize}

\section{U--Substitution}
\begin{itemize}
\item Look for integral that we can write in the form:
$$
\int f(g(x))g'(x) \diff x
$$
If $F'=f$, then
$$
\int F'(g(x))g'(x) \diff x = F(g(x)) + c
$$
\item Why? Let's examine the chain rule from differential calculus. By the chain rule, we have
$$
\frac{\diff}{\diff x}[F(g(x))] = F'(g(x))g'(x)
$$
If we make the change of variable $u = g(x)$, then we have:
\begin{align*}
\int F'(g(x))g'(x) \diff x &= F(g(x)) + c \\
&= F(u) + c \\
&= \int F'(u) \diff u
\end{align*}
Writing $F' = f$, we get
$$
\int f(g(x))g'(x) \diff x = \int f(u) \diff u
$$
\item \textbf{Substitution Rule}: If $u=g(x)$ is a differentiable function whose image\footnote{Think of the image as the range} is an interval $I$ and $f$ is continuous on $I$, then
$$
\int f(g(x))g'(x)\diff x = \int f(u) \diff u
$$
\item \textbf{Process}
\begin{enumerate}
\item Identify some part of $g(x)$ that might be simplified by substituting in a single variable $u$, which will then be a function of $x$.
\item Determine if $g(x) \diff x$ can be reformulated in terms of $u$ and $\diff u$
\item Solve the indefinite integral
\item Substitute back in for $x$
\end{enumerate}
\item \textbf{Process for definite integrals}: Using the procedure above,
$$
\int_a^b g(x) \diff x = \int_c^d f(u) \diff u = F(d) - F(c)
$$
where $c=u(a)$ and $d=u(b)$.
\end{itemize}

\section{Integration by Parts}
\begin{itemize}
\item Recall the product rule for differentiation:
$$
\frac{\diff}{\diff x}[f(x)g(x)] = f(x)g'(x) + g(x)f'(x)
$$
Taking the integral of both sides of the equation, we obtain:
$$
f(x)g(x) = \int f(x)g'(x) \diff x + \int g(x)f'(x) \diff
$$
Rearranging terms, we obtain the familiar form for integration by parts:
$$
\int \underbrace{f(x)}_{u}\underbrace{g'(x) \diff x}_{\diff v} = \underbrace{f(x)}_{u}\underbrace{g(x)}_v - \int \underbrace{g(x)}_v \underbrace{f'(x) \diff x}_{\diff u}
$$
Most people remember the integration by parts formula as:
$$
\int u \diff v  = uv - \int v \diff u
$$
where $\diff u = u'(x)\diff x$ and $\diff v = v'(x) \diff x$
\item For definite integrals, we have
$$
\int_a^b f(x)g'(x) \diff  x = f(x)g(x)\big |_a^b - \int_a^b g(x)f'(x) \diff x
$$
\item The goal is to obtain a simpler integral than one we started with. HINT: Choose $u=f(x)$ to be a function that becomes simpler when differentiated (or at least not more complicated) as long as $\diff v = g'(x) \diff x$ can be readily integrated to give $v$.
\end{itemize}

\newpage
\section{Improper Integrals (Infinite Intervals)}

\begin{itemize}

\item \textbf{Definitions of Improper Integrals}
\begin{enumerate}[(a)]
\item If $\displaystyle \int_a^t f(x) \diff x$ exists for every number $t\geq a$, then
$$
\int_a^\infty f(x) \diff x = \lim_{t \rightarrow \infty} \int_a^t f(x) \diff x
$$
provided the limit exists as a finite number.
\item If $\displaystyle \int_t^b f(x) \diff x $ exists for every number $t \leq b$, then
$$
\int_{-\infty}^b f(x) \diff x = \lim_{t \rightarrow -\infty} \int_t^b f(x) \diff x
$$
provided this limit exists as a finite number.
\end{enumerate}
\item The improper integrals in (a) and (b) are called \textbf{convergent} if the corresponding limit exists and \textbf{divergent} if it does not exist.
\item If both $\displaystyle \int_a^\infty f(x) \diff x$ and $\displaystyle \int_{-\infty}^a f(x) \diff x$ are \textbf{convergent}, then we define
$$
\int_{-\infty}^{\infty} f(x) \diff x = \int_{-\infty}^a f(x) \diff x + \int_a^\infty f(x) \diff x
$$
where $a$ is any real number.
\item Useful reminder: \textbf{L'Hospital's Rule}.
\begin{itemize}
\item Why do we use it? To figure out the limits of functions that are in an \textbf{indeterminate} form. For example, suppose we want to find the limit of the form
$$
\lim_{x\rightarrow a}\frac{f(x)}{g(x)}
$$
where both $f(x) \rightarrow 0$ and $g(x) \rightarrow 0$ as $x \rightarrow a$, then the limit may or may not exist. Essentially, you get the indeterminate form $\frac{0}{0}$.

Or suppose you have a limit of the form
$$
\lim_{x\rightarrow a}\frac{f(x)}{g(x)}
$$
where both $f(x) \rightarrow \infty$ and $g(x) \rightarrow \infty$ as $x \rightarrow a$, then the limit may or may not exist. Essentially, you get the indeterminate form $\frac{\infty}{\infty}$.
\item Statement of \textbf{L'Hospital's Rule}: Suppose $f$ and $g$ are differentiable and $g'(x)\neq 0$ near $a$ (except possibly at $a$.) Suppose that
\begin{enumerate}
\item $\lim_{x\rightarrow a} f(x) = 0$ and $\lim_{x\rightarrow a} g(x) = 0$ \quad \textbf{OR}
\item $\lim_{x\rightarrow a} f(x) = \pm \infty$ and $\lim_{x\rightarrow a} g(x) = \pm \infty$
\end{enumerate}
Then
$$
\lim_{x\rightarrow a}\frac{f(x)}{g(x)} = \lim_{x\rightarrow a}\frac{f'(x)}{g'(x)}
$$
if the limit on the right side exists or is $\infty$ or $-\infty$.
\end{itemize}
\end{itemize}

\end{document}
\bibliography{mathcamp}


\section{Conclusions}
	A model solver like Cplex and an heuristic method have substantial differences in the goal they want to achieve: ILP solvers find optimal solutions verifying that it's optimal, while heuristic focus on computation time and find quickly a good solution, that might be optimal or not, without any guarantee about how good the solution actually is.

	From selected tests we can see that both approaches works well for small instances and find reliably the optimal solution. Increasing problem size will make Cplex solver slower and genetic algorithm find solutions more distant from optimal one.

	This project was interesting and made me understand that each method is more suited for a particular goal and has its pros and cons, depending on intrinsic characteristics, implementation of operators/parts of the algorithm and instances of problems. This means that there's no best method to solve some problems (like TSP and related), it all depends on the final solutions that we want to find.


\section{Odem Curse}\label{perk:odemCurse}
\textbf{Cost:} 100CP\\
\textbf{Requirements:} -\\
\textbf{Passive, Repeatable}\\
You were born with the power of Odem inside of you.
This allows you to train in the three flames of power, but also to gain other abilities as well.
However, Odem is not a gift, but a curse instead.
Whenever you would become heavily wounded, your willpower may explode in an invisible, violent force called a burstout.
Roll a D6. On an odd number, every creature in a \passus{20} radius around you must make a Vitality Check.
The DV of this check is your Empathy + 7 + your combined level, and they can add their combined level to the check if they also have the Odem Curse perk.
If they fail, they take 1d10 psychic damage per level you have (all three levels).\\
You then fall unconscious.\\
Your GM may also call for a D6 roll to check for a burstout if your character is under strong emotional duress, such as if one of your allies is harmed strongly.\\
If you rolled an even number on the D6, you do not suffer a burstout.\\
After your first burstout like this, a guild of specialized manhunters called "The Seekers", which is part of the Church of Four, becomes aware of you, and starts hunting for you.
Once they catch you and take you into custody, they seal your powers with an~\nameref{perk:odemSigil}.
\\
Level Progression:\\
II: 500 CP, your burstout only deals 1d8 damage per level\\
III: 2,500 CP: your burstout only deals 1d6 damage per level\\
IV: 5,000 CP: your burstout only deals 1d4 damage per level\\
V: 10,000 CP: you have learned to control your burstouts, and they don't deal any damage anymore\\


\documentclass[11pt]{article}

\usepackage{amsmath}
\usepackage{xfrac}

\usepackage{listings}
\usepackage{hyperref}

\setlength\parindent{0pt}

\begin{document}
    \title{HPCSE II - Exercise 5}
    \author{Anian Ruoss}
    \maketitle

    \section*{Task 2}
    \label{sec:Task2}

    The results from running \texttt{nbody\_naive.cu} (with increased output
    precision for verification) are displayed in Listing~\ref{lst:Naive}.

    \begin{lstlisting}[basicstyle=\scriptsize, frame=single, caption={Output
    from running \texttt{nbody\_naive.cu}.}, label={lst:Naive}]
        Net Force: 0.000000139824
        Absolute Force: 66480053.035935938358
        Time: 16.09551728s
    \end{lstlisting}

    We apply the following optimizations:
    \begin{itemize}
        \item We introduce the temporary variables \texttt{x\_force},
        \texttt{y\_force}, and \texttt{z\_force} to reduce the number of
        writes to global memory from $\mathcal{O} \left( N \right)$ to
        $\mathcal{O} \left( 1 \right)$ per thread.
        \item We introduce the temporary variables \texttt{x\_mIdx},
        \texttt{y\_mIdx}, \texttt{z\_mIdx}, and \texttt{m\_mIdx} to reduce
        the number of reads from global memory from
        $\mathcal{O} \left( N \right)$ to $\mathcal{O} \left( 1 \right)$ per
        thread.
        \item We create the arrays \texttt{x}, \texttt{y}, \texttt{z}, and
        \texttt{m} of size \texttt{BLOCKSIZE} in shared memory.
        This amounts to $\texttt{BLOCKSIZE} \cdot 4 \cdot 8$ bytes $\approx$
        $32$ kilobytes of shared memory which is still below the total amount
        of shared memory per block of 49152 bytes (obtained by running
        \texttt{deviceQuery.cpp} from
        \url{https://github.com/NVIDIA/cuda-samples/blob/master/Samples/deviceQuery/deviceQuery.cpp}
        ).
        As a consequence, we reduce the number of reads from global memory
        from $\mathcal{O} \left( \texttt{BLOCKSIZE} \cdot N \right)$ to
        $\mathcal{O} \left( N \right)$ per block.
        \item We replace $\sfrac{1}{\texttt{sqrt}\left( \ldots \right)}$ with
        a call to \texttt{rsqrt}$\left( \ldots \right)$ which puts less
        pressure on the ALUs.
        \item We move the multiplication with \texttt{m\_mIdx} out of the
        for-loops due to distributivity of multiplication and addition.
        \item We add $10^{-16}$ to the sum of squared distances to avoid
        dividing by zero for the case $i = m$ thereby also avoiding divergence.
        \item We introduce the temporary variable \texttt{tmp} to avoid
        computing the same term three times.
        \item We unroll the inner loop.
    \end{itemize}

    All optimizations were fairly straightforward to implement and we present
    the output of our optimized solver in Listing~\ref{lst:Optimized}.

    \begin{lstlisting}[basicstyle=\scriptsize, frame=single, caption={Output
    from running \texttt{nbody\_opt.cu}.}, label={lst:Optimized}]
        Net Force: 0.000000144482
        Absolute Force: 66480053.035935945809
        Time: 2.23435090s
    \end{lstlisting}

    Comparing listings~\ref{lst:Naive} and~\ref{lst:Optimized} we observe that
    the net and absolute forces are identical (up to an acceptable tolerance)
    with a speedup of $\approx 7.2$.\\

    A note on correctness: since the task asks for the optimization of the
    given N-Body solver without changing the problem size we do not
    explicitly handle the case where the problem size $N$ is not evenly
    divisible by the number of threads per block\footnote{We also note that
    \texttt{nbody\_naive.cu} does not handle this case either.}.
    However, our code can easily be extended for this purpose by enclosing
    the accesses to global memory on lines $38 - 41$ with
    \texttt{if (b + threadIdx.x < N)} and by adding
    \texttt{if (N <= b + i) continue;} to line 47.

\end{document}


\chapter{Some R features}

Most of our work in this module will use R software, although we will spend time considering the output of other programs.   R is useful because it lets us work through the various calculations, in addition to having commands for specific analyses.

It is rather useful to save your work somewhere you can find it again later.   Create a subfolder in the u: drive called \texttt{STAT3401} and store all your work for this module in there.   R uses a working directory - it is not always in a sensible place.   You will have to set the working directory once you have opened R each time you run a session.

\begin{itemize}
\item[] FILE --- CHANGE DIR --[USE DIALOG BOX]
\item[] OR
\item[] \texttt{> setwd("u:/STAT3401")}
\end{itemize}

Make sure you either use the module portal shortcut, or set the working directory \emph{each and every time} you use R.

\emph{Also, you should note that R is case sensitive, therefore R and r are different.}

There is some supplementary R code available in the module portal (mvmmisc.R).   You need to copy this file into your working directory, and load it into R.   It will provide a few additional functions that are not currently available within R.

\begin{verbatim}
> source("mvmmisc.R")
\end{verbatim}

\subsection{Getting help}

R has an extensive help system.   If you know what you're looking for.   The following commands give you the help page for a particular function:

\begin{verbatim}
> help(seq)
> ?seq
\end{verbatim}

If you've a vague idea, \texttt{apropos} will prompt you for other terms that might be relevant, have a look at \texttt{apropos(seq)}.

\texttt{help.search()} (note the quotation marks) will do a search for any help files containing the word you are looking for, have a look at \texttt{help.search(``seq'')}

And finally, typing \texttt{help.start()} will open up a web-browser interface to the R help system.

\subsection{Tidying objects}

In a while, we'll look at creating objects within R.   All these objects get stored in your workspace in one file called \texttt{.Rdata}.   If you don't take care, this will soon use up all your available file space.   R will only ask you if you want to save your workspace at the end of any session.   If you want to save any work in the meantime, type \texttt{save.image()} at intervals.

Type \texttt{objects()} to get a list of any objects that are stored in your workspace.

If you wish to remove an objects, called spot, type \texttt{rm(spot)}.

You can quit R by typing \texttt{q()}, and you will be prompted as to whether you wish to save your workspace.   If you say yes, all your work that session will be saved.   If you say no, R will save the workspace you started the session with.

\subsection{R as an interactive calculator}

At it's simplest, R just works in interactive mode - you type in a command, it gives you an answer:

\begin{verbatim}
> 2 + 3
> 2 - 3
> 2 * 3
> 2/3
> 2^3
\end{verbatim}

You might like to check that the operator precedence works correctly.

\begin{verbatim}
> 4^2 - 3 * 2
> (4^2) - (3 * 2)
> -2 - -3
> -2 - -3
> 1 - 6 + 4
> 2^-3
\end{verbatim}

R has a fairly full range of mathematical functions, e.g.

\begin{verbatim}
> log(100)
> log(100, base = 10)
> log(100, b = 10)
\end{verbatim}

If you're not sure what's going on here, type \texttt{?log} to check.

\subsection{Data objects}

R stores data in a range of objects.   For example:

\begin{verbatim}
> x <- 1
\end{verbatim}

The less than, and the minus sign used together create an ``assignment operator'', we have assigned the value of 1 to x.   If we store our workspace, R will remember that x has a value of 1.   This isn't terribly interesting, in practice we need to store rather more useful information.   If we enter:

\begin{verbatim}
> x <- c(5.4, 5.7, 3.8, 4.1, 4.4, 6.1, 9.8)
> names <- c("Suttons", "Bass", "Boddingtons", "Courage",
      "Stella", "Fosters", "Teignworthy")
\end{verbatim}

we have a range of values for x and a set of names.   We can store these data together in a data frame, called spot:

\begin{verbatim}
> spot <- data.frame(x, names)
> spot
> spot$x
> spot$names
> barplot(spot$x, names.arg = as.character(spot$names))
\end{verbatim}

Having created the data frame, we can extract individual columns using the dollar sign between the name of the data frame and the name of the column.

In practice, we will either use data which is already available within R as a data frame, or we will load data from Excel type csv files (comma separated value) - where it will be imported as a data frame.   The rather useful thing about R is that we can have as many of these data frames in our workspace as we want - but watch your housekeeping!

Data can also be stored in matrices (arrays) as well as lists in R.   We will look much harder at matrices next week!

%%% Local Variables: ***
%%% mode:latex ***
%%% TeX-master: "book.tex"  ***
%%% End: ***


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

\title{Background Study on MeerKAT SETI Search}
\author{Jiapeng Zhang}
\date{May 2021}

\usepackage{natbib}
\usepackage{graphicx}
\usepackage{float}

\begin{document}

\maketitle

\section{Introduction}
In the universe, numerous signals are in the form of electromagnetic(EM) waves, such as communication signals, These signals are strongly coherent, which means the power spectrum of such signals would be a narrow band. However, these signals will show a drift rate with respect to time, when detecting, due to Doppler effect. Therefore, Search for Extraterrestrial Intelligence(SETI) is a research based on analyzing the drift rate to seek possible transmitter signals from exoplanets. Currently, The research is being conducted on MeerKAT. It is a large radio telescope array focusing, which mainly detects two bands of signals - one is 856-1712MHz and another is 544-1088MHz. In this report, it is primarily centered on the basic understanding of SETI.

\section{Theory}
In order to conclude all the possible signals, maximum drift rate is the foremost variables studied. To calculate the maximum drift rate, there are four dominant factors:
    1.Rotational acceleration of Earth
    2.Orbital acceleration of Earth
    3.Rotational acceleration of the observed object
    4.Orbital acceleration of the observed object
Based on the above, the maximum drift rate is given by,
\begin{equation}
    \centering
    \dot{f}=\frac{f_{rest}}{c}(\frac{4\pi^2R_{\oplus}}{P_{rot,\oplus}^2}+\frac{4\pi^2R}{P_{rot}^2}+\frac{GM_\odot}{r_\oplus^2}+\frac{GM}{r^2})
\end{equation}
where $f_{rest}$ is the minimal detectable frequency, $r$ and $r_\oplus$ are the orbital radius of the observed object and Earth, $R$ and $R_\oplus$ are the radii of the observed object and Earth, $P_{rot}$ and $P_{rot,\oplus}$ are the rotation period of the observed object and Earth.\cite{2019ApJ...884...14S}

\section{Known Objects}
By applying equation 1 to a few know objects,

\begin{table}
\centering
\resizebox{\textwidth}{!}{
\begin{tabular}{l|rrrrrr}
\hline
         Name &  r\_obs(km) &  P\_obs(day) &     R\_obs(km) &  M\_center(Kg) &  drift\_rate\_1 &  drift\_rate\_2 \\
\hline
        Earth &     6371.0 &       1.000 &  1.496e+08 &  1.989e+30 &      0.226125 &      0.143706 \\
         Moon &     1737.1 &      27.322 &  3.844e+05 &  5.972e+24 &      0.120794 &      0.076767 \\
      Mercury &     4880.0 &      58.646 &  5.791e+07 &  1.989e+30 &      0.226034 &      0.143648 \\
      Jupiter &    69911.0 &       0.414 &  7.786e+11 &  1.989e+30 &      6.268084 &      3.983455 \\
           Io &     1821.6 &       1.769 &  4.217e+05 &  1.898e+27 &      2.154424 &      1.369167 \\
  51 Pegasi b &   135830.0 &      21.900 &  7.880e+06 &  2.208e+30 &      6.889148 &      4.378150 \\
 Tau Boötis b &    11945.6 &       3.310 &  9.343e+11 &  2.765e+30 &      0.129515 &      0.082309 \\
   Beta Pic b &   102070.1 &       0.338 &  1.376e+09 &  3.481e+30 &     13.595275 &      8.639988 \\\hline
\end{tabular}}
\caption{A few known objects and their drift rate under two different bands.}
\label{table:1}
\end{table}

\begin{figure}[H]
\centering
\includegraphics[scale=0.3]{Part_1.pdf}
\caption{A simulation of 5 mins observation of narrow bandwidths for various drift rate, starting at $f_{rest}=856MHz$(left) and $f_{rest}=544MHz$(right). The shaded area is where the drift rate is 10Hz/s.}
\label{fig:1}
\end{figure}

From fig.1, it is clearly that 10Hz/s of drift rate is not enough, even for known objects. The maximum drift rate during 5 mins for L band is 2.853 MHz/s, and for UFL band is 1.813 MHz/s.

\section{Voyager}
Voyager has collected a significantly large amount of signals. Here are two plots of time and power with respect to a range of frequency from 8418.457034043968 MHz to 8421.38671875 MHz

\begin{figure}[H]
    \centering
    \includegraphics[scale=0.4]{voyager.pdf}
    \caption{The collected data from voyager from 8418.457034043968 MHz to 8421.38671875 MHz. The figure above is the time elapsed vs frequency, and the figure below is the power vs frequency.}
    \label{fig:2}
\end{figure}

In Sheikh et al., it was suggested that above 200nHz of normalized drift rate is worth further study. From this range of frequency. The drift rate 0.363527 Hz/s. If MeerKAT is used, the normalized drift rate is 0.425 nHz for L band and 0.668 nHz. MeerKAT won't detect such signal because it exceeds the bandwidth. It is not compatible with what Sheikh et al. range.

\section{Extension}
Due to the lack of access to off-satellite MeerKAT observation data, there is only the power spectrum plot of the on-satellite data.

\begin{figure}[H]
    \centering
    \includegraphics[scale=0.8]{on.pdf}
    \caption{On-satellite signal power spectrum from MeerKAT.}
    \label{fig:3}
\end{figure}

\begin{figure}[H]
    \centering
    \includegraphics[scale=0.8]{on_waterfall.pdf}
    \caption{On-satellite signal waterfall from MeerKAT.}
    \label{fig:4}
\end{figure}

The drift rate for this satellite signal is significantly small to be recognized. The frequency at 1575.4055MHz is most likely to be compromised by Radio Frequency Interference

\bibliographystyle{plain}
\bibliography{export-bibtex.bib}

\end{document}


\documentclass[conference]{IEEEtran}
\usepackage{polyglossia}
\usepackage{moreverb}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{pifont}
\usepackage{booktabs,caption}
\captionsetup{labelsep=newline,singlelinecheck=false} % optional
\usepackage{tabularx}

\begin{document}
\title{A Discussion of the Robust Information-theoretic Clustering Framework (RIC)}
\author{\IEEEauthorblockN{Simon Lackerbauer}
\IEEEauthorblockA{Institut für Informatik\\
Ludwig-Maximilians-Universität München\\
Oettingenstraße 67, 80538 München\\
lackerbauer@lrz.mwn.de}}

\maketitle

\begin{abstract}
In the 2006 paper \textit{Robust Information-theoretic Clustering} Böhm et al. propose a three-part algorithm to find diversely distributed clusters in data sets using an information-theoretic approach, most noticeably the VAC criterion, which depends on the principle of minimum-description length (MDL) - while being input-free and as such usable without specialist knowledge. After comparison with other algorithms with the same or similar prerequisites, one can conclude that it reaches its goal admirable, although with certain limitations, most noticeably quality of the input clustering and runtime efficiency.
\end{abstract}

\section{Introduction}
The authors of the herein discussed paper\cite{Bohm2006-ts} went out to answer the question “How do we find a natural clustering of a real world point set, which contains an unknown number of clusters with different shapes, and which may be contaminated by noise?”

Heavy emphasis was put upon the notion that the algorithm accomplishing this feat shall need no user-input, and, furthermore, not be restricted to purely Gaussian cluster distributions. The proposed algorithm also shouldn't be easily subjugated by noisy data sets, and moreover be at least reasonable efficient in its runtime-complexity. If and how well the proposed algorithm adheres to these self-given requirements, and also how it compares to other methods by researches out to find a solution to much the same problems (compare eg. NIC\cite{Faivishevsky2010-uk} and PaCCo\cite{Mueller2011-hd}), shall be the focus of this discussion.

\section{Overview}
First of all, in section~\ref{sec:ric}, the RIC framework will be presented and the principles behind it explained. Then we'll take a short look at the experiments against which RIC was tested in section \ref{sec:exp}. Afterwards, section~\ref{sec:crit} will expatiate upon general criticisms of the framework that were addressed by other seminar participants in the discussion following the presentation. In section~\ref{sec:comp} the algorithm will be compared with other similar algorithms on a variety of axes. Finally, this discussion will conlude in section~\ref{sec:conc}.
\section{The RIC Framework}
\label{sec:ric}
The RIC framework takes as input a pre-clustered data set, though it is indifferent towards the method by which this pre-clustering shall be accomplished. The authors themselves use K-means in their example data sets. RIC is thusly not strictly a clustering algorithm as it is a cluster refining algorithm\cite{Bohm2008-eh}. (By definition, any cluster refining algorithm should in principle be able to function as a clustering algorithm, refining from the case that every point in the data set is a distinct cluster.) Compared with other input-free clustering algorithms like X-means\cite{Hamerly2003-hm} and G-means\cite{Pelleg2000-jr} RIC is supposed to find any clusterings which can be defined by its predetermined PDFs, which means it doesn't rely solely on Gaussian clusters, but is nevertheless restricted to detecting clusters of a (reasonably small) finite set with mathematically non-too-complex probability densities.

The RIC framework is composed of two sub-algorithms doing the heavy lifting with the MDL-like VAC criterion standing in as a measure of goodness.
\subsection{VAC - Volume After Compression}
The VAC (Volume After Compression) criterion lies at the heart of the RIC framework and guides virtually any decision the framework has to make about the goodness of a given clustering. VAC uses Elias gamma encoding\cite{Elias1975-wj} to encode any integer $i$ using $O(\log i)$, be it point-coordinates or point-offsets from the cluster center if point $\vec{x}$ is said to belong to a cluster $C$. It further takes into account the possible correlation in a cluster, and if it makes sense to instead save a decorrelation matrix. Thus, the volume after compression of a point $ \vec{x} $ in a grid with $ \gamma $ distance between grid cells can be summarized as
\[ VAC(x) = \left(\log_2 \frac{n}{|C|} \right) + \left(\sum_{0 \leq i < d} \log_2 \frac{1}{pdf_i(x_i) \cdot \gamma} \right) \]
where $ \log_2 \frac{n}{|C|} $ are the encoding costs of the cluster-Id and $ \sum_{0 \leq i < d} \log_2 \frac{1}{pdf_i(x_i) \cdot \gamma} $ are the encoding costs of all the integers defining a point $ \vec{x} $ in $ d $. Obviously the encoding costs depend quite significantly on the chosen probability density function ($ pdf_i $) that is assigned to estimate one dimension of the cluster.

To find the appropriate $ pdf $ the VAC criterion is employed again so that
\[ pdf_i = {\arg\min}_{pdf_{stat} \in \text{PDF}} \sum_{\vec{x} \in C} \log_2 \frac{1}{pdf_{stat}(x_i) \cdot \gamma} \]
where the available $ pdf $ is chosen from the set of defined PDFs with defining characteristics (eg mean, variance) as calculated from the considered coordinate dimension.

Further, a decorrelation matrix is calculated, but only included if the VAC criterion warrants such a move - as in: the decorrelation saves more space by virtue of its better fit than it takes to save the matrix itself.

Putting all these formulae together, we finally reach the VAC of a full cluster in
\[ VAC(C) = VAC(dec(C)) + \sum_{\vec{x} \in C} VAC(dec(C) \cdot \vec{x}) \]
where $ dec(C) $ is the decorrelated cluster.

The authors illustrate the principle behind encoding a cluster with different PDFs as in figure \ref{fig:vac}. As they write themselves that the grid constant $ \gamma $ shall be chosen so as to enable each datapoint to fall into its own grid cell, the choice of $ \gamma $ in their example seems a little off, but not in a truly negative way.

\begin{figure}
  \centering
  \noindent\includegraphics[width=\linewidth]{imgs/vac}
  \caption[]{Example of VAC\cite{Bohm2006-ts}}
  \label{fig:vac}
\end{figure}

\subsection{RF - Robust Fitting}
The Robust Fitting sub-algorithm deals with outliers in the input clusters. The fitting algorithm employs the VAC criterion to determine if a point is adequately described by the characteristic distribution of the cluster or if it makes more sense to not count that specific point as belonging to (any or this) specific cluster. An example of how a conventional clustering might work in finding a characteristic distribution as opposed to how the RF algorithm estimates its fitting using the VAC criterion can be found in figure \ref{fig:robust_estimation}. But the sole introduction of the VAC criterion to measure goodness does not yet incorporate outlier detection.

\begin{figure}
  \centering
  \noindent\includegraphics[width=\linewidth]{imgs/robust_estimation}
  \caption[]{Conventional and robust estimation\cite{Bohm2006-ts}}
  \label{fig:robust_estimation}
\end{figure}

Instead, RF derives its robustness regarding outliers from the fact that the conventional way to estimate the covariance matrix $ \Sigma $ is by computing a matrix $ \Sigma_C $ from the points $ \vec{x} \in C $ by averaging
\[ \Sigma_C = \frac{1}{|C|} \sum_{\vec{x} \in C} (\vec{x} - \vec{\mu}) \cdot (\vec{x} - \vec{\mu})^\text{T} \]
whereas RF doesn't solely use arithmetic means but also tries the coordinate-wise median (the median of $ (\vec{x} - \vec{\mu}_{R_i}) \cdot (\vec{x} - \vec{\mu}_{R_j}) $ over all $ \vec{x} $) yielding the robust covariation matrix $ \Sigma_R $.

Given the conventional covariance matrix $ \Sigma_C $, by Principle Components Analysis (PCA) one could obtain the orthonormal Eigenvector matrix $ V $, the decorrelation matrix, and the diagonal matrix $ \Lambda $, containing all Eigenvalues, with $ \Sigma_C = V \Lambda V^\text{T} $. Using the property of diagonal dominance (ie all diagonal elements are greater than the sum of the other values in their respective row), one could then measure the distance between any two points $ \vec{x} $ and $ \vec{y} $ by using the Mahalanobis distance\cite{Mahalanobis1936-wy} defined by $ V $ and $ \Lambda $:
\[ d_{\Sigma_C}(\vec{x}, \vec{y}) = (\vec{x} - \vec{y})^\text{T} \cdot V \cdot \Lambda^{-1} \cdot V^\text{T} \cdot (\vec{x} - \vec{y}) \]

The robust covariance matrix $ \Sigma_R $ does not necessarily have the diagonal dominance property. However, this can easily be fixed by adding a matrix $ \varPhi \cdot I $ to the covariance matrix. $ \varPhi $ should naturally be chosen as the maximum difference of all the column sums and their corresponding diagonal element. The authors also add a small amount on top of that (in their example 10\%), but it's not really clear why that added value would be needed, as even
\[ \varPhi_{naive} = \max_{0 \leq i < d} \left\{ \left( \sum_{0 \leq j < d, i\neq j} (\Sigma_C)_{i,j} \right) - (\Sigma_{C})_{i,i} \right\} \]
should be enough to satisfy the diagonal dominance property. They do however add that 10\%, which means the suggested value in the original paper is
\[  \varPhi = 1.1 \cdot \varPhi_{naive}. \]

The estimation of a robust covariance matrix does not mean that this matrix is actually used as the descriptive matrix of the cluster, however - the decision about which matrix to use is, as expected, made by calculating the VAC of both $ \Sigma_C $, $\Sigma_R $ and of several candidate matrices and finally choosing the one yielding the lowest VAC.

Once the covariance matrix with the lowest VAC is found, all points are first deemed outliers and then iteratively inserted into the set of cluster points (by order of their Mahalanobis distance from the distribution center), with accompanying VAC scoring at each step. Once a (local) minimum is reached, the process stops and the cluster and outliers are then returned to the next RIC sub-algorithm, CM.

\subsection{CM - Cluster Merging}
The Cluster Merging algorithm is likely the computationally costliest part of the RIC process as it compares each cluster with every other cluster for possible merging using the VAC criterion again, or simply checking if
\[ VAC(C_i \cup C_j) < VAC(C_i) + VAC(C_j) \]
for all $ C_i,C_j \in \mathcal{C},i \neq j $. Getting the VAC score of a merged cluster seems only possible by building a new set of points from the previous two clusters and running the whole RF algorithm on that set again.

The CM part of the algorithm also comes with the option of going further down the search tree to get out of a local minimum. It will then merge clusters even if
\[ VAC(C_i \cup C_j) \geq VAC(C_i) + VAC(C_j) \]
for a given $ t $ iterations. If it actually does find to have been in a local minimum, the counter will naturally reset to 0.

\section{Experiments}
\label{sec:exp}
RIC is tested on two different sets of synthetic data and on two different sets of real data. RIC found all the correlational, Laplacian and Gaussian clusters in the synthetic data sets, the input being provided by either K-means or DBSCAN\cite{Ester1996-rh}. RIC manages to correctly identify more than 98\% of the noise objects in the data sets and reduces the initial VAC score by about a quarter each. The provided runtimes for both data sets are provided and discussed below in section \ref{sub:run}.

Further evaluation is provided by running RIC on a 14-dimensional real world metabolic data set. Clustering in this biomedical instance can provide help in diagnosing disorders, if the algorithm can cluster both the healthy control group and the test group with disease correctly. For that reason, in this situation as further points of comparison \textit{impurities} in the clusters are counted - impurities being wrongly assigned groups for the known distribution, ie the sum of statistical type I and type II errors. As expected, RIC is able to beat both spectral as well as K-means clustering by achieving a lower VAC, even with both other clustering algorithms being provided with the correct number of clusters to identify. More importantly, however, is RIC's far superior number of impurities (mostly ill datapoints ascribed to the healthy cluster), usually making only about a third of the errors that K-means and spectral achieve alone.

The fourth example provided concerns retinal images of cats in various states of health. The images are encoded as a 7-dimensional data set with more than 21 thousand instances, which RIC (again using K-means as a starting point) clusters into 13 clusters, all of which are correlational, and two of which describe actual, studied, biological meaningful relationships, namely the "Müller cells" and "rod photoreceptors". As RIC's pretense was to provide meaningful clusters without user-input, and, as such, without relying on the user's specific domain knowledge, this can be taken as a sign that it at least partially reached its goal.

\section{General Criticism}
\label{sec:crit}
As the lead author himself confirms in later works\cite{Bohm2008-eh}\cite{Bohm2010-uu}, the clustering output of RIC strongly depends on the quality of the initial clustering and the cluster model is limited to linear attribute correlations. They're also limited to the list of predefined PDFs, though that might not be too much of a limitation, as, in theory, new PDFs are supposed to be added quite easily. Further, there's a reason that there's only a limited to supply of deeply researched and named density functions to begin with, namely that they're readily applicable to a big enough subset of problems. Natural processes that need much more elaborate models also are clearly not in scope of the RIC framework.

\subsection{Runtime Analysis}
\label{sub:run}
The paper does not contain an explicit runtime analysis of RIC in general or its sub-algorithms. It is, however, relatively easy to see that the VAC calculation itself should take at most linear time as it's only adding up the total size of an encoded input. The Robust Fitting part can probably be assumed to also need only linear time, whereas the Cluster Merging algorithm almost certainly grows quadratically at least in the worst case.

The experimental runtimes that can be taken from the paper (147s for 4751 objects in 2 dimensions and 567s for 7500 objects in 3 dimensions) also seem suggestive of a quadratic growth rate, as an input of $ 7500 \cdot 3 = 22500 $ integers, about 2.4 times as many as $ 4751 \cdot 2 = 9502 $ integers takes roughly 3.9 times the time to process.

\begin{table*}
  \caption{Comparison of RIC with other information-theoretic clustering algorithms}
  \label{tab:comp}
  \begin{tabularx}{\textwidth}{rlllXXl}
  	\toprule
  	                    & parameter-free & runtime analysis              & input data          & clustering strategy & clusters detected                                       & year \\ \midrule
  	                RIC & yes            & $ O(n^2)^{\beta} $            & matrix              & input-refining      & Gaussian, Laplacian, Correlational, others$ ^{\alpha} $ & 2006 \\
  	              PaCCo & yes            & $ O(n) < x < O(n^3)^{\beta} $ & graph (weighted)    & bisecting             & Gaussian, others$ ^{\alpha} $                           & 2011 \\
  	minCEntropy($ ^+ $) & no             & $ O(n^2) $                    & matrix              & proprietary         & Gaussian                                                & 2010 \\
  	              ROCAT & yes            & $ O(n) $                      & matrix              & bisecting         & not applicable                                          & 2014 \\
  	               PICS & yes            & $ O(n) $                      & graph (attributed)  & bisecting         & not applicable                                          & 2012 \\
  	            INCONCO & yes            &           $ O(n)^\beta $                    & matrix (attributed) & bisecting                    & Gaussian                                                & 2011 \\
  	                NIC & yes            &     $ O(n^2) $                          &    matrix                 &      greedy sequential k-means               &      non-convex                                                   & 2010 \\
  	                VoG &  yes              &     $ O(n)^\gamma $                          &     graph                &      multiple               &          not applicable                                               & 2014 \\ \bottomrule
  	\multicolumn{7}{l}{$ ^{\alpha} $ user-defined PDFs are explicitly mentioned as desired extensions to the algorithm}                                                               \\
  	\multicolumn{7}{l}{$ ^{\beta} $ estimate, as the respective authors did not provide an explicit runtime analysis} \\
    \multicolumn{7}{l}{$ ^{\gamma} $ the average case with $ n $ being the numbers of edges on the graph}
  \end{tabularx}
\end{table*}

\subsection{Edgecases}
It would have been interesting to see how the RIC framework reacts to random or exactly equally distributed input. Would it see structure in the noise regardless? Would the CM method make initial bad K-means clustering on such data more deterministic? Sadly, there are no examples included in the paper that can act as a kind of control group.

\section{Comparison with other Algorithms}
\label{sec:comp}
In this section, we'll compare how RIC fares against some of the other clustering algorithms introduced in the seminar, eg PaCCo\cite{Mueller2011-hd}, minCEntropy\cite{Vinh2010-tc}, ROCAT\cite{He2014-uf}, PICS\cite{Akoglu2012-vz}, INCONCO\cite{Plant2011-wy}, NIC\cite{Faivishevsky2010-uk}, VoG\cite{Koutra2014-up} and Subdue\cite{Ketkar2005-zs}. The categorical results of these comparisons are provided succinctly in table \ref{tab:comp}.

\subsection{PaCCo}
PaCCo is a weighted graph-based algorithm employing the information-theoretic MDL principle to check the goodness of a clustering just like RIC does, including the Huffman coding structure along a cluster PDF. Different from RIC, however, PaCCo in general assumes Gaussian clusters, but other PDFs can be added by the user. A further similarity is the fact that both algorithms work without user-input. PaCCo however comes with its own bisecting K-means strategy, so its input really are completely unordered and unclustered data.

PaCCo's runtime efficiency is not explicitly stated, other than being "super-linear". In tests against Zelnik-Manor and Perona's parameter-free SpectralZM algorithm\cite{Zelnik-Manor2004-rx}, which has a runtime of $ O(n^3) $, PaCCo outpaced SpectralZM with ease. Its real runtime efficiency will thus lie somewhere in-between.

In conclusion, with PaCCo introduced significantly later than RIC, and having a different input assumption, the RIC framework still holds up surprisingly well in comparison.

\subsection{minCEntropy$ (^+) $}
The focus of minCEntropy lies not on producing a single clustering solution to a given data set, but instead realizes that data can often be interpreted in more than one way (eg data that can be used for facial recognition/authentication could also be used to identify looking direction). The algorithm's goodness criterion seems different from all the other criteria employed throughout this paper - instead of referencing the MDL principle the authors choose to minimize the conditional entropy left in the data, or in other words, maximize the average intra-cluster similarity (hence the name). Of course, concentrating on maximizing intra-cluster similarity will invariably make it easier to succinctly describe a given cluster - in other words, minimizing the description length needed.

The included complexity analysis puts emphasis on the fact that although initializing the required kernel matrix takes up to $ O(n^2) $ time, further updating to reach an optimal clustering takes only linear time and converges quickly.

Then, minCEntropy$ ^+ $ is the extension of minCEntropy to find the above mentioned alternative clusterings when given a clustering to explicitly exclude. There's also a further extension minCEntropy$ ^{++} $ that can exclude multiple clusters.

No iteration of the algorithm works completely parameter-free.

\subsection{ROCAT}
ROCAT is a pretty young, parameter-free approach to clustering, using the MDL principle (though expressed as a question of entropy like with minCEntropy above), and focusing on subspace clusters for categorical (ie not numerical) data. As ROCAT deals with categorical data, a defining cluster probability distribution like a Gaussian curve is not really applicable. Clusters built by ROCAT over a matrix view of the attributive data are always shaped rectangular.

ROCAT's runtime efficiency grows linearly with $ n $, quadratically with dimensionality, so it's one of the most efficient algorithms discussed until now.

\subsection{PICS}
PICS is a parameter-free graph-clustering algorithm that does not solely cluster on connectivity information but also takes node attributes into account. Naturally, PICS also relies on an MDL criterion to decide if a split of the biggest identified cluster brings a better description of the data (similar to the approach used by PaCCo above).

\subsection{INCONCO}
INCONCO is a parameter-free clustering algorithm with much the same premise as PICS, only that it is not based on graph data with attributes, but instead on vector data with mixed-type attributes.

Where RIC uses the Robust Fitting method instead of PCA to make its clustering less sensitive to outliers, INCONCO extends Cholesky decomposition\cite{Golub1996-ak} as it's more efficient than PCA and yields better results. The usage of an MDL criterion for decisions regarding goodness of fit at each step of the bisecting algorithm going through the input data set does not come as a surprise anymore.

There is no explicit theoretical runtime analysis given, but from the runtimes reported, INCONCO seems extremely efficient when looking at the number of points processed, with much of it probably due to a large but constant overhead.

\subsection{NIC}
NIC is a parameter-free framework that can find clusters independently of their underlying structure utilizing the MeanNN differential entropy estimator. NIC is certainly different in that it can even find clusters consisting of points non-convex sets (eg concentric circles), a feat that RIC would not be able to accomplish without being fed a complex user defined distribution first.

\subsection{VoG}
The premise of VoG is the description of large graphs using a certain vocabulary (eg stars, chains, bi-partite cores). So not only shall clusters in the graph be recognized, but also be described by their most descriptive characteristic. By then examining the frequencies with which the predefined structures in the vocabulary appear in the graph and the most notable structures altogether, one can make some meaningful abstractions of the underlying real world structure (eg finding the two groups comprising a Wikipedia edit war).

\section{Conclusion}
\label{sec:conc}
In the end, especially against competitors that were introduced significantly later and which could build upon a larger body of work with much the same direction, the RIC framework still fares surprisingly well. It is one of the few algorithms that comes pre-equipped with more than just the regular Gaussian PDF (of course, Gaussian distributions still play one of the most significant roles in data description across all fields). Its runtime complexity is not the most amazing thing about the framework, but still holds up against much of the competition. As we've seen under section \ref{sec:crit}, there are some valid criticisms to be aware of, but as the real world examples have shown, any clustering algorithm that can identify known relations consistently and, as such, can be used to find new relationships in data is a step in the right direction.

Adding into that the fact that the RIC framework provides exactly that, a framework that can profit from the fact that clustering elsewhere might get better and as such provide better input to be enhanced by the information-theoretic principles that guides it, the findings by Böhm et al. certainly advanced the area of research they set out to advance.

\section*{Acknowledgments}
The author would like to thank Dr. Bianca Wackersreuther for providing input and help whenever needed and conducting the seminar in a well-received and professional manner. Next, Prof. Christian Böhm, both for co-authoring the discussed paper in the first place, and then giving me the opportunity to engage with the topic for this course. Lastly, the other participants in this seminar, for providing constructive criticism after my talk without which this discussion paper wouldn't have been possible.

\bibliography{sources.bib}{}
\bibliographystyle{plain}

\end{document}


\documentclass[8 pt]{article}

\usepackage[utf8x]{inputenc}
\usepackage{dsfont}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tensor}
\usepackage{mathtools}
\usepackage[T1]{fontenc}
%\usepackage[spanish]{babel}
\usepackage[cm]{fullpage}
\usepackage{graphicx}
%\usepackage{float}
\usepackage{bm}
\usepackage{setspace}
\usepackage{enumitem}
\usepackage{mdwlist}
\usepackage{parskip}
\usepackage{listings}
\usepackage{color}
%\usepackage{epstopdf}
\usepackage{tikz,datatool}
\usepackage{hyperref}
\usepackage{mathabx}
\usepackage{multicol}
\usepackage{eurosym}
\usepackage{caption}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\AtBeginDocument{
  \let\myThePage\thepage
  \renewcommand{\thepage}{\oldstylenums{\myThePage}}
}

\newcommand{\gra}{$^\text{o}$}
\newcommand{\dif}{\text{d}}
\newcommand{\avg}[1]{\left\langle #1 \right\rangle}
\newcommand{\ket}[1]{\left| #1 \right\rangle}
\newcommand{\bra}[1]{\left\langle #1 \right|}
\newcommand{\bket}[2]{\left\langle #1 \middle| #2 \right\rangle}
\newcommand{\der}[2]{\frac{\text{d} #1}{\text{d} #2}}
\newcommand{\prt}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\dert}[3]{\frac{\text{d}^#3 #1}{\text{d} #2^#3}}
\newcommand{\prtt}[3]{\frac{\partial^#3 #1}{\partial #2^#3}}
\newcommand{\dl}{\mathcal{L}}
\newcommand{\dha}{\mathcal{H}}
\newcommand{\vol}{\text{vol}}
\renewcommand{\vec}[1]{\pmb{#1}}

\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\newenvironment{Figure}
  {\par\medskip\noindent\minipage{\linewidth}}
  {\endminipage\par\medskip}

\begin{document}

\begin{minipage}{\textwidth}
    \centering
    \Large \textbf{\textsc{Homework 2: Sensitivity and Option Strategies}}
    \vspace{0.5cm}

    \small \textsc{Francisco García Flórez, Joris van Lammeren, Wouter Varenkamp}
    \vspace{0.5cm}

    \begin{minipage}{0.6\textwidth}
      \textbf{Abstract.} In this exercise we continue using the program written for the last homework, analyzing now the sensitivity of the option prices to changes in several parameters. In the second part, we analyze the stategy \emph{long call option} and compute the \emph{put-call parity}.
    \end{minipage}
\end{minipage}

\vspace{0.5cm}

\begin{multicols*}{2}
\section{Sensitivity of the option price}

Firstly we will show how the option price is affected by changes in several variables of the Weiner process. In the following plots we show the mean and standard deviation values for each one, the second one using error bars. Also, the option price for call options will be shown in red, while the one for put options will be shown in blue.

Some comparisons can be done against the Black-Scholes model, which solves analytically the stochastic differential equation of the Weiner process, giving the following solution \cite{Wilmott} for the probability density function of S:

\begin{equation} \label{eq:weinersol}
  \frac{1}{\sigma S \sqrt{2\pi t}} \exp\left[ -\frac{\left(\log\frac{S}{S_0} - (\mu - \frac{1}{2}\sigma^2)t\right)^2}{2\sigma^2 t}\right] ~~,
\end{equation}

also known as lognormal distribution.

Just by looking at this equation we can predict the behavior of the option price as parameters change --- $\sigma$ and $t$, which will clearly widen the distribution of points as they increase, and $\mu$ or $S_0$ which will shift the whole distribution changing the option price but without affecting the width.

\subsection{Initial stock price, $S_0$}

\begin{Figure}
  \begin{center}
    \includegraphics[width=0.8\textwidth]{graphs/oP_stock.eps}
    \captionof{figure}{Value and sensitivity of the option price for a range of initial stock prices. The green line represents the exercise price (15\euro).}
    \label{fig:stock_sens}
  \end{center}
\end{Figure}

As we can see in Figure \ref{fig:stock_sens}, changing the initial stock price doesn't affect the option price in an unexpected way, and the standard deviation of our results doesn't increase significantly either. This is expected, since what we are doing here is just moving the distribution of share value at exercise date to higher or lower values, so for lower (higher) values smaller (larger) the probability of making profit and therefore the option price will be lower (higher).

\subsection{Volatility, $\sigma$}

\begin{Figure}
  \begin{center}
    \includegraphics[width=0.8\textwidth]{graphs/oP_vol.eps}
    \captionof{figure}{Value and sensitivity of the option price for a range of volatilities.}
    \label{fig:vol_sens}
  \end{center}
\end{Figure}

In this case we are changing the volatility of the share, so its value at exercise date will have a wider range of values. In other words, we expect the standard deviation of our results to be larger as we can predict by looking at equation (\ref{eq:weinersol}). The denominator of the distribution is given by $2\sigma^2 t$, and it clearly explains this behavior. Also, for $\sigma\rightarrow0$ we find no width at all, since the values will only change due to the drift.

The option price is also increasing, since a higher volatility spreads the share value at expiration date, and since we compute the option price by removing values smaller than the exercise price, it increases the average.

\vfill

\subsection{Duration, $aT$}

\begin{Figure}
  \begin{center}
    \includegraphics[width=0.8\textwidth]{graphs/oP_dur.eps}
    \captionof{figure}{Value and sensitivity of the option price for a range of durations.}
    \label{fig:dur_sens}
  \end{center}
\end{Figure}

Again, the error bars widen as $t$ increases, since the standard deviation depends on $\sqrt{t}$ as we can see from equation \ref{eq:weinersol}. In addition, the option price increases as the drift has more time to act and thus increase the value of the share. For large $t$ we should include a term of the form $e^{-rt}$, but we will just assume that $r$ is small enough not to make a significant difference in a year.

As we mentioned before, changing $aT$ is similar to a change in $\sigma$ in terms of widening of the distribution, and it shows clearly as Figures \ref{fig:vol_sens} and \ref{fig:dur_sens} both present a similar behavior, the former increasing $\avg{oP}_{rf}$ linearly and the latter as $\sqrt{t}$.

\subsection{Drift, $\mu$}

\begin{Figure}
  \begin{center}
    \includegraphics[width=0.8\textwidth]{graphs/oP_drift.eps}
    \captionof{figure}{Value and sensitivity of the option price for a range of drifts.}
    \label{fig:drift_sens}
  \end{center}
\end{Figure}

Finally, in Figure \ref{fig:drift_sens} we can see how changing the drift produces a very similar result as changing the initial stock price from Figure \ref{fig:stock_sens}, as we predicted by studying equation (\ref{eq:weinersol}). We could check that these two plots are equal when $\log S_0$ and $\mu t$ give the same contribution. Also as we predicted, the standard deviation doesn't significantly change with $\mu$, except for the inherent randomness of the algorithm.

\section{$A$/$B$ long call spread}

When using a long call spread you are buying a call option (going long) with a price $A$ and writing a call option (going short) with a price $B$. $A$ is smaller than $B$ and the stock price is usually in between but does not have to be. This limits the risk you are taking, but it also limits your profits to a maximum value.

\begin{Figure}
  \begin{center}
    \includegraphics[width=0.8\textwidth]{graphs/long_call_option.eps}
    \captionof{figure}{Diagram of the payoff for the strategy \emph{long call option}. In this case $A=10$ and $B=20$.}
    \label{fig:long_call_option}
  \end{center}
\end{Figure}

In Figure \ref{fig:long_call_option} the pay off diagram of the long call spread is shown. There are three possible scenarios. If the stock price drops below $A$ you make a loss equal to the net amount of cash you paid for both the options. If the stock price is between $A$ and $B$ your profit is the difference between the stock price and $A$ minus the net amount paid for the options, this might still be negative. If the stock price is bigger than $B$ both options will be used. So your profit is the difference between $A$ and $B$ minus the net amount paid for the options. This is your maximum potential profit.

In the case of the 10/20 long call spread and the start stock price of 15 it would be preferable for the stock price to go up. The closer to $B$ the higher your profit will be. However, the stock price shouldn't become much higher than $B$, as profits won't increase further. But this would mean you made a bad move by putting a ceiling to your profit in exchange for a smaller loss.

\section{Put-call parity}

In a put-call parity you buy a put option, $P$, and you write a call option, $C$, with the same exercise price $E$, you also have an actual asset of the stock. So the cost of the portfolio is $S + P - C$. In this case you keep the options until the expiring date. At the expiring date there are two options. The stock price is smaller than the exercise price. In this case the call option will not be used, but the put option will. This makes the profit of the portfolio $S + ( E - S ) - 0 = E$ minus the price of the portfolio. When the stock price is bigger than the exercise price the call option will be used and the put option will not be used. Your profit is then $S + 0 - ( S - E ) = E$.

\begin{Figure}
  \begin{center}
    \includegraphics[width=0.8\textwidth]{graphs/put_call_parity.eps}
    \captionof{figure}{Diagram of the payoff showing the \emph{put-call parity}.}
    \label{fig:put_call_parity}
  \end{center}
\end{Figure}

In Figure \ref{fig:put_call_parity} we see that the dashed line is the profit for every value of the stock price, minus the net costs of the portfolio, but we set that to 0 in this example. Figure \ref{fig:put_call_parity} shows that when you can acquire such a portfolio for a price smaller than $E$ you will always make a profit.

The put-call parity formula is then

\begin{equation*}
    S + P - C = E e^{-r(T-t)} ~~,
\end{equation*}

where $r$ represents the interest rate. This is based on the principle that having money now has more worth than having the same amount of money in the future. It is the same as discounting $S + P - C$.

\begin{thebibliography}{28}
\raggedright
\addcontentsline{toc}{section}{Bibliography}

\bibitem{Wilmott} P. Wilmott et al, \emph{The Mathematics of Financial Derivatives}, 1995.

\end{thebibliography}

\end{multicols*}

\end{document}


% MOLT (Max's Own LaTeX Template)
% Version 2.11.1
% Edited 2022/01/23

% Packages and document settings
\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage[UKenglish]{babel}
\usepackage[UKenglish]{isodate}
\usepackage{tikz}
\usepackage{framed}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{natded}
\usepackage{mathtools}
\usepackage{multirow}
\usepackage{tipa}
\usepackage[linguistics]{forest}
\usepackage{subfig}
\usepackage{hyperref}

\definecolor{shadecolor}{gray}{0.9}
\pagestyle{fancy}
\parindent = 0pt
\cleanlookdateon

% Commands - for pure mathematics
\newcommand{\derivn}[1]{\frac{d^{#1}y}{dx^{#1}}}
\newcommand{\newtdiff}[2]{\frac{\Delta #1 (#2)}{\Delta #2}}
\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\norm}[1]{\left\| #1 \right\|}
\newcommand{\mat}[1]{\mathbf{#1}}
\newcommand{\rank}[1]{\text{rk}(#1)}
\newcommand{\rref}[1]{\text{rref}(#1)}
\newcommand{\kernel}[1]{\text{ker}(#1)}
\renewcommand{\dim}[1]{\text{dim}(#1)}
\newcommand{\image}[1]{\text{Im}(#1)}
\newcommand{\tp}[1]{#1^\top}
\newcommand{\vs}[1]{\text{span} \left\{ #1 \right\}}

% Commands - for discrete mathematics
\newcommand{\dis}[1]{\texttt{#1}}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\floor}[1]{\lfloor #1 \rfloor}
\newcommand{\ceil}[1]{\lceil #1 \rceil}
\newcommand{\pre}{$_{pre}$}
\newcommand{\set}[1]{\{#1\}}
\newcommand{\pair}[1]{\langle #1 \rangle}
\newcommand{\tuple}[1]{\langle #1 \rangle}
\newcommand{\dom}[1]{\text{dom}(#1)}
\newcommand{\addr}[1]{\text{\textopencorner} #1 \text{\textcorner}}
\newcommand{\bigO}[1]{O(#1)}
\newcommand{\bigTheta}[1]{\Theta(#1)}

% Environments
\newenvironment{prf}{\textbf{Proof.}}{\qedsymbol}
\newenvironment{amatrix}[1]{%
  \left[\begin{array}{{}*{#1}{c}|c@{}}
}{%
  \end{array}\right]
}
\newenvironment{aMatrix}[1]{%
  \left[\begin{array}{{}*{#1}{c}|{}*{#1}{c}}
}{%
  \end{array}\right]
}

% Math operators
\DeclareMathOperator{\derivone}{\frac{dy}{dx}}
\DeclareMathOperator{\rarrow}{\rightarrow}
\DeclareMathOperator{\darrow}{\leftrightarrow}
\DeclareMathOperator{\rArrow}{\Rightarrow}
\DeclareMathOperator{\dArrow}{\Leftrightarrow}
\DeclareMathOperator{\R}{\mathbb{R}}
\DeclareMathOperator{\N}{\mathbb{N}}
\DeclareMathOperator{\Z}{\mathbb{Z}}
\DeclareMathOperator{\C}{\mathbb{C}}
\DeclareMathOperator{\Q}{\mathbb{Q}}
\DeclareMathOperator{\iden}{\approx}
\DeclareMathOperator{\perm}{\sim}

% Theorem styles
\newtheorem{theorem}{Theorem}
\newtheorem{thm}{Theorem}

% ##### MODIFY YOUR TITLE HERE #####
\title{MOLT - Max's Own \LaTeX \ Template \\ Sample Document}
\author{Sample Author}
\date{\today}

% ##### MODIFY HEADING/FOOTING HERE #####
\lhead{Sample Author}
\chead{Sample Document}
\rhead{\today}
\lfoot{MOLT - Max's Own \LaTeX \ Template (Spring 2021)}
\cfoot{}
\rfoot{\thepage}

% ##### DOCUMENT STARTS HERE #####
\begin{document}
\maketitle

\section*{Sample Section}

\subsection*{Sample Subsection}
This is some sample text. \\

Here are some sample text, in code style: \code{printf(``Hello world!'');} \\

There are plenty of commands defined for mathematical (pure and discrete) symbols and formulae - feel free to look them up in the heading section of the \code{.tex} file.

\newpage

\section{Sample Section, Numbered}

\textbf{Question 1. (42 marks)} This is a sample question.

\begin{shaded}
    This is the sample sample, with the paragraph shaded. \\

    \emph{This template is pretty good at turning college worksheets into paperless format.}
\end{shaded}

\end{document}