\section{Jacobi Plate Temperature Simulation}
\paragraph{Goals and algorithms.}
For the two programs implemented to simulate a square plate's temperature
distribution over time until a stable heat was achieved throughout the
entire plate. The jacobi method was chosen as the algorithm to simulate this.
Parallelization of the algorithm was done by partitioning the plate into
sectioned rows that each thread would perform the calculation on exclusively
from one another.

\paragraph{Jacobi Implemented in C++.}
There are three implementations of Jacobi in C++: A Serial version, and two
parallel versions. This was done because the initial parallel version, which
created new threads each iteration, performed poorly compared to the serial
version; The second parallel version instead created the child threads once,
and used semaphores to synchronize the threads each iteration instead. This
second parallel version's performance was much closer to the serial version
when utilizing only a single child thread. It also proved to scale with
additional threads at a rate much better than the first parallel version,
eclipsing both the performance of the serial and first parallel version.

\par Each version of jacobi was timed using the same rules. The clock starts
after arguments to the program are checked, and just before the arrays
simulating the plate are initialized. This timer ends after the total number
of cells below the value 50.0 is calculated.

\paragraph{Jacobi Implemented in Rust.}
Jacobi had three versions implemented in Rust as well, for performance anomalies
just like the C++ implementation. The three versions are as follows: A Serial
version, a stdlib parallel version, and a crossbeam parallel version. The serial
version of jacobi was a straightforward port from the C++ one to Rust, while
the crossbeam version was made due to the stdlib of Rust being insufficient for
implementing concurrent jacobi.

\par The first major change made in all versions was
from allocating the array that represents the plate as a static global to
dynamically allocating it during runtime as a vector out of necessity. This was
done as Rust does not allow for global mutable variables, and stack allocation
of the plate would overflow the stack. The second import implementation detail
difference for the stdlib version was the huge costs incurred in-order to
satisfy Rust's borrow checker without the aid of the recently removed
{\cf std::scoped::thread}. The crossbeam version of rust remedies the
performance-costing changes made to accommodate the Rust stdlib by utilizing a
third-party library written in Rust that emulates the functionality provided by
{\cf std::scoped::thread}.

%TODO(todd): Write more

\paragraph{User Experience writing Jacobi in C++.}
This was very simple to implement, it was based off of a single threaded C
version so most of the math parts were already figured out, it was just a
matter of making it concurrent. The only major issue that arose was a small
thread creation loop that went unnoticed until benchmarking was done, it
spawned threads but then never used them which caused some performance
anomalies until it was found and removed.

\paragraph{User Experience writing Jacobi in Rust.}
The serial version of jacobi implemented in Rust was very straightforward. Rust
lends itself well to porting code from C++ to Rust, as the Rust version was
based of the C++ version. Rust provides the convenience of zero-initializing
every variable by default, which removed the need for an amount of the jacobi
initialization code\footnote{This can also be done explicitly in C++}.
Attempting to allocate the array that represented the plate managed to trigger
a segfault, although a minor one, in Rust for the first time. It appears that
Rust cannot guarantee against over-allocating the stack understandably.

\par Implementing the first parallel version using only the standard library
was very difficult, as sharing portions of an array among threads and
guaranteeing the lifetimes of the grid portions is necessary. It was a battle
against Rust's borrow checker rather than solving the problem, as even though
joining the threads at the end should guarantee that they do not outlive the
main thread, Rust was unable to understand this and failed to compile the program.
%TODO(todd): finish


\documentclass[12pt,twoside]{article}

\newcommand{\reporttitle}{Title of course}
\newcommand{\reportauthor}{Your Name}
\newcommand{\reporttype}{Coursework}
\newcommand{\cid}{your college-id number}

% include files that load packages and define macros
\input{includes} % various packages needed for maths etc.
\input{notation} % short-hand notation and macros

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

\begin{document}
% front page
\input{titlepage}

%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main document
\section{Introduction}
This is a template for coursework submission. Many macros and definitions can be found in \texttt{notation.tex}. This document is not an introduction to LaTeX. General advice if get stuck: Use your favorite search engine. A great source is also \mbox{\url{https://en.wikibooks.org/wiki/LaTeX}}.

\section{Basics}

\subsection{Figures}
A figure can be included as follows:
\begin{figure}[tb]
\centering % this centers the figure
\includegraphics[width = 0.7\hsize]{./figures/usc} % this includes the figure and specifies that it should span 0.7 times the horizontal size of the page
\caption{This is a figure.} % caption of the figure
\label{fig:usc} % a label. When we refer to this label from the text, the figure number is included automatically
\end{figure}
Fig.~\ref{fig:usc} shows the USC logo.

Some guidelines:
\begin{itemize}
\item Always use vector graphics (scale free)
\item In graphs, label the axes
\item Make sure the font size (labels, axes) is sufficiently large
\item When using colors, avoid red and green together (color blindness)
\item Use different line styles (solid, dashed, dotted etc.) and different markers to make it easier to distinguish between lines
\end{itemize}

\subsection{Notation}
\begin{table}[tb]
\caption{Notation}
\label{tab:notation}
\centering
\begin{tabular}{ll}
Scalars & $x$\\
Vectors & $\vec x$\\
Matrices & $\mat X$\\
Transpose & $\T$\\
Inverse & $\inv$\\
Real numbers & $\R$\\
Expected values & $\E$\\
\end{tabular}
\end{table}
Table~\ref{tab:notation} lists some notation with some useful shortcuts (see latex source code).

\subsubsection{Equations}
Here are a few guidelines regarding equations
\begin{itemize}
\item Please use the \texttt{align} environment for equations (\texttt{eqnarray} is buggy)
\item Please number all equations: It will make things easier when we need to refer to equation numbers. If you always use the \texttt{align} environment, equations are numbered by default.
\item Vectors are by default column vectors, and we write
\begin{align}
\vec x &= \colvec{1,2}
\end{align}
\item Note that the same macro (\texttt{$\backslash$colvec}) can produce vectors of variable lengths, as
\begin{align}
\vec y &= \colvec{1,2,3,4}
\end{align}
\item Matrices can be created with the same command. The \& switches to the next column:
\begin{align}
\mat A = \begin{bmatrix}
1 & 2 & 3\\
3 & 4 & 5
\end{bmatrix}
\end{align}
\item Determinants. We provide a simple macro (\texttt{$\backslash$matdet}) whose argument is just a matrix array:
\begin{align}
\matdet{
1 & 2 & 3\\
3 & 4 & 5\\
2 & 2 & 2
}
\end{align}
\item If you do longer manipulations, please explain what you are doing: Try to avoid sequences of equations without text breaking up. Here is an example:
We consider
\begin{align}
U_1 = [\colvec{1,1,0,0},\, \colvec{0,1,1,0},\, \colvec{0,0,1,1}]
\subset\R^4, \quad
U_2 = [\colvec{-1,1,2,0},\, \colvec{0,1,0,0}]
\subset\R^4\,.
\end{align}
To find a basis of $U_1\cap U_2$, we need to find all $\vec x \in V$ that can be represented as linear combinations of the basis vectors of $U_1$ and $U_2$, i.e.,
\begin{align}
\sum_{i=1}^3 \lambda_i \vec b_i = \vec x = \sum_{j=1}^2 \psi_j \vec c_j\,,
\end{align}
where $\vec b_i$ and $\vec c_j$ are the basis vectors of $U_1$ and $U_2$, respectively.
%
The matrix $\mat A = [\vec b_1|\vec b_2|\vec b_3| -\vec c_1|-\vec
c_2]$ is given as
\begin{align}
\mat A =
\begin{bmatrix}
1 & 0 & 0 & 1 & 0\\
1 & 1 & 0 & -1 & -1\\
0 & 1 & 1 & -2 & 0\\
0 & 0 & 1 & 0 & 0
\end{bmatrix}\,.
\end{align}
By using Gaussian elimination, we determine the corresponding reduced row echelon form
\begin{align}
\begin{bmatrix}
1 & 0 & 0 & 1& 0\\
0 & 1 & 0 & -2 & 0\\
0 & 0 & 1 & 0 & 0\\
0 & 0 & 0 & 0 & 1
\end{bmatrix}
\,.
\end{align}
We keep in mind that we are interested in finding $\lambda_1,\lambda_2,\lambda_3\in\R$ and/or $\psi_1,\psi_2\in\R$ with
\begin{align}
\begin{bmatrix}
1 & 0 & 0 & 1& 0\\
0 & 1 & 0 & -2 & 0\\
0 & 0 & 1 & 0 & 0\\
0 & 0 & 0 & 0 & 1
\end{bmatrix}
\colvec{\lambda_1, \lambda_2, \lambda_3, \psi_1, \psi_2}
=\vec 0\,.
\end{align}
From here, we can immediately see that $\psi_2=0$ and $\psi_1\in\R$ is
a free variable since it corresponds to a non-pivot column, and our solution is
\begin{align}
U_1\cap U_2 = \psi_1\vec c_1 =  [ \colvec{-1,1,2,0} ]
\,, \quad \psi_1\in\R\,.
\end{align}
\end{itemize}

\subsection{Gaussian elimination}
We provide a template for Gaussian elimination. It is not perfect, but it may be useful:

\begin{elimination}[6]{5}{8mm}{1}
    \eliminationstep
    {
1 & - 2 & 1 & -1 & 1 &  0\\
0 & 0 & -1 & 1 & -3 & 2\\
0 & 0 & 0 & -3 & 6 & -3\\
0 & 0 & -1 & -2 & 3 & a
    }
    {
\\
\\
\\
-R_2
    }
    \\
\eliminationstep
 {
1 & - 2 & 1 & -1 & 1 &  0\\
0 & 0 & -1 & 1 & -3 & 2\\
0 & 0 & 0 & -3 & 6 & -3\\
0 & 0 & 0 & -3 & 6 & a-2
    }
    {
\\
\\
\\
-R_3
    }\\
\eliminationstep{
1 & - 2 & 1 & -1 & 1 &  0\\
0 & 0 & -1 & 1 & -3 & 2\\
0 & 0 & 0 & -3 & 6 & -3\\
0 & 0 & 0 & 0 & 0 & a+1
}
{
\\
\cdot (-1)\\
\cdot (-\tfrac{1}{3})\\
\\}
\\
\eliminationstep{
1 & - 2 & 1 & -1 & 1 &  0\\
0 & 0 & 1 & -1 & 3 & -2\\
0 & 0 & 0 & 1 & -2 & 1\\
0 & 0 & 0 & 0 & 0 & a+1
}{}
\end{elimination}

The arguments of this environment are:
\begin{enumerate}
\item Number of columns (in the augmented matrix)
\item Number of free variables (equals the number of columns after which the vertical line is drawn)
\item Column width
\item Stretch factor, which can stretch the rows further apart.
\end{enumerate}

\newpage
\section{Answer Template}
\begin{enumerate}[1)]
\item Discrete models

\begin{enumerate}[a)]
\addtocounter{enumii}{2} % change to enumi if you use sections rather than enumerate for question numbers
\item
\item
\item
\end{enumerate}

\item Differentiation

\begin{enumerate}[a)]
\item
\item
\addtocounter{enumii}{1}
\item
\item
\end{enumerate}

\item Continuous Models

\begin{enumerate}[a)]
\item
\item
\item
\item
\item
\item
\item
\end{enumerate}

\item Linear Regression

\begin{enumerate}[a)]
\item
\item
\item
\item
\end{enumerate}

\item Ridge Regression

\begin{enumerate}[a)]
\item
\item
\item

\begin{enumerate}[i)]
\item
\item
\end{enumerate}

\end{enumerate}

\item Bayesian Linear Regression

\begin{enumerate}[a)]
\addtocounter{enumii}{1}
\item
\item
\item
\item (bonus)
\end{enumerate}

\end{enumerate}

\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


% mental note to run makeindex on final compilation

\documentclass[a5paper]{memoir}

\usepackage[english]{babel}
\usepackage[autostyle, english = american]{csquotes}
\usepackage{parskip}
\usepackage{makeidx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{tabu}
\usepackage{tabularx}
\usepackage{systeme}
\usepackage{graphicx}
\usepackage[margin=1cm]{caption}
\usepackage[super]{nth}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{hyperref}

\hypersetup{pdftitle={A Comprehensive Guide to the CASIO fx-9860GIIs},pdfauthor={Sun Yudong, Li Yicheng},bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=1,	colorlinks=true,linkcolor=black,pdfpagemode=UseOutlines,pdfpagelayout=TwoPageRight}

\MakeOuterQuote{"}
\makeindex

\newenvironment{acknowledgements}%
{\cleardoublepage\thispagestyle{empty}\null\vfill\begin{center}%
		\bfseries Acknowledgements\end{center}}%
{\vfill\cleardoublepage\null}

%\graphicspath{{subdir1/}{subdir2/}{subdir3/}...{subdirn/}}
\graphicspath{{screenshots/}}

% lambda
	% http://tex.stackexchange.com/questions/290165/how-do-i-get-a-nicer-lambda
	% ref.: egreg at http://tex.stackexchange.com/a/14406/
	\usepackage{pifont}
	\makeatletter
	\newcommand\Pimathsymbol[3][\mathord]{%
		#1{\@Pimathsymbol{#2}{#3}}}
	\def\@Pimathsymbol#1#2{\mathchoice
		{\@Pim@thsymbol{#1}{#2}\tf@size}
		{\@Pim@thsymbol{#1}{#2}\tf@size}
		{\@Pim@thsymbol{#1}{#2}\sf@size}
		{\@Pim@thsymbol{#1}{#2}\ssf@size}}
	\def\@Pim@thsymbol#1#2#3{%
		\mbox{\fontsize{#3}{#3}\Pisymbol{#1}{#2}}}
	\makeatother
	% the next two lines are needed to avoid LaTeX substituting upright from another font
	\input{utxmia.fd}
	\DeclareFontShape{U}{txmia}{m}{n}{<->ssub * txmia/m/it}{}
	% you may also want
	\DeclareFontShape{U}{txmia}{bx}{n}{<->ssub * txmia/bx/it}{}
	% just in case
	%\DeclareFontShape{U}{txmia}{l}{n}{<->ssub * txmia/l/it}{}
	%\DeclareFontShape{U}{txmia}{b}{n}{<->ssub * txmia/b/it}{}
	% plus info from Alan Munn at http://tex.stackexchange.com/questions/290165/how-do-i-get-a-nicer-lambda?noredirect=1#comment702120_290165
	\newcommand{\pilambdaup}{\Pimathsymbol[\mathord]{txmia}{21}}

% linear algebra
	% http://tex.stackexchange.com/questions/2233/whats-the-best-way-make-an-augmented-coefficient-matrix
	\newenvironment{amatrix}[1]{%
		\left(\hspace{0.15cm}\begin{array}{@{}*{#1}{c}|c@{}}
		}{%
	\end{array}\hspace{0.15cm}\right)
	}

	\def\VR{\kern-\arraycolsep\strut\vrule &\kern-\arraycolsep}
	\def\vr{\kern-\arraycolsep & \kern-\arraycolsep}

\pretitle{\begin{center}\Huge\bfseries}
	\title{A Comprehensive Guide to the CASIO fx-9860GIIs}
	\posttitle{\par\vskip1em{\normalfont\normalsize\scshape The better graphing calculator for H2 Mathematics \\ \vspace{1cm} Quick Reference Math included\par\vfill}\end{center}}
\author{Sun Yudong, Li Yicheng \\ 15S6G \\ Hwa Chong Institution (College Section)}
\predate{\vfill\begin{center}\large}

\def\code#1{\texttt{#1}}
\def\note#1{\textcolor[HTML]{109fa9}{\textbf{\textit{Note:}}} #1}
\def\tip#1{\textcolor[HTML]{a9109f}{\textbf{\textit{Tip:}}} #1}
\def\caution#1{\textcolor[HTML]{b02f10}{\textbf{\textit{Caution:}}} #1}
\def\example#1{{\centering -- \textcolor[HTML]{2a6c06}{\textbf{\textit{Example:}}} #1 --\par}}

\newenvironment{sidenote}%
{\textcolor[HTML]{00559e}{\textbf{\textit{Sidenote:}}} \color[HTML]{3c90d8}}%
{\ignorespacesafterend}

\def\runmat{\code{RUN$\cdot$MAT} }

% define column vector
% creds: http://tex.stackexchange.com/questions/2705/typesetting-column-vector#2712
% usage: \colvec{m}{a}{b}{c}
\newcount\colveccount
\newcommand*\colvec[1]{
	\global\colveccount#1
	\left(
	\begin{array}{c}
	% \begin{pmatrix}
		\colvecnext
	}
	\def\colvecnext#1{
		#1
		\global\advance\colveccount-1
		\ifnum\colveccount>0
		\\
		\expandafter\colvecnext
		\else
	%\end{pmatrix}
	\end{array}
	\right)
	\fi
}

%define function buttons
\def\Fone{(\code{F1}) }
\def\Ftwo{(\code{F2}) }
\def\Fthree{(\code{F3}) }
\def\Ffour{(\code{F4}) }
\def\Ffive{(\code{F5}) }
\def\Fsix{(\code{F6}) }

\def\fone{(\code{F1})}
\def\ftwo{(\code{F2})}
\def\fthree{(\code{F3})}
\def\ffour{(\code{F4})}
\def\ffive{(\code{F5})}
\def\fsix{(\code{F6})}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
\setlength{\footnotesep}{\baselineskip}

%\setcounter{tocdepth}{2} % which level the sectioning commands are printed in the ToC
%\setcounter{secnumdepth}{4} %up to what level the sectioning titles are numbered\makeatletter
\setsecnumdepth{subsection}

\newcommand{\specialcell}[2][c]{%
	\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
% \specialcell{No. of serious\\accidents in a day}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\newcommand{\addtoindex}[1]{#1\index{#1}}

\begin{document}

\begin{titlingpage}
	\maketitle
\end{titlingpage}

\frontmatter

\begin{acknowledgements}
	Were we to delve deeper into die Welt der Mathematik, we would scarce be able to differentiate the real and the imaginary.

	Who would have known, that with functions ranging limitless, and planes stretching to infinity, we could prosper in this World of Mathematics. Just as a plane cannot be fully defined without its normal vector, we thank our tutor Mr Yee Weng Hong for his patient direction, without whom this guide would not have been possible.

	We also thank the Hwa Chong Institution Mathematics Department, for it has been the distribution of their awesome and systematic notes, which we have sampled very generously in this friendly guide, that has greatly increased our probability of success.

	And to our friends, with whom our paths have crossed, thank you for supporting us the whole way.

	This integrated guide is dedicated to everyone who has dared to think different.

	Who, against all odds, shall stand firm against the evil Alevelus Examinus -- with their Casio fx-9860GIIs calculator in hand.
\end{acknowledgements}

\tableofcontents

\chapter{Preface}
This guide is provided as-is and was compiled by a bunch of students in 2016. We tried our best to be mathematically and technically accurate. But software versions (Ver 2.04 now) do change, and this guide may not be valid indefinitely. However, the source of this file is publically available on GitHub. Feel free to contact us.

If there are anything you want to do, but you can't seem to know how to, try Google, or RTFM. Otherwise, just experiment a bit. The CASIO interface should be intuitive enough.

Do note that some notes inside this guide were taken from the H2 Mathematics notes provided by the Hwa Chong Institution (College Section) Math Department.

\vspace{0.7cm}

\begin{tabular}{l l}
	Sun Yudong: & sunjerry019 [at] gmail [dot] com \\
	Li Yicheng: & liyicheng340 [at] gmail [dot] com
\end{tabular}

\mainmatter
\chapter{The Basics}
Every command you will ever need is organized neatly in the \code{[OPTN]} button on your graphing calculator (GC).

Unfortunately there are some areas where the CASIO calculator isn't very intuitive and we need some documentation, and this section is a primer of the functionailities that we can't really sort into specific H2 Mathematics topics.

\tip{You can just press the button that corresponds to the number/letter at the bottom right of the icons in the menu:}

\begin{figure}[h]
	\centering
	\includegraphics[width=0.5\textwidth]{mainmenu}
\end{figure}

\section{Display Modes}
As a special mention that you probably did not notice, we shall first introduce the different display modes that the calculator is capable of. In the Set Up menu (\code{[SHIFT] + [MENU]}), there are different display options, and we summarize their corresponding functions as follows:
\begin{center}
	\renewcommand{\arraystretch}{1.3}
	\begin{tabular}{|c|p{7.5cm}|}
		\hline
		\textbf{Mode}	&	\textbf{What it does} \\
		\hline
		\code{Fix}$n$	&	Rounds off answer to $n$ decimal places \\
		\hline
		\code{Sci}$n$	&	Rounds off answer to $n$ significant figures \\
		\hline
		\code{Norm}		&	Converts answer to scientific notation when the value $x$ lies outside of the following range: \vspace{2mm} \newline \hspace*{5mm} \textbf{\code{Norm1}}: $10^{-3}>|x|>10^{10}$ \newline \hspace*{5mm} \textbf{\code{Norm2}}: $10^{-9}>|x|>10^{10}$ \\
		\hline
	\end{tabular}
\end{center}

In addition to these options, there is also a \code{Eng} mode that adds on to those above mentioned modes. The \code{/E} indicator is on display while the engineering notation is in effect (e.g. \code{Norm1/E}).

In the engineering mode, answers are displayed with standard order-of-magnitude prefixes, and the symbol that makes the mantissa a value from 1 to 1000 is automatically chosen:
\begin{center}
	\renewcommand{\arraystretch}{1.3}
	\begin{tabular}{|c|c||c|c|}
		\hline
		E (Exa)		& $\times10^{18}$	& m (milli)	& $\times10^{-3}$ \\
		\hline
		P (Peta)	& $\times10^{15}$	& $\mu$ (micro)	& $\times10^{-6}$ \\
		\hline
		T (Tera)	& $\times10^{12}$	& n (nano)	& $\times10^{-9}$ \\
		\hline
		G (Giga)	& $\times10^{9}$	& p (pico)	& $\times10^{-12}$ \\
		\hline
		M (Mega)	& $\times10^{6}$	& f (femto)	& $\times10^{-15}$ \\
		\hline
		k (kilo)	& $\times10^3$		& 	&  \\
		\hline
	\end{tabular}
\end{center}

You can also type these prefixes when doing calculations: they are available under \code{[OPTN] > $\triangleright\times$2 > ESYM} \Fone. You might find these extremely useful when doing calculations for Physics.

Under that same menu, there is also the \code{ENG} and $\overleftarrow{\texttt{ENG}}$ which shifts the decimal place of the displayed value 3 digits to the (left/right), and (decreases/increases) the exponent by 3 respectively.

\section{Radian/Degree/Gradian} \label{sec:angleunits}

Like the majority of other scientific calculators, this GC is able is accept input and display the magnitude of angles in either degrees, radians, or gradians. To change between the 3, enter the Set Up menu, and scroll down until you see a row labelled \code{Angle}. The 3 different units are the displayed at the bottom of the screen and can be selected by the \code{[F1]} to \code{[F3]} buttons.

Note that this setting is universal throughout your GC - it will change the units angles are handled in every mode including but not limited to usual calculations, graphing, etc, unless you specifically specify otherwise (not covered in this section). Therefore, it is vital that you check your units before undergoing any calculation, especially before and during examinations.

\section{Storing values into variables}
You can also store values into variables, just like with your trusty fx-95SG PLUS Calculator. To do this, simply type the value and then use the $\rightarrow$ to store it into a variable:

\begin{figure}[h]
	\centering
	\includegraphics[width=0.5\textwidth]{savevar}
\end{figure}

This also works for vectors and matrices, but the data type must correspond before and after the $\rightarrow$.

\section{Solving for the roots of a polynomial}
There are mainly 2 ways to solve for the roots of a polynomial using the GC:
\begin{itemize}
	\item Using the \code{EQUA > Poly} \Ftwo app
	\item Plot a graph and solve for roots
\end{itemize}

The \code{EQUA > Poly} is quite intuitive, and similar to the standard issue CASIO fx-95SG scientific calculator, so we will just note some limitations/features of this GC:
\begin{itemize}
	\item The polynomial solver only accepts real coefficients
	\item You can change the \code{Set Up > Complex Mode} setting to \code{$a+bi$} for imaginary roots (but not imaginary coefficients)
\end{itemize}

To plot a graph, you go to \code{Graph}. Refer to Section \ref{chap:graphing} (Graphing) for more information.

\section{Solving a 1-variable Equation}
There are mainly 2 ways to solve a 1-variable equation (e.g. $e^x + 5x = 1$) using the GC:
\begin{itemize}
	\item Using the \code{EQUA > Solver} \Fthree app
	\item Using \code{Solve} or \code{SolveN}
	\item Plotting a graph
	\begin{itemize}
		\item Move everything to one side and solve for root
		\item Solve for the intersections of 2 or more graphs
	\end{itemize}
\end{itemize}

\subsection{Solving using \code{EQUA > Solver}}
To use the built-in equation solver:
\begin{enumerate}
	\item Go to \code{EQUA > Solver} \Fthree
	\item Enter the equation you would like to solve under \code{Eq}. Remember to put the = sign.
	\begin{itemize}
		\item Alternatively, you can use \code{RCL} \Fone to recall functions entered into \code{GRAPH} or \code{TABLE}
	\end{itemize}
	\item Press \code{[EXE]} and put your initial guess under \code{X}. An example can be as such:
	\begin{center}
		\code{
			\begin{tabular}{|r|l|}
				\hline
				X 		& 0 \\
				\hline
				Lower 	& -9E+99 \\
				\hline
				Upper	& 9E+99 \\
				\hline
			\end{tabular}
		}
	\end{center}
	\item Press \code{Solv} \Fsix
\end{enumerate}

\note{}The initial guess isn't very important for equations with unique solutions. However, if the equation has multiple solutions, it will give the answer closer to the original guess.

For example, given the equation $(x-1)(x-3)=0$, entering the following will give the corresponding answers:
\begin{center}
	\renewcommand{\arraystretch}{1.2}
	\begin{tabular}{|c|c|}
		\hline
		$X$ 	& Answer \\
		\hline
		0		& 1 \\
		\hline
		1.5 	& 1 \\
		\hline
		2		& 1 \\
		\hline
		2.5		& 3 \\
		\hline
		4		& 3 \\
		\hline
	\end{tabular}
\end{center}

After solving the equation, you can always access the value again by going to \runmat and typing \code{X}.

\subsection{Solving using \code{Solve} or \code{SolveN}}
Alternatively, you can use the \code{Solve} or \code{SolveN} functions in \runmat to obtain the solution. They can be found under \code{[OPTN] > CALC}\Ffour.

Their usage is as follows, as far as we have discovered:
\begin{center}
	\code{Solve(<equation>,<initial guess>)} \\
	\code{SolveN(<equation>)}
\end{center}

Both \code{Solve} and \code{SolveN} will give you only 1 answer, and works similar to how the \code{EQUA > Solver} works.

\section{Solving a Multi-variable Linear System}
There are 3 types of linear systems, namely systems with:
\begin{itemize}
	\item No solution
	\item 1 unique solution
	\item Infinitely many solutions
\end{itemize}

To solve a multi-variable system of linear equations using your GC, there are 2 main ways:
\begin{enumerate}
	\item Using the \code{EQUA > Siml} \Fone app
	\item Using matrices
\end{enumerate}

\subsection{Using the \code{EQUA > Siml} app}
While you can use matrices to solve any kind of linear system, you can use the \code{EQUA > Siml} app \textit{\textbf{only if the linear system has a unique solution}}.

\note{Should you try to use the \code{EQUA > Siml} app to solve for a linear system with no solution, or infinitely many solutions, the calculator would just throw a \code{Ma Error} at you while you stare, bemused, wondering why the calculator is so bad to you.}

Anyhow, the app is intuitive enough, so I shall skip it.

\subsection{Using Matrices} \label{sec:usingMatrices}

To solve a linear system the matrix way, let's first consider the following linear system:
\begin{center}
	\syslineskipcoeff{1.2}
	\systeme{
		\hspace{0.2cm} x+y+2z=9,
		\hspace{0.2cm} 2x+4y-3z=1,
		\hspace{0.2cm} 3x+6y-5z=0
	}
\end{center}

By taking the coefficients of the variables $x$, $y$ and $z$, we can form the following augmented matrix:
\[
	\begin{amatrix}{3}
		1 & 1 & 2  & 9 \\
		2 & 4 & -3 & 1 \\
		3 & 6 & -5 & 0
	\end{amatrix}
\]

To solve for $x$, $y$ and $z$:\footnote{ Fn Keys have been left out to save space.}
\begin{enumerate}
	\item Go to \runmat \code{> $\triangleright$MAT}
	\item Select \code{Mat A} and enter the dimensions
	\begin{itemize}
		\item $m$ is the number of rows, in this case 3
		\item $n$ is the number of columns, in this case 4
	\end{itemize}
	\item Enter the augmented matrix above accordingly, putting the augmented column into the 4th column:
	\begin{equation*}
		\left[
			\begin{array}{cccc}
			1 & 1 & 2  & 9 \\
			2 & 4 & -3 & 1 \\
			3 & 6 & -5 & 0
			\end{array}
		\right]
	\end{equation*}
	\item Press \code{[EXIT]} then \code{[EXIT]} to go back to the main \runmat screen
	\item Go to \code{[OPTN] > MAT > $\triangleright$ > Rref}
	\item Then \code{ $\triangleright \times 3$ > Mat}, then \code{[ALPHA] + A}, giving the following:
	\begin{center}
		\code{Rref Mat A}
	\end{center}
	\item Press \code{[EXE]}, and then you should be able to get the following matrix:
	\begin{equation*}
		\left[
			\begin{array}{cccc}
			1 & 0 & 0 & 1 \\
			0 & 1 & 0 & 2 \\
			0 & 0 & 1 & 3
			\end{array}
		\right]
	\end{equation*}
\end{enumerate}

This can then be rewritten as an augmented matrix:
\begin{equation*}
\bordermatrix{  & x & y & z & \vr ~ \cr
			  ~ & 1 & 0 & 0 & \VR 1 \cr
			  ~ & 0 & 1 & 0 & \VR 2 \cr
			  ~ & 0 & 0 & 1 & \VR 3 }
\end{equation*}

which can then be rewritten as:
\begin{center}
	\syslineskipcoeff{1.2}
	\systeme{
		\hspace{0.2cm} x=1,
		\hspace{0.2cm} y=2,
		\hspace{0.2cm} z=3
	}
\end{center}

Notice that the left side of the final augmented matrix is the identity matrix. This is what you would typically see for a linear system with a unique solution.

This same procedure can be used to find the solutions of any linear system with any number of variables.

The following are possible matrices you can obtain after the \code{Rref} command for the other types of linear systems:

\begin{itemize}
	\item \textbf{No solution}
	\begin{equation*}
		\begin{tabu}{ccc}
			\begin{amatrix}{3}
			1 & 0 & 2 & 2 \\
			0 & 1 & 3 & 3 \\
			0 & 0 & 0 & 1
			\end{amatrix} & \rightarrow & \syslineskipcoeff{1.2}
			\systeme{
				\hspace{0.2cm} x=2-2t,
				\hspace{0.2cm} y=3-3t,
				\hspace{0.2cm} 0z=1
			}\\
		\end{tabu}
	\end{equation*}
	where $t \in \mathbb{R}$

	Since $0=1$ is not possible, the above linear system is inconsistent and has no solutions.
	\item \textbf{Infinitely many solutions}
	\begin{equation*}
		\begin{tabu}{ccc}
			\begin{amatrix}{3}
			1 & 0 & 2 & 2 \\
			0 & 1 & 3 & 3 \\
			0 & 0 & 0 & 0
			\end{amatrix} & \rightarrow & \syslineskipcoeff{1.2}
			\systeme{
				\hspace{0.2cm} x=2-2t,
				\hspace{0.2cm} y=3-3t,
				\hspace{0.2cm} z=t
			}\\
		\end{tabu}
	\end{equation*}
	where $t \in \mathbb{R}$

	In this case, the answer is obtained easily through back-substitution. Rewriting the augmented matrix, we observe that:
	\begin{center}
		\syslineskipcoeff{1.2}
		\systeme{
			\hspace{0.2cm} x+2z=2,
			\hspace{0.2cm} y+3z=3
		}
	\end{center}

	By letting $z$ be a parameter $t$ ($t \in \mathbb{R}$), we observe that:
	\begin{equation*}
	\begin{tabu}{ccc}
		\syslineskipcoeff{1.2}
		\systeme{
			\hspace{0.2cm} x+2t=2,
			\hspace{0.2cm} y+3t=3,
			\hspace{0.2cm} z=t
		} & \rightarrow & \syslineskipcoeff{1.2}
			\systeme{
				\hspace{0.2cm} x=2-2t,
				\hspace{0.2cm} y=3-3t,
				\hspace{0.2cm} z=t
			}\\
		\end{tabu}
	\end{equation*}

	Thus obtaining the general solution.
\end{itemize}

You will find this useful for both "System of Linear Equations" and "Vectors" (See Chapter \ref{chap:vectors}).

For a more in-depth understanding of what is going on here, you may wish to refer to Section \ref{sec:solvLinSys}.

\section{How to reset your calculator}
This is a question that we get asked all the time: 2-8-On DOESN'T WORK, how in the world do I reset this calculator for the exam?

Well, worry not my intrepid mathematician, because we will answer your question in this section. But just to make it clear, we are not \textit{too} sure what the \textit{correct} way to do this is, and these instructions here exists purely as a form of reference.

Okay so, once that is out of the way, there are generally 2 ways of resetting your calculator, and they are both in \code{SYSTEM > Reset} \Ffive \code{> $\triangleright$} \fsix:

\begin{figure}[h]
	\centering
	\includegraphics[width=0.5\textwidth]{resetscreen}
\end{figure}

Generally, the \code{Main\&Storage} option will do you well. It deletes any and all calculations made, and programs you have added, and resets your current settings (such as fraction display modes) back to the factory setting. Showing the end result of this screen to the examiner will \textit{usually} suffice.
\begin{figure}[h]
	\begin{minipage}[h]{0.5\textwidth}
			\centering
			\includegraphics[width=0.95\textwidth]{resetms}
	\end{minipage}%
	\begin{minipage}[h]{0.5\textwidth}
			\centering
			\includegraphics[width=0.95\textwidth]{resetinit}
	\end{minipage}
\end{figure}

Alternatively, there is the \code{Initialize All} option, which initializes your whole calculator to the factory state (aka the state in which you bought your calculator), this will also work.

There is also a button to \textbf{\textit{restart}} the calculator should it act abnormally, or freeze. You will find this at the back of your calculator right above the battery holder.

\section{Others}
Other functionalities, such as copy and pasting, will not be covered here. Please check out the manual provided by Casio on their website. A quick google for "Casio fx9860GII user manual" should suffice.

\chapter{Graphing} \label{chap:graphing}

In this short chapter, we will explore the main functions of a graphing calculator, and that is to graph functions.

\section{Basic Operations}
To graph a function, go to \code{GRAPH} in the main menu. Enter the functions into \code{Y1} onwards. Press \code{DRAW} \Fsix or \code{[EXE]} to graph. Most of these are pretty intuitive, just some things you should take note:
\begin{itemize}
	\item The \code{Y} and \code{X}, etc. at the bottom of the screen is for entering the functions \code{Y1, Y2, \dots} and \code{X1, X2, \dots}. For the variable $x$, use the \code{[X,$\theta$,T]} button instead
	\item To restrict the domain of the function, type:
	\begin{center}
		\code{Y1 = $f(x)$,[start,end]}
	\end{center}
	\note{Restricting the domain disables the sketching of the inverse of a graph.}
\end{itemize}

\begin{figure}[h]
	\centering
	\includegraphics[width=0.5\textwidth]{sinx}
	\caption{Graph of sin($x$), for $-\pi \leq x \leq \pi$}
\end{figure}

After pressing \code{DRAW} (\code{F6} or \code{[EXE]}), you can press \code{[AC/on]} to break the plotting script.

\subsection{Solving for values from the plotted graph}

To solve for anything, use \code{[G-Solv]} \Ffive.

==== Add Intersection, and stuff

\section{Sketching}
Once a graph is plotted, you can sketch additional graphs on top of the already plotted graph. This includes sketching the inverse\index{Sketching!Inverse} of a function, tangent\index{Sketching!Tangent} and normal\index{Sketching!Normal} to a point on the curve.

\begin{figure}[h]
	\centering
	\includegraphics[width=0.5\textwidth]{normtan_sinx}
	\caption{Graph of sin($x$), for $-\pi \leq x \leq \pi$, with the normal and tangent drawn at $x=-2.5$}
\end{figure}

All these are accessible under the Sketch menu (\code{SHIFT > F4}).

When sketching the normal/tangent, just press the number keys if you would like to enter a specific X-value to plot the normal/tangent at.

\section{Plotting a table from function} \label{sec:plottable}
To effectively use your calculator as a function generator, you can use the \code{TABLE} mode available in the menu:
\begin{enumerate}
	\item Go to \code{TABLE} and then enter your function just like how you would in \code{GRAPH}
	\item Go to \code{SET} \Ffive
\end{enumerate}

Once in table mode, you can enter values directly into the $X$ column to generate values using the function.

This is especially useful when you are doing the same operation multiple times on different numbers, or when you are generating solving a Sequences and Series question using the Method of Differences.

\section{Taking Integrals}
\subsection{Definite Integrals}
Your calculator can be used to solve definite integrals.

One way is to find the area under the graph after plotting the equation.

\begin{enumerate}
	\item Plot the graph following the instructions from Section \ref{chap:graphing}.
	\item Press \code{G-Solv} \Ffive, followed by $\triangleright$ \Fsix and \code{$\int$dx} \Fthree.
	\item A cursor on the curve will now appear on the graph, along with $x$ and $y$ values. Move the cursor to the lower bound of the definite integral you're trying to find, and press \code{EXE}, followed by the upper bound, and press \code{EXE} again.
	\item The area under the graph should now be shaded and the value of the area is displayed as \code{$\int$dx}.
\end{enumerate}

This method is great if you already have the graph plotted and want to find the integral quickly without entering the equation again. If you do not need to plot the graph and simply want to find the definite integral directly, you may find the integration function in the \runmat app more useful.

\begin{enumerate}
	\item From the main menu, enter the \runmat app (\code{1}).
	\item Press the \code{OPTN} button and select the \code{CALC} option \Ffour.
	\item Under the \code{CALC} submenu, choose the \code{$\int$dx} option (\code{F4}).
	\item Enter the equation as per standard Mathematical notation.

	\note{You should change the variable to be integrated from whatever letter it was originally to $x$ since the calculator forces the integral to be integrated with respect to $x$ as can be seen by the $dx$ at the back.}
\end{enumerate}

\subsection{Indefinite Integrals}
SEAB bans all calculators capable of direct symbolic integration and differentiation. In other words, you cannot enter $3x^2$ into your graphing calculator and get $x^3$ or vice versa. To be fair, this feature was never in the international version of the Casio anyway.

Thankfully, even in the Singaporean version of the Casio, you can plot the graph of the integral visually.

For example, we will try to plot the integral of $2x$. Assuming that your GC is working properly and the Laws of Mathematics have not changed in drastic ways, the graph should be identical to that of $x^2$.

\begin{enumerate}
	\item From the main menu, enter the \code{GRAPH} app (\code{5}).
	\item Under \code{Y1}, enter the function $2x$.
	\item Move to \code{Y2}. Enter the following function:
	\begin{equation*}
	\code{Y2}=\int_{0}^{x} \code{Y}1 \, dx
	\end{equation*}
	\note{\code{Y2} will take a significant amount of time to plot (around 5-10 seconds). It is recommended that you deselect \code{Y1} by pressing \code{SEL} \Fone to prevent \code{Y1} from being plotted, saving a couple of seconds.}
	\item Press \code{DRAW} \fsix. A parabola that identical to $y=x^2$ should be yield. You can plot $y=x^2$ on top of the integral to confirm.
\end{enumerate}

While this function is unable to give you the equation of the integral directly, you can use double check your integrals using this method. Plotting the integral using this method can also be useful if you have to find multiple definite integrals (using the trace function in the graph page).

\chapter{Vectors} \label{chap:vectors}

Casio added support for vectors with the \code{02.04.5301} firmware update. This is added on top of support for Matrices, which will be covered mainly in Chapter \ref{chap:linalge} (Linear Algebra).\footnote{While vectors are also covered in the Linear Algebra syllabus, this chapter will focus more on what is needed to tackle the H2 syllabus.}

\caution{Vector capabilities will be disabled in the new \textit{Exam Mode} that ships with the Ver. \code{2.09} update.\footnote{We will not be covering this as we are covering Ver. \code{2.04.5301}, the latest SEAB approved firmware version.}} However, as of present we are not aware of any requirements to activate \textit{Exam Mode} during SEAB's examinations.

\section{Entering a Vector}

Functionally, vectors in this GC is no different from a 1 by $n$ or a $n$ by 1 matrix. Hence, you can use \code{Mat} and \code{Vct} interchangeably, so long as they are of the correct order.

To enter a vector into the GC:

\begin{enumerate}
	\item Enter the \runmat mode and select \code{$\triangleright$MAT} \fthree
	\item Select \code{M$\leftrightarrow$V} \fsix. The top row should now say \code{Vector} and the \code{Vct A} row should be highlighted by default
	\item Press \code{EXE} and enter the vector's dimensions. For the following example vector, it is a $3\times1$ vector, so enter $m=3$ and $n=1$
	\begin{equation*}
		\colvec{3}{3}{1}{4}
	\end{equation*}
	\item Enter the values in your vector into the three rows as shown on your textbook/exam paper
	\item Press \code{EXIT} twice to return to the main \runmat screen
\end{enumerate}

Alternatively, if you are in \runmat and your Input/Output is set to \code{Math} in the settings, you can enter vectors simply by going to \code{MATH} \Ffour \code{>} \code{MAT} and then choosing the appropriately sized matrix. These entered matrices will replace your \code{Vct A}/etc. described in the next few sections.

Note that the labelling follows the conventional $m \times n$ format, where $m$ is the number of rows, and $n$ is the number of columns.

\section{Vector Calculations}

\subsection{Addition and Subtraction}

To perform addition or subtraction calculations between two vectors:

\begin{enumerate}
	\item At the main \runmat screen, press \code{[OPTN]}, followed by \code{MAT} \ftwo. Press \code{$\triangleright$} \Fsix twice, then select \code{Vct} \fone.
	\item Press the \code{[ALPHA]} button, then press the corresponding letter that represents your first vector. For example, if you entered the vector at the first row previously, press the button that corresponds to \code{A} (which is \code{[X,$\theta$,T]}).
	\item Press the usual addition or subtraction signs at the bottom right of your calculator depending on which calculation you wish to do.
	\item Repeat steps 1 and 2 for your second vector, then press \code{[EXE]} to calculate the result.
\end{enumerate}

\subsection{Dot Product}

Vector specific calculations are slightly more complicated than addition or subtraction. To find the dot product of two vectors:

\begin{enumerate}
	\item In the vector section under \code{OPTN > MAT}, select \code{DotP} \ftwo.
	\item Press \code{Vct}, then press the corresponding letter that represents the first vector in your dot product expression.
	\item Press the \code{[,]} button, then repeat step 2 but for the second vector in your dot product expression. It is good practice at this stage to press the \code{[)]} button to close the opening bracket that comes together with the \code{DotP(} function.
	\item Press \code{[EXE]} to calculate the result.
\end{enumerate}

\subsection{Cross Product}

Cross product calculations are similar to dot products. To find the cross product between two vectors:

\begin{enumerate}
	\item In the vector section under \code{OPTN > MAT}, select \code{CrsP} \fthree.
	\item Press \code{Vct}, then press the corresponding letter that represents the first vector in your cross product expression.
	\item Press the \code{[,]} button, then repeat step 2 but for the second vector in your cross product expression. It is good practice at this stage to press the \code{[)]} button to close the opening bracket that comes together with the \code{CrossP(} function.
	\item Press \code{[EXE]} to calculate the result.
\end{enumerate}

It is important to note here that the \code{[$\times$]} button on your calculator will not work as a cross or dot product operator! Should you attempt to use it as such, your GC will return a \code{Dimension ERROR}.

\subsection{Angle Between Two Vectors}

Your GC is also capable of finding the angle between two vectors. To do so:

\begin{enumerate}
	\item In the vector section under \code{OPTN > MAT}, select \code{Angle} \ffour.
	\item Press \code{Vct}, then press the corresponding letter that represents the first vector.
	\item Press the \code{[,]} button, then repeat step 2 but for the second vector. It is good practice at this stage to press the \code{[)]} button to close the opening bracket that comes together with the \code{Angle(} function.
	\item Press \code{[EXE]} to calculate the result. Note that the angle calculated can be in radians, degrees, or gradians depending on your settings at the moment. Refer to Section \ref{sec:angleunits} if you are not sure how to change the units.
\end{enumerate}

\subsection{Unit Vectors}

If you ever need to find the unit vector of a particular vector, you can do so directly with your GC. To do so:

\begin{enumerate}
	\item In the vector section under \code{OPTN > MAT}, select \code{UntV} \ffive.
	\item Press \code{Vct}, then press the corresponding letter that represents your vector. It is good practice at this stage to press the \code{[)]} button to close the opening bracket that comes together with the \code{UnitV(} function.
	\item Press \code{[EXE]} to calculate the result.
\end{enumerate}

\section{Problems involving Vectors}
\subsection{Finding the line of intersection between 2 or more planes}
Let's say you are given 2 planes:

\begin{equation*}
	\pi_{1}: \textbf{r} \cdot \colvec{3}{3}{1}{5} = 4 \hspace{5mm} \text{ and } \hspace{5mm} \pi_{2}: \textbf{r} \cdot \colvec{3}{5}{1}{3} = 2
\end{equation*}

First, convert them to linear equations:
\begin{equation*}
\syslineskipcoeff{1.2}
\systeme{
	\hspace{0.2cm} 3x+y+5z=4,
	\hspace{0.2cm} 5x+y+3z=2
}
\end{equation*}

Then solve for the general solution as described in Section \ref{sec:usingMatrices} (Using Matrices to Solve Multi-variable Linear System):
\begin{equation*}
\syslineskipcoeff{1.2}
\systeme{
	\hspace{0.2cm} x=t-1,
	\hspace{0.2cm} y=-8t+7,
	\hspace{0.2cm} z=t
}\hspace{5mm} \text{where } t \in \mathbb{R}
\end{equation*}

Separating out the $t$, we realize that the solution (the line of intersection) can be written as such:
\begin{equation*}
\colvec{3}{x}{y}{z} = \textbf{r} = \colvec{3}{1}{-8}{1}t + \colvec{3}{-1}{7}{0} \hspace{5mm} t \in \mathbb{R}
\end{equation*}

Similarly, you can expand this method to find the point of intersection (unique solution).

\chapter{Statistics}
One major use of a graphing calculator is for use in statistics. In the following chapters, we will outline the methods with which we can use our GC. Calculator functions in this section can generally be found under \code{[OPTN] > [STAT]}. Permutation and Combinations will not be covered. Calculated variables can be found under \code{[VARS] > [STAT]}

In this chapter, all random variables are represented by capital letters (usually $X$ or $Y$). Small letters are reserved to represent values (e.g. $x$).

\note{However, please do not use $Z$, as it is reserved for the standard normal distribution.}

\section{Discrete Random Variable}
A discrete (countable) random variable $X \in \mathbb{Z}^*$ has expectation (or expected value or mean) $\mu$
\begin{equation}
	\mathrm{E}(X)=\mu=\sum_{\mathrm{all}~x}^{}x\mathrm{P}(X=x)
\end{equation}
(You can think of this as the weighted sum of all the possibilities for $X$)

and variance $\sigma^2=\mathrm{stddev}^2$
\begin{equation}
	\mathrm{Var}(X)=\sigma^2=\mathrm{E}(X-\mu)^2=\mathrm{E}(X^2)-\mu^2
\end{equation}
\note{The above does not apply to continuous random variables.}

The function that gives the probability that a discrete random variable is exactly equal to some value is called the \textit{Probability Mass Function} (PMF). However, we will write PDF throughout this section instead, so as to be in-line with the curriculum/ calculator functions.

\subsection{Using Data}
If given a set of histogram data (i.e. categories and its corresponding frequencies), one can calculate statistical properties of it.

For example, given the following data:
$$
\setlength\tabulinesep{2mm}
\begin{tabu}{ |c|c|c|c|c| }
	\hline
	x & 0 & 1 & 2 & 3 \\
	\hline
	\mathrm{P}(X=x)  & \frac{1}{8}  & \frac{3}{8}  & \frac{3}{8} &\frac{1}{8}  \\
	\hline
\end{tabu}
$$

You can do 1-Variable Statistical calculations by:
\begin{enumerate}
	\item Go into \code{STAT} and then enter the X-values into \code{List 1} and its frequency into \code{List 2}
	\item Go to \code{CALC > SET} and adjust the settings accordingly for 1-Var (\code{XList:List1, Freq:List2})
	\item \code{[EXIT]} and then choose \code{1VAR}
\end{enumerate}

If you want to further manipulate these calculated values (such as squaring $\sigma$ to find variance), you can go to \runmat and then \code{[VARS] > [STAT] > [X]} to finding the value(s) you wanted.

Let's do a simple example to illustrate how to do this:

\example{Expressway accidents}

Over a period of 120 days, the number of serious accidents in a day along a certain expressway are recorded as follows:

\begin{center}
	\renewcommand*{\arraystretch}{1.2}
	\begin{tabular}{|C{0.5cm}|C{0.5cm}|C{0.5cm}|C{0.5cm}|C{0.5cm}|C{0.5cm}|C{0.5cm}|c|}
		\hline
		0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 or more \\
		\hline
		21 & 36 & 32 & 18 & 9 & 3 & 1 & 0  \\
		\hline
	\end{tabular}
\end{center}

where the \nth{1} row is the number of serious accidents in a day, and the \nth{2} is the number of days that number of serious accidents was recorded on.

To find the mean and variance of this dataset:
\begin{enumerate}
	\item Go to \code{STAT} and enter the data appropriately:
	\begin{figure}[h]
		\centering
		\includegraphics[width=0.5\textwidth]{expressway_accident_1}
	\end{figure}
	\item Go to \code{CALC > SET} and set the \code{1Var XList} as \code{List1} and \code{1Var Freq} as \code{List2}. You need not care about \code{2Var} for this example
	\item Press \code{[EXIT]} and then \code{1VAR} \Fone and you should get the following:
	\begin{figure}[h]
		\centering
		\includegraphics[width=0.5\textwidth]{expressway_accident_2}
	\end{figure}
	\item You now have the mean $\bar{x}$ and standard deviation $\sigma x$
	\item To find the variance of this data, go to \runmat and you will find $\sigma x$ under \code{VARS > STAT > X > $\sigma$x}. Enter that and then square it.
\end{enumerate}

You have now found that $\bar{x} = 1.7583$ and $\text{Var}(x)=1.7499$.

\begin{sidenote}
	Since the variance and the mean is about the same, we can thus conclude that a Poisson model may be valid for this data set.
\end{sidenote}

Refer to Section \ref{sec:plotstat} (Plotting Statistics/Visualization) for plotting statistical data.

\subsection{Binomial Distribution} \label{sec:binom}
A binomial random variable $X$ has the following characteristics:
\begin{enumerate}
	\item The experiment consists of $n$ repeated independent trials
	\item Each trial only has 2 outcomes: "success" or "failure"
	\item The probability of a `success' $p$ is constant in each trial
\end{enumerate}

% The probability distribution of $X$ is called the \textit{binomial distribution}, and
The probability $\textrm{P}(X = x)$ of obtaining $x$ successes in $n$ trials is given by:

\begin{equation}
	\mathrm{P}(X=x) = {n \choose x} p^x(1-p)^{n-x},~x \in \mathbb{Z}^*
\end{equation}

and has $\mathrm{E}(X) = np$ and $\mathrm{Var}(X)=np(1-p)$.

We write $X \sim \mathrm{B}(n, p)$.

\note{the probability is only non-zero when $0 \leq x \leq n$ (i.e. there is an upper bound).}

\subsubsection{Binomial PDF}

To obtain the probability $\textrm{P}(X = x)$, we can either use the formula, or use the in-built \code{\addtoindex{BinomialPD}} function:
\begin{center}
	\code{BinomialPD([X],$n$,$p$)}
\end{center}

When \code{X} is not provided, the output answer will be a \code{List}.

Alternatively, we can use the \code{STAT} app to obtain the probability:
\begin{enumerate}
	\item Go into \code{STAT} (\code{2} in the menu)
	\item Press \code{DIST}\Ffive\code{ > BINM}\Ffive\code{ > Bpd}\Fone
	\item Set the following:
	\begin{center}
		\setlength{\tabcolsep}{10pt}
		\renewcommand{\arraystretch}{1.1}
		\begin{tabular}{|l|l|}
			\hline
			Data		& Variable \\
			\hline
			$x$			& X \\
			\hline
			Numtrial	& $n$ \\
			\hline
			$p$			& $p$ \\
			\hline
			Save Res	& \code{None} \\
			\hline
		\end{tabular}
	\end{center}
	\item Press \code{[EXE]} or scroll to \code{Execute} and press \code{CALC}\Fone
	\item You can do further manipulation of the value obtained by:
	\begin{enumerate}
		\item Going to \runmat
		\item Go to \code{[VARS] > STAT}\Fthree\code{> RESLT}\Fsix\code{> DIST}\Fthree
		\item There you can find the $p$ value by pressing $p$ \Fone and then \code{[EXE]}
	\end{enumerate}
\end{enumerate}

\subsubsection{Binomial CDF}

To obtain the probability $\textrm{P}(X \leq x)$ (\textit{cumulative distribution function} of $x$), we can use the in-built \code{\addtoindex{BinomialCD}} function:

\begin{center}
	\code{BinomialCD([X],$n$,$p$)}
\end{center}

Similarly, if \code{X} is not provided, the output answer will be a \code{List}.

Alternatively, following instructions in the previous section (Section \ref{sec:binom} $\Rightarrow$ Binomial PDF), and choosing \code{Bcd} instead.

As a general rule of thumb:
\begin{center}
	\setlength{\tabcolsep}{10pt}
	\renewcommand{\arraystretch}{1.1}
	\begin{tabular}{|c|c|}
		\hline
		Answer in:		& Use: \\
		\hline
		$\mathbb{Z}$	& Table \\
		\hline
		$\mathbb{R}$	& Graph \\
		\hline
	\end{tabular}
\end{center}

Refer to Section \ref{sec:plottable} for plotting results from a table, which might be useful for plotting the PDF/CDF of a binomial distribution, since $\mathrm{P}(X=x)$ is undefined when $x \notin \mathbb{Z}^*$

\subsection{Poisson Distribution} \label{sec:poisson}
A random variable that follows a Poisson distribution has the following characteristics:
\begin{itemize}
	\item Events occur randomly in a fixed interval and independently of one another.
	\item The mean rate of occurrence of the event is \textbf{constant} in the given interval.
	\item The probability of more than 1 event occuring within a short interval is \textbf{negligible}.
\end{itemize}

The probability $\textrm{P}(X = x)$ of obtaining $x$ successes in a fixed interval is given by:
\begin{equation}
	\textrm{P}(X=x)=e^{-\pilambdaup}\frac{\pilambdaup^x}{x!},~x \in \mathbb{Z}^*
\end{equation}

We write $X \sim \textrm{Po}(\pilambdaup)$, where $\pilambdaup$ is the mean number of occurrence of the event in that fixed interval.

This random variable $X$ has $\mathrm{E}(X)=\mathrm{Var}(X)=\pilambdaup$.

\note{}
\begin{itemize}
	\item $X$ ranges over an infinite number of integer values (i.e. there is no upper bound)
	\item $\pilambdaup \propto t$, where $t$ is the length of the interval
\end{itemize}

\note{}
\begin{center}
	\setlength{\tabcolsep}{10pt}
	\renewcommand{\arraystretch}{1.1}
	\begin{tabular}{|c|c|}
		\hline
		$\pilambdaup \in \mathbb{Z}$					& 2 modes\\
		\hline
		$\pilambdaup \in \mathbb{R} \notin \mathbb{Z}$	& 1 mode\\
		\hline
	\end{tabular}
\end{center}

\subsubsection{Poisson PDF}
To obtain the probability $\textrm{P}(X = x)$, we can either use the formula, or use the in-built \code{\addtoindex{PoissonPD}} function:
\begin{center}
	\code{PoissonPD(x,$\pilambdaup$)}
\end{center}

Alternatively, we can use the \code{STAT} app to obtain the probability:
\begin{enumerate}
	\item Go into \code{STAT} (\code{2} in the menu)
	\item Press \code{DIST}\Ffive\code{ > POISN}(\code{$\triangleright$ F1})\code{ > Ppd}\Fone
	\item Set the following:
	\begin{center}
		\setlength{\tabcolsep}{10pt}
		\renewcommand{\arraystretch}{1.2}
		\begin{tabular}{|l|l|}
			\hline
			Data		& Variable \\
			\hline
			$x$			& X \\
			\hline
			$\mu$		& $\pilambdaup$ \\
			\hline
			Save Res	& \code{None} \\
			\hline
		\end{tabular}
	\end{center}
	\item Press \code{[EXE]} or scroll to \code{Execute} and press \code{CALC}\Fone
	\item You can do further manipulation of the value obtained by:
	\begin{enumerate}
		\item Going to \runmat
		\item Go to \code{[VARS] > STAT}\Fthree\code{> RESLT}\Fsix\code{> DIST}\Fthree
		\item There you can find the $p$ value by pressing $p$ \Fone and then \code{[EXE]}
	\end{enumerate}
\end{enumerate}

\subsubsection{Poisson CDF}
The cumulative probability $\textrm{P}(X \leq x)$ can be calculated by using the in-built \code{\addtoindex{PoissonCD}} function:
\begin{center}
	\code{PoissonCD(x,$\pilambdaup$)}
\end{center}

Alternatively, following instructions in the previous section (Section \ref{sec:poisson} $\Rightarrow$ Poisson PDF), and choosing \code{Pcd} instead.

\subsubsection{Additive Property of Poisson Random Variable}
If $X \sim \textrm{Po}(\pilambdaup)$ and $Y \sim \textrm{Po}(\mu)$, where $X$ and $Y$ are \textbf{independent}, then:
\begin{equation}
	X+Y \sim \textrm{Po}(\pilambdaup + \mu)
\end{equation}

\section{Continuous Random Variable}
The probability for a continuous variable $X$ to fall within a particular region $[a,b]$ is given by:
\begin{equation}
	\mathrm{P}(a \leq X \leq b) = \int_{a}^{b} f(x)
\end{equation}
where $f(x)$ is the \textit{probability density function} (PDF) of X.

In particular,
\[
\int_{-\infty}^{\infty}f(x) = 1
\]

Moreover,
\begin{align*}
	\mathrm{P}(a \leq X \leq b) &= \mathrm{P}(a \leq X < b)\\
	&= \mathrm{P}(a < X \leq b) \\
	&= \mathrm{P}(a < X < b)
\end{align*}

\subsection{Normal Distribution}
A (continuous) random variable $X\in \mathbb{R}$ that follows a normal distribution with mean $\mu$ and standard deviation $\sigma$ has a \textit{probability density function} (PDF) given by:

\begin{equation}
	f(x)=\frac{1}{\sigma\sqrt{2\pi}} \cdot e^{\frac{-(x-\mu)^2}{2\sigma^2}}
\end{equation}

We write $X \sim \mathrm{N} (\mu,\sigma^2)$

\note{$Z$ is reserved to represent the standard normal distribution. Do not use it to represent your variables (that do not follow standard normal distribution).}

\subsubsection{Normal Distribution PDF}
There are one of 2 ways to plot a graph of the normal distribution PDF:

\begin{itemize}
	\item Plot the actual equation
	\item Use the in-built \code{NormPD} function
\end{itemize}

However, it must be noted that the \code{NormPD} plots slower than using the actual equation. Using \code{G-Solv} is also slower.

The usage of \code{\addtoindex{NormPD}} is
\begin{center}
	\code{NormPD(X,[$\sigma$,$\mu$])}
\end{center}

In this case, \code{X} can be either a single value, or a \code{List}. The corresponding $p$-value will also be adjusted accordingly.

If $\sigma$ and $\mu$ are not provided, the standard normal distribution with $\sigma=1$ and $\mu=0$ is assumed.

\note{You should not use this command to calculate the probability of a certain random variable $\textrm{P}(X = x)$ where $x \in \mathbb{R}$. This is because for a continuous random variable, this does not make sense. It should always be a range. (i.e. use the CDF in the next section)}

\subsubsection{Normal Distribution CDF}
CDF stands for \textit{Cumulative Distribution Function}. This can be calculated by taking the integral of the normal PDF from $-\infty$ to $x$. One can take integral by plotting the graph out (refer to previous section), and then \code{G-Solv > $\int$dx}.

Alternatively, you can use the built-in \code{\addtoindex{NormCD}}:
\begin{center}
	\code{NormCD(<Lower>,<Upper>,[$\sigma$,$\mu$])}
\end{center}

If $\sigma$ and $\mu$ are not provided, the standard normal distribution with $\sigma=1$ and $\mu=0$ is assumed.

\begin{sidenote}
	You might realize that the value given by the calculator differs from that given by its Texas Instrument counterpart. This is no error as both calculators probably uses slightly different methods of calculating the probability.

	As a yardstick, we have compared the answers given by both calculators to that given by WolframAlpha, and it seems that the Casio calculator gives a more accurate value.
\end{sidenote}

To plot the Normal Distribution CDF, you can use:
\begin{center}
	\code{Y = NormCD(-1E99,X,[$\sigma$,$\mu$])}
\end{center}

\note{\code{-1E99} is to simulate $-\infty$.}

Alternatively, we can use the \code{STAT} app to obtain the probability:
\begin{enumerate}
	\item Go into \code{STAT} (\code{2} in the menu)
	\item Press \code{DIST}\Ffive\code{> NORM}\Fone\code{> Ncd}\fone
	\item Set the following:
	\begin{center}
		\setlength{\tabcolsep}{10pt}
		\renewcommand{\arraystretch}{1.2}
		\begin{tabular}{|l|l|}
			\hline
			Data		& Variable \\
			\hline
			Lower		& \textit{Lower} \\
			\hline
			Upper		& \textit{Upper} \\
			\hline
			$\sigma$	& $\sigma$ \\
			\hline
			$\mu$		& $\mu$ \\
			\hline
			Save Res	& \code{None} \\
			\hline
		\end{tabular}
	\end{center}
	\item Press \code{[EXE]} or scroll to \code{Execute} and press \code{CALC}\Fone
	\item You can do further manipulation of the value obtained by:
	\begin{enumerate}
		\item Going to \runmat
		\item Go to \code{[VARS] > STAT}\Fthree \code{> RESLT}\Fsix\code{> DIST}\Fthree
		\item There you can find the $p$ value by pressing $p$ \Fone and then \code{[EXE]}
	\end{enumerate}
\end{enumerate}
\note{You cannot use this method for plotting}

\subsubsection{Finding the value given the probability}
One sometimes need to find $a$ given $\textrm{P}(X < a) = b$ where $a,b \in \mathbb{R}$ and $b$ is the probability of $X$ being less than $a$.

To do this, we need the \code{\addtoindex{InvNormCD}} function built into the calculator. The usage of \code{InvNormCD} is as follows:
\begin{center}
	\code{InvNormCD($b$,[$\sigma$,$\mu$])}
\end{center}

This will give you back $a$.

\section{Hypothesis Testing}
The calculator has in built apps for hypothesis testing. In the H2 Math syllabus, we are mainly interested in the Z-test and t-test, both of which are included as apps in the calculator.

\subsection{Z-test}
To do a Z-test:

\begin{enumerate}
	\item Go into \code{STAT} (\code{2} in the menu)
	\item Press \code{TEST} \Fthree \code{> Z} \Fone \code{> 1-s} \Fone
	\item At the row labelled \code{Data}, ensure that it is set to \code{Variable} aka \code{Var} \Ftwo.
	\item Select the type of test to be conducted, i.e. if $\mu \neq \mu_0$ \Fone, $\mu < \mu_0$ \Ftwo, or $\mu > \mu_0$ \Fthree.
	\item Enter the value of $\mu_0$, the mean of the population that is under $H_0$ to be rejected or not rejected.
	\item Enter $\sigma$, the standard deviation of the population.
	\item Enter $\bar{x}$, the mean of the sample.
	\item Enter $n$, the number of samples taken.
	\item Go to the row labelled \code{Execute}, and press \code{EXE}. A page with the $Z$-value and the $p$-value displayed accordingly.
	%TODO: Screenshot
\end{enumerate}

Alternatively, with a set of data entered in the \code{STAT}

\section{Use for Experimental Data/SPA}
The calculator can be used to determine the equation of a best fit line/parabola etc. from a set of data from experiments. From the main menu, enter the \code{S-SHT} app (\code{4}).

In the app, simply enter each set of data into each row. Enter the data on the same axis under the same column.

For example, consider the following experimental data for an experiment involving electrical current ($I$) and potential difference ($V$):

\begin{center}
	\setlength{\tabcolsep}{10pt}
	\renewcommand{\arraystretch}{1.2}
	\begin{tabular}{|c|c|}
		\hline
		\textbf{V/V}	& \textbf{I/A} \\
		\hline
		0.7148			& 0.0588 \\
		\hline
		0.7372			& 0.0633 \\
		\hline
		0.7780			& 0.0752 \\
		\hline
		1.058			& 0.143 \\
		\hline
		1.200			& 0.170 \\
		\hline
		1.340			& 0.210 \\
		\hline
	\end{tabular}
\end{center}

Enter this set of data into the GC as follows:

\begin{center}
	\setlength{\tabcolsep}{10pt}
	\renewcommand{\arraystretch}{1.2}
	\begin{tabular}{|r|c|c|}
		\hline
		{\tiny SHEET}& \textbf{A}	& \textbf{B} \\
		\hline
		\textbf{1}	& 0.7148		& 0.0588 \\
		\hline
		\textbf{2}	& 0.7372		& 0.0633 \\
		\hline
		\textbf{3}	& 0.7780		& 0.0752 \\
		\hline
		\textbf{4}	& 1.058			& 0.143 \\
		\hline
		\textbf{5}	& 1.200			& 0.170 \\
		\hline
		\textbf{6}	& 1.340			& 0.210 \\
		\hline
	\end{tabular}
\end{center}

To plot the points onto a graph, first press the right arrow key ($\triangleright$, \code{F6}) and select the \code{GRPH} option \Fone.

Once in the \code{GRPH} menu, we will first configure the graph options.
\begin{enumerate}
	\item Press \code{SET} \Fsix and ensure that \code{StatGraph1} is shown on the first line and the \code{Graph Type} is \code{Scatter}.
	\item Move to \code{XCellRange} and enter \code{B1:B6}. This means that the values from cells \code{B1} to \code{B6} inclusive are that for the horizontal $x$-axis.
	\item Move to \code{YCellRange} and enter \code{A1:A6}.
	\item Finally, ensure that the \code{Frequency} option is \code{1}.
	\begin{itemize}
		\item You may select any \code{Mark Type} that suits your personal preferences.
	\end{itemize}
	\item Press \code{EXIT} to leave the configuration menu and return to the spreadsheet.
\end{enumerate}

Now, press \code{GPH1} \Fone. A graph with markings corresponding to the points on the spreadsheet should be yield.

You calculator can find the equation of a best fit line or curve. In this case, the data is expected to be linearly related (and it is linearly related).

\begin{enumerate}
	\item Press \code{CALC} \Fone.
	\item There are now a number of options corresponding to different types of graphs and relationships such as $x^2$, $\ln$, and $e^x$. In this case, our data is linear, so select \code{X} \Ftwo.
	\item Select $\code{ax+b}$ \Fone.
	\item A table with various values is yield. The value $a$ corresponds to the gradient, and $b$ is the $y$-intercept. $r^2$ represents how closely the data fit to the line, with the value of $1$ corresponding to a perfect, ideal fit.
	\item To view the graph visually, select \code{DRAW} \Fsix. To generate $y$-values using the equation, select \code{COPY} \Ffive, and select one of the \code{Y1}/\code{Y2\dots} to copy to.
\end{enumerate}

\note{You will need to re-enter the formula before graphing/using the table, or it will cause a condition error. This re-entering could simply be going to the function in \code{Table}, pressing the right arrow and then pressing \code{[EXE]}.}

The linear regression result can also be obtained using the concept of best approximations, covered in Section \ref{sec:bestapprox} under Linear Algebra.

\subsection{Plotting Statistics/Visualization} \label{sec:plotstat}
In this section, we would explore ways we can use the calculator to help us visualize statistics, just like how it would appear in our lecture notes. The steps here are purely provided as an example, and to expose you to these functions, and you should adapt accordingly for your own use.

\subsubsection{Binomial/Poisson Distribution}
To visualize a binomial distribution, let's first generate a list of values for a certain binomial distribution. For example, let's say that $X \sim \text{B}(50, \frac{1}{3})$:

We can generate a list of probabilities easily in \runmat:

\begin{center}
	\code{BinomialPD(50,$\mathtt{\frac{1}{3}}$) $\mathtt{\rightarrow}$ List 1}
\end{center}

Thereafter, go into \code{STAT} and you'll see the probabilities all listed out for you in the \code{List 1}:

\begin{figure}[h]
	\centering
	\includegraphics[width=0.5\textwidth]{binom50}
\end{figure}

We can then easily graph this result:
\begin{enumerate}
	\item Go to \code{GRPH} \Fone \code{>} \code{SET} \fsix
	\item Scroll to \code{Graph Type} and choose \code{Bar} ($\triangleright$ \code{>} \code{F3})
	\item Select:
	\begin{tabular}{| l | l |}
		\hline
		\code{Data1} 		& \code{List1} \\
		\hline
		\code{Stick Type} 	& \code{Length} \\
		\hline
	\end{tabular}
	\item Press \code{EXIT} and then \code{GPH1} \fone
\end{enumerate}

The graph should have been plotted. You can scroll, zoom in, or out to see more:

\begin{figure}[h]
	\centering
	\includegraphics[width=0.5\textwidth]{binom50plot}
\end{figure}

This should look like those graphs they have in your lecture notes.

\note{the x-coordinate of 1 corresponds to $\text{P}(X=0)$}

A similar procedure can be followed to plot a graph of a variable that follows a Poisson distribution.

\chapter{Linear Algebra} \label{chap:linalge}
Some of you might find yourself doing linear algebra, and needing to do matrix manipulations. In this chapter, I will outline some basic concepts covered in MA1101R (NUS H3 Course), and how you can use your GC to find the answer.

You may find certain concepts here useful for H2 Mathematics as well, especially in terms of matrix manipulations. I suggest you read this chapter as a complement of Chapter \ref{chap:vectors} (Vectors).

\section{Storing Matrices}
accessing individual matrix elements

\section{Solving Linear Systems} \label{sec:solvLinSys}
introduce augemented matrix
how to augment if 2

\subsection{Elementary Row Operations and Row-Echelon Forms}
row equiv

\section{Best Approximations} \label{sec:bestapprox}

\cleardoublepage
% \addcontentsline{toc}{chapter}{Index}
\printindex

\end{document}


\section{Hyperparameters}
\label{chp:future_work:sec:hyperparameters}
Finding optimal hyperparameters for a model is a challenging task and can limit a model's performance \parencite{Bergstra:2011,Zeiler:2012}.
In the following two subsections we want to show two enhancements for future research which can lead to better performing algorithms.

\subsection{Re-Sampling Strategy}
\label{chp:future_work:sec:hyperparameters:re_sampling_strategy}
The datasets we used are very imbalanced.
Only about a fifth of their datapoints are labeled as vague.
Therefore, in the grid-search, we considered two re-sampling strategies, namely random up-sampling and random down-sampling.
Those techniques take into account a dataset's imbalance by randomly duplicating entries of the minority class or discarding samples of the majority class.

However, more sophisticated re-sampling techniques exist.
One example is \ac{SMOTE} \parencite{Chawla:2002}.
Instead of randomly duplicating entries of the minority class, \ac{SMOTE} generates new samples of the minority class which are "close" to the other datapoints.
For an extensive explanation of \ac{SMOTE} we refer to the original paper of \textcite{Chawla:2002} instead.

With this technique and other more complex ones \parencite{Li:2008} the corresponding authors were able to enhance the performance gain of their models significantly.
Therefore, future studies should consider more advanced re-sampling strategies and examine their impact on the learning phase of a model.

\subsection{Search Technique}
\label{chp:future_work:sec:hyperparameters:search_technique}
Hyperparameters can be obtained by different techniques.
In the study we use a basic grid-search.
According to \textcite{Bergstra:2012} not all hyperparameters influence a model's performance equally and therefore grid-search is a poor choice.
Recent research has proposed different alternatives for a simple grid-search, for example \textit{random search} \parencite{Bergstra:2012}.
Instead of defining a hyperparameter grid and using the best performing hyperparameter combination, with random search one randomly picks hyperparameters from a predefined range.

Since the used hyperparameters directly impact a model's performance \parencite{Claesen:2015}, future research should consider the usage of more advanced hyperparameter search techniques such as random search.


% !TEX root =  manual.tex
\section{Emulator Tuning}\label{sec:emulatortuning}

As part of training the emulator, \path{madai_train_emulator} determines the hyper-parameters ($\Theta_k$ in Eq. \eqref{eq:hyperform}) to be used by the emulator. In many cases, these parameters are simply chosen \emph{ad hoc}, but \path{madai_train_emulator} initializes them to reasonable values. To train the emulator, run the command

\commandline{madai\_train\_emulator stat1}

When training the emulator, \path{madai_train_emulator} looks for parameters defined in a file named\\ \path{stat1/settings.dat}, which is a text file describing parameters used in the emulator construction and tuning and for the MCMC procedure. The file has a simple form,

\begin{quote}
{\tt MCMC\_USE\_MODEL\_ERROR             false}\\
{\tt PCA\_FRACTION\_RESOLVING\_POWER     0.99}\\
{\tt MCMC\_NUMBER\_OF\_BURN\_IN\_SAMPLES 100000}\\
{\tt SAMPLER\_NUMBER\_OF\_SAMPLES           1000000}\\
{\tt MCMC\_STEP\_SIZE                    0.1}
\end{quote}

\path{madai_train_emulator} produces a file called \path{stat1/EmulatorState.dat}. This file has the following format:
\begin{quote}
{\tt SUBMODELS}~$M_Z$~~~$\leftarrow$Each principal component is modeled separately.\\
{\tt MODEL~~~0}~~~~~~~~~$\leftarrow$ The submodels are numbered zero through $M_z-1$.\\
{\tt COVARIANCE\_FUNCTION} {\it SQUARE\_EXPONENTIAL\_FUNCTION}\\
$\uparrow$ This describes the  functional form assumed by the GPE for the covariance.\\
The choice determines what hyper-parameters mean.\\
{\tt REGRESSION\_ORDER }~~ $\leftarrow$ Order of polynomial to fit to the model outputs\\
{\tt THETAS}~~~~~$\leftarrow$ Hyper-parameter values for this submodel\\
$N_\Theta$~~~~~~~~~~$\leftarrow$ This is the number of hyper-parameters\\
$\Theta_1$\\
$\Theta_2$\\
$\vdots$\\
$\Theta_{N_\Theta}$\\
{\tt END\_OF\_MODEL}\\
{\tt MODEL~~1}\\
$\vdots$\\
{\tt END\_OF\_MODEL}\\
{\tt MODEL}~~~{$M_z-1$}\\
$\vdots$\\
{\tt END\_OF\_MODEL}\\
{\tt END\_OF\_FILE}
\end{quote}\vspace*{-8pt}

The $\Theta_i$ values can be modified in these files to tune the emulator.

There are several supported choices for the \variable{COVARIANCE\_FUNCTION}. See section \ref{sec:CovarianceFunctions}.


\section{Project Description}
\label{section:description}

The main contribution of this work should be to evaluate the boundaries of conventional machine learning approaches for hate speech detection. This includes manual feature extraction and subsequent text classification of doc\-u\-ments into hate speech and non-hate speech as opposed to modern deep learning approaches. Part of this work is also to find out which features and classifiers are suitable for such a classification task. The results should show which features work best for which classifier as well as which problems can be addressed with conventional machine learning methods and which not. A comparison to modern deep learning approaches should be drawn using the metrics of simple accuracy as well as precision and recall, respectively the F1-score.

\begin{equation}
Accuracy = \frac{TP + TN}{TP + FP + TN + FN}
\end{equation}

\begin{equation}
Precision = \frac{TP}{TP + FP}
\end{equation}

\begin{equation}
Recall = \frac{TP}{TP + FN}
\end{equation}

\begin{equation}
F1-score = 2 \cdot \frac{Precision \cdot Recall}{Precision + Recall}
\end{equation}

The accuracy is used to measure how good a classifier can detect hate speech with the appropriate features while the F1-Score is used to evaluate how error-prone the chosen machine learning approach is. The F1-score is especially important as both used data sets are not class-balanced. As both data sets are annotated an automatic evaluation is possible. As a baseline, results of the mentioned papers as well as from papers documented in GitHub will be chosen.

As stated above, the two data sets from \cite{ThomasDavidson.2020} and \cite{OnadeGibert.2020} will be used for this project. One possible problem could be that the amount of documents classified as pure hate speech in \cite{ThomasDavidson.2020} might not be enough to create profound classifiers. In this case one has to evaluate whether hate speech data from \cite{OnadeGibert.2020} is enough to achieve valid results or whether documents classified as offensive language from \cite{ThomasDavidson.2020} should be used as hate speech data as well.

In \autoref{fig:pipeline} a schema of the project pipeline is shown. After having harmonized and consolidated the data sets into a common processable corpus one has to figure out which feature representations are commonly used in the area of hate speech detection and which classifiers are to be evaluated. This informationen will be based on the future lecture progress and further readings of the already introduced papers. The distribution of tasks can be done by feature-classifier combinations. In this sense the project can also be scaled without additional planning effort.

\vspace{12pt}
To summarize the scope of the project the following subgoals were iden\-ti\-fied:

\begin{itemize}
	\item Prepare the data sets.
	\item Identify suitable feature representations and transform the data ac\-cord\-ingly.
	\item Identify and train machine learning classifiers.
	\item Combine classifiers with different feature representations.
	\item Evalute and compare the performance using accuracy, precision, recall and F1-score.
	\item Show the boundaries of conventional machine learning approaches in comparison to deep learning approaches.
\end{itemize}

The results of the project can contribute to offer an easier way to detect hate speech without having to train deep neural networks. It furthermore gives a more holistic view on different approaches to handle hate speech detection with conventional machine learning and text analytics methods and last but not least helps to fight hate speech on social media platforms.

\begin{figure}[t]
	\centering
	\includegraphics[width=1.0\textwidth]{./pipeline.png}
	\caption{Text Analytics Pipeline}
	\label{fig:pipeline}
\end{figure}


\section{Characteristic functions}


\documentclass{amsart}

\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usepackage{tikz-cd}

\newtheorem{defn}{Definition}
\newtheorem{prop}{Proposition}

\DeclareMathOperator{\im}{Im}

\title{Characteristic Structure}
\date{\today}
\author{P. A. Brooksbank}
\author{J. F. Maglione}
\author{E. A. O'Brien}
\author{J. B. Wilson}

\begin{document}

\begin{abstract}
    New Zealand was unable to keep COVID going, and Germany has taken way too
    long to get start. In the US the power of positive thinking has kept us number one
    in COVID almost from the start.
\end{abstract}
\maketitle

\section{Introduction}

We are after methods to find characteristic subgroups of groups, and later rings and
algebras, but without the apriori assumption that we know about the automorphisms.
This raises some immediate questions about how one validates the return.  A
second concern is that we want lots of these subgroups, enough that we can
confine the possible automorphism and isomorphism problems enough that we might
begin to solve for these. That calls for some level of control on how generate
such subgroups.  This note introduces a means to first describe characteristic
subobjects in a manner independent of automorphisms, and second to capture their
structure algebraically so it can be used efficiently.

In a category, the characteristic subobjects are the fixed points (amongst
subobjects) of automorphisms.  Sometimes these fixed points can be identified
independent of the action by the automorphism groups and this makes it possible
to begin to approximate the structure of the automorphism groups by first
computing a good number of fixed points, i.e. a good number of characteristic
subobjects. For this and many reasons it is becomes natural to consider
algorithms that search out characteristic subobjects and do so in large, but
controlled, quantities.  To this end we introduce an algebra whose elements
index characteristic subobjects of a fixed object.

Some characteristic subobjects are more desireable than others.  For most of our
applications we wont have automorphisms at the ready so we will want instead
functions $G\mapsto F(G)$ that apply to any object $G$ in a fixed category
$\mathsf{C}$ and return a characteristic subobject $F(G)$.  For instance, a
commutator subgroup is characteristic in any group. This leads us in a natural
way to regard the desired characteristic subobjects as the images of various
functors $F:\mathsf{C}\to \mathsf{C}$ (images of functors are automatically are
preserved by automorphisms), but we shall also need that these be equipped with
natural transformations $\eta_G:F(G)\to G$ whose image is the actual
characteristic subobject.   In categorical parlance we are seek what are known
as \emph{counits} $\eta:F\Rightarrow 1_{\mathsf{C}}$.  The categorically dual
concpet of a \emph{units} $1_{\mathcal{C}}\Rightarrow F$ leads to characteristic
quotients. So in categories of algebraic structures like groups and rings we can
equate these with their kernels and fund a host of further characteristic
subobjects. Recognizing these connections also links to a to a rich source of
characteristic subobjects: adjoint functor pairs $F\dashv G:\mathsf{C}\to \mathsf{D}$.
The perhaps unexpected aspect here is that this shows we should be consulting
with other categories $\mathsf{D}$ when hunting for new characteristic subobjects.

A further detail we must consider are means to compactly encode the subobjects
we aim to discover.  A helpful tool in this is to reflect the lattice structure
of characteristic subgroups into the functor abstraction.  We do so by creating
a monoid structure on these functors.  First the monoid can be specified
compactly using generators.  Second, the monoid offers an agile measn to tour
the characteristic subobjects by identifying them with random walks in the
monoid.  Thirdly, by computing relations for the monoid we develop an
isomorphism invariant.  The relations can also let us prune randome walks so we
do not waste energy searching where we wont be profitable.  And foruthly, our
monoid rests inside a theoretically larger monoid, so we can at a later point
update the monoid by adding to its generating set.  In short, by abstracting
the problem into a functor category we gain a uniform description of the problem
and by attaching algebra to this description we are able to design better solutions
and apply them in general settings.

So to summarize the potential:
\begin{enumerate}
    \item  We can declare that our command has a fixed subcategory generated by
    some prescribed functors. Our algorithm takes as input your group and
    evaluates its associated diagram.  I.e. it outputs a bunch fo characterisitc
    subgroups but now we can explain what precisely those subgroups.  They are
    the ones given by counits in the above subcategory.

    \item The outputs are co-recursive. I.e. we can immediately return
    something, and leave the user to begin exploring the characterisitc
    subgroups as they like because these will be indexed by words in the
    generators of the above counit subcat.

    \item This is modular.  If you want to add a new strategy you are adding a
    new generator to the counit category.

    \item We might begin to add randomized strategies with meaningful
    interpretations, e.g. a random char could be modeled as a random walk in the
    above counit subcategory.

    \item This offers some chance for theory/rewriting.  We might be able to
    derive some generators as generated by others and other as independent and
    thus justify the order in which we might generate new chars.  If they are
    captured by previous words we likely can remove them as they don't tell us
    something new.

\end{enumerate}

\section{A cast of characteristics}

Our first description of characteristic subobjects $C$ of an object $A$
describes $C$ as invariant under automorphisms of $A$.   This is an internal
definition, referring only to $A$.   All this takes place in a category
$\mathsf{C}$.  So what we truly seek are functions $A\mapsto F(A)$ whose outputs
are characteristic subobjects of $A$.  In this way given later objects $B$,
these too admit their own characteristic subobjects $F(B)$ that can be compared
with $F(A)$, specifically for every isomorphism $f:A\to B$ we may assign an
appropriate restriction $F(f):F(A)\to F(B)$. This calls for a functor
$F:\mathsf{C}\to \mathsf{C}$.  The second implied concept is the ability to
return to $A$ from $F(A)$, i.e. to produce an actual subobject $C\hookrightarrow
A$ from $F(A)$.  This calls for functions $\epsilon_A:F(A)\to A$, that can be
defined in a manner that is uniform as we vary $A$.  Using the identity functor
$1_{\mathsf{C}}:\mathsf{C}\to \mathsf{C}$, this can be realized as the familiar
diagram of natural transformations $\epsilon:F\Rightarrow 1_{\mathsf{C}}$ between
the endo-functors $F$ and $1_{\mathsf{C}}$:
\begin{center}
    \begin{tikzcd}
        \mathsf{C}
            \arrow[r, bend right=-45, "F"name=F]
            \arrow[r, bend right=45, "1_{\mathsf{C}}"name=1]
         & \mathsf{C}
         %%% 2-cell
         \arrow[Rightarrow, from=F, to=1,"\epsilon"]
    \end{tikzcd}
    $\qquad \equiv\qquad \forall A.\forall B.\forall f:A\to B.\qquad$
    \begin{tikzcd}
        F(A) \arrow[d,"\epsilon_A"]\arrow[r,"F(f)"] & F(B) \arrow[d,"\epsilon_B"]\\
        A\arrow[r,"f"] & B
    \end{tikzcd}
\end{center}
An endo-functor $F:\mathsf{C}\to \mathsf{C}$ with a natural transformation
$\epsilon:F\to 1_{\mathsf{C}}$ is called a \emph{counit}.

Now let us attempt to reverse this generalization to see to what degree it may
miss some of our intended structures.  A few technical matters emerge at this
stage.  Most contexts we consider have an obvious substructures, e.g. subgroups
\& subalgebras.  By appealing to a functorial perspective we do better to
convert our thinking to a categorical definition.  For instance a kernel the
algebraic sense must be assumed to now to be in the categorical sense.  These
usually agree but naunces can emerge in some circumstances.  With modest
assumptions on $\mathsf{C}$ we arrive at the following partial reversal of the
above construction.

\begin{prop}
    If $\mathsf{C}$ has (categorical) images and $\epsilon:F\Rightarrow
    1_{\mathsf{C}}$ is a counit then
\begin{enumerate}
    \item the image $\im\eta_A$ is a subobject of $A$; and
    \item if $f:A\to A$ is an endomorphism then $\im\eta_A=\im\eta_{f(A)}$.
\end{enumerate}
\end{prop}

Witness that this concept matches the stronger concept of a \emph{fully invariant}
subobject because it concerns all endomorphisms rather than solely automorphisms.
Thus for example in the category of groups there is no counit that specifies the
center because centers are in general not fully invariant.  However, in the
commutator subgroup can be realized as a counit.  Specifically
\begin{align}
    F(G) & = [G,G] \\
    F(f:G\to H) & =f|_{[G,G]}:[G,G]\to [H,H] \\
    \eta_G &:[G,G]\hookrightarrow G & \eta_G(x)=x.
\end{align}
A simple option to include all characteristic subgroups we can limit the
category $\mathsf{C}$ to the isomorphism groupoid of $\mathsf{C}$. However a
more natural alternative is to consider a dual concept.  The dual of a counit is
a unit $\eta:1_{\mathsf{C}}\Rightarrow F$.  Here we may again capture a notion
of characteristic by appealing to kernels instead of images.

\begin{prop}
    If $\mathsf{C}$ has (categorial) kernels and $\eta:1_{\mathsf{C}}\Rightarrow
    F$ is a unit then
\begin{enumerate}
    \item the kernel $\ker\eta_A$ is a subobject of $A$; and
    \item if $f:A\to A$ is an endomorphism then $\ker \eta_A=\ker\eta_{f(A)}$.
\end{enumerate}
\end{prop}

Witness that centers (and all marginal subgroups) are (categorical) kernels.

For a categories $\mathsf{C}$ and $\mathsf{D}$, the category of functors
$\mathsf{D}\to \mathsf{C}$ we denote as $\mathsf{C}^{\mathsf{D}}$.  Its objects
are functors and its morphisms are natural transformations.  Now we are interested
in only those functors which a natural transformation to the identity functor.
So we are opperating within the \emph{slice} category $\mathsf{C}^{\mathsf{C}}/_1$
for counits, and $1\backslash \mathsf{C}^{\mathsf{C}}$ for units.  We shall give these
more intuitive names:
\begin{align}
    Char(\mathsf{C}) & = \mathsf{C}^{\mathsf{C}}/_1 &
    Cochar(\mathsf{C}) & = 1\backslash \mathsf{C}^{\mathsf{C}}.
\end{align}
Our objective is to define elements of these categories and investigate the
subcategories they generate.

\subsection{Operations}

In a group we know the characteristic subgroups form a lattice under joins and
intersections. As we shift to an abstracted point of view that is independent of
the automorphisms and even subsets we need to replace this structure with
operations between the many functors.  This all takes place inside the category
$Char(\mathsf{C})$ and we therefore want a standard categorical product on this
category.  This exists provided that $\mathsf{C}$ has a categorical product.
The diagram in the functor category is thus a pullback along the two counits
$F\Rightarrow 1\Leftarrow G$.  In the usual way such a product is associative.
If we have a zero in $\mathsf{C}$ then we furthermore have a product identity
so $Char(\mathsf{C})$ is a monoid.

\subsection{Wiskers and adjoints}

A common and diverse source of units and counits are adjoint functor pairs
$F\dashv G:\mathsf{C}\to \mathsf{D}$.  That is $1_{\mathsf{C}}\Rightarrow G\circ F$
and $F\circ G\Rightarrow 1_{\mathsf{D}}$.  This can be used to give a round-about
alternative proof that various subgroups are characteristic, but the real value is
to link with much effort to unused areas.

For instance, free-forgetful adjoint pairs recover the usual verbal and marginal
subgroups as characteristic subgroups.  We already know this but it may help to follow
such an example to make the idea clear.  Meanwhile another source of adjoint functor pairs
are induction-restriction functors.  Those are imposed on modules but can also be taken to
act regularly.

\section{Filters}

In some contexts it may be profitable to impose conditions that the cast of characteristic
functors we devise preserve algebraic structure.  For example, that it commute with
some operators.  In the category of rings a natural choice is the product, and in groups
it is the commutator that we consider.

\end{document}


\problemname{Balanced Cut}

Professor Anna van Lier is preparing to give a lecture on balanced binary search trees.
Recall that these are binary trees with two properties:
\begin{itemize}
\item \emph{Balanced tree:} For every node, the height of its left subtree and the height
of its right subtree differ by at most $1$.  For instance in
Figure~\ref{fig:avltree}, the left and right subtrees of node $7$ have
heights $2$ and $1$, respectively.  If a node does not have a left (or
right) subtree then that subtree is considered to have height $0$.
\item \emph{Search tree:} Each node has a value. The value of a node is greater than all the values
in the left subtree of the node, and smaller than all the values
in the right subtree of the node.  For instance in
Figure~\ref{fig:avltree}, the left subtree of node $7$ contains the
values $4$, $5$ and $6$ which are all smaller than $7$.
\end{itemize}

Anna got a picture of such a tree from a colleague.  This tree has $n$ nodes with the values $1$ to $n$.
However, it turns out to be too big to fit on her slides so she would like to make it smaller.
In particular, she would like to erase some nodes from the tree such
that it has exactly $k$ remaining nodes.
Whenever she erases a node, she also erases the subtrees of that node.
Of course, the resulting tree must still be a balanced binary search tree.

For pedagogical purposes, Anna would like the node values in her final
tree to be small.  Therefore, she wants the list of the $k$ remaining
node values to be the lexicographically smallest possible.  For
example she would prefer a tree containing values $2, 5, 9$ over a tree
containing values $2, 6, 7$.

As Anna is far too busy doing more important things, the task of
finding which nodes to erase falls upon one of her teaching assistants, i.e., you.

\begin{figure}[!h]
\begin{center}
\includegraphics[width=0.9\textwidth]{sample1}
\caption{Illustration of Sample Input 2 and its solution.}
\label{fig:avltree}
\end{center}
\vspace{-1cm}
\end{figure}

\section*{Input}

The input consists of:
\begin{itemize}
  \item One line with two integers $n$ and $k$ ($2 \leq n \leq 5 \cdot 10^{5}$, $1 \leq k \leq n - 1$), the
    number of nodes in the tree and the number of nodes to keep.
\item $n$ lines, the $i$th of which contains an integer $p_i$ ($1\leq p_i \leq n$ or
	$p_i = -1$), the parent of the node with value $i$ or $-1$ if the node with value $i$ is the root.
    % Each value from $1$ to $n$ (inclusive) occurs at most twice and $-1$ occurs exactly once.
\end{itemize}

It is guaranteed that the given tree is a balanced binary search tree.

\section*{Output}

Output a single line with a binary string of length $n$.
The $i$th character should be `\texttt{1}' if the node with value $i$ should be kept,
and `\texttt{0}' if it should be erased.