\section{Decimal and Binary Math}

The next few sections introduce some math ideas that may or may not be familiar to you. In order to really understand how computers work, you need to understand several math concepts that are not hard, but may be unfamiliar. The first concept is the \emph{exponent}.

\subsection*{Bases and Exponents}

Exponentiation is a mathematical operation, written as $b^n$, involving two numbers, the base, $b$, and the exponent, $n$. Exponentiation means ``repeated multiplication of the base."

\noindent That is, $b^n$ is the product of multiplying the base number $n$ times:

\begin{equation*}
b^{n}=\underbrace {b\times \cdots \times b} _{n}
\end{equation*}

\noindent In this case, $b^n$ is called the ``\emph{n-th} power of b", or ``b raised to the power n." So 3 to the 4\textsuperscript{th} power looks like this:

\begin{equation*}
3^4 ~=~ 3 \times 3 \times 3 \times 3 ~=~ 9 \times 9 ~=~  81
\end{equation*}

Put another way: the exponent is a number, smaller and on the upper right hand side of a number, that means ``multiplying a number times itself zero times, once, or more than once" depending on whether the number is 0, 1, 2, or another number (written $n$ in the description above). It is possible to use fractions as exponents, but we won't talk about that here.

The base can be any number, though most people think most easily in base-10. So in base-10, 10 to the power 2, or 10 to the second power, means $10 \times 10$.

\subsection*{Order of Magnitude (Columns)}

When counting up from zero, by one, in base 10, you eventually get to 9. In order to count any higher, you must ``carry the one" over to the next column and reset the counter in the ``ones" column (the place that counts by one, from zero to nine). When you move from the ``\emph{ones}'' column to the ``\emph{tens}'' column, the next column to the left represents the next \emph{order of magnitude} of the base. ``Magnitude" means ``size", and in math, it means, specifically, moving from counting by one number (the base) to counting by the base times itself -- first twice, then three times, then more. For base-10, you count from 0 to 9 in the right-most column, then from 10 to 90 in the next column to the left, then from 100 to 900 in the next column to the left, then from 1000 to 9000, and so on. Each time the counter gets full (reaches 9), you cannot represent any more of the quantity being counted without moving to the next largest order of magnitude. That is, if your display only shows two digits, once you count past 99, you have no idea is the number is 0, or 100, or 200, or 900, or ten thousand, or 4 billion.

\newpage
\subsection*{Squares}

Shapes that are squares have four sides with the same length; that is, the length and width are the same. \emph{Squaring a number} is multiplying the number times itself, just like, in a square, both sides have the same length. The most common way you will see a ``squared number" described is with a little 2 up above the number, like  $2^2$, or $3^2$, or $10^2$. That smaller `2' is the exponent, that we discussed above.

\medskip

Squaring the number 10 (that is, multiplying ten times itself) gets: $10 \times 10 = 100$

\bigskip

\begin{tabular}{l m{0.75in} l l }

\blockline{1}{0.5} & $1 \times 1 = $ & \blockline{1}{0.5} & $=1^2$ \\
\\
\blockline{2}{0.5} & $2 \times 2 = $ & \makeplate{2}{1}{0.5} & $=2^2$ \\
\\
\blockline{3}{0.5} & $3 \times 3 = $ & \makeplate{3}{1}{0.5} & $=3^2$\\
\\
\blockline{4}{0.5} & $4 \times 4 = $ & \makeplate{4}{1}{0.5} & $=4^2$ \\
\\
\blockline{5}{0.5} & $5 \times 5 = $ & \makeplate{5}{1}{0.5} & $=5^2$ \\
\\
\blockline{6}{0.5} & $6 \times 6 = $ & \makeplate{6}{1}{0.5} & $=6^2$ \\

\end{tabular}

\newpage

\subsection*{Cubes}

Cubes have the same length side, on each of six sides, in \emph{three} dimensions. When cubing a number, you are multiplying the number times itself, and then multiplying it times itself \emph{again}, because all three sides are the same (they have the same value). The most common way you will see a ``cubed number" described is with a little 3 up above the number, like  $2^3$, or $3^3$, or $10^3$. As above, the exponent tells you how many times you multiply the number times itself (here, that means three times).

\medskip

Cubing the number 10 gets: $10 \times 10 \times 10 = 1000$

\bigskip

\begin{tabular}{m{1.1in} m{1.0in} m{1.45in} m{1.9in}}

\blockline{1}{0.5} & $1 \times 1 \times 1 = $ & \blockline{1}{0.5} & One times itself is one.\\
\\
\blockline{2}{0.5} & $2 \times 2\times 2 = $ & \makeplate{2}{2}{0.5} & Two sets of four, or \newline$4+4$ (that is, $2^2 + 2^2$) \\
\\
\blockline{3}{0.5} & $3 \times 3 \times 3 = $ & \makeplate{3}{3}{0.5} & Three sets of nine, or \newline$9+9+9$\newline Put another way:\newline $9 \times 3 = 27$ \\
\\

\blockline{4}{0.5} & $4 \times 4 \times 4 = $ & \makeplate{4}{4}{0.5} & Cubes get big quickly---\newline Here's four sets of 16. \newline$16 \times 4 = 64$ \\
\\

\blockline{5}{0.5} & $5 \times 5 \times 5 = $ & \makeplate{5}{5}{0.5} & Five sets of 25. \newline$25 \times 5 = 125$ \\
\\

\end{tabular}

\newpage

\subsection*{Multipliers and Prefixes}

In systems of measurement, when talking about, say, weight, height, or pressure, there are base units and there are ways to refer to these base units in large multiples, or in tiny fractions. You're probably a little taller than one \emph{meter} in height. And it takes one hundred \emph{centimeters} to add up to one meter. The prefix ``centi-" means it takes one hundred of \emph{these} to add up to one of the \emph{base unit}, which in this case is a meter.

The same goes for weight. You probably weigh between 20 and 40 \emph{kilograms}. The prefix ``{kilo-}'' means \emph{one thousand} of whatever the base unit is. Put another way, grams are pretty small amounts of weight, so measuring things like people or cars is impractical if we use grams, because cars weigh millions of grams. Medicines, on the other hand,  are usually measured in quantities called \emph{milligrams} -- each milligram is only $\frac{1}{1000}$ (one one-thousandth) of a gram. Don't be confused into thinking ``milli-" means ``million'' --- ``mega" means ``million.''

When thinking about computers, we hear terms that are often expressed as multiples of things like memory and storage capacity. A kilobyte is 1,000 bytes (a \emph{byte} is 8 individual bits, and each bit is the smallest unit of computing -- it can only represent 1 or 0). A megabyte is 1,000 kilobytes (or, 1,000,000 bytes). A gigabyte is one \emph{billion} bytes, and a terabyte is one \emph{trillion} bytes.

\newpage
\subsection*{Representing Numbers in Decimal}

\emph{Decimal} means ``with tens". You've always been taught to count in the decimal system -- by ten. When you are counting by ones, once you get past 9, you reset the right-most number to zero and add that ten to the next column, which is the \emph{tens} column (so you only increment that counter by one, since you are adding \emph{one} ``ten'' to the total). Once you fill up 9 ``tens" (90) and count up past 9 in the ``ones'' column (that is, you add one to 99), you have to set the ones column and the tens column to zero, and add one to the ``hundreds'' column. You \emph{carry} the ten to the left from the ones, and carry the hundred to the left, to the next-largest set of tens. One hundred is ten tens, one thousand is 100 tens, and so forth.

\noindent It looks like this:
\bigskip

\begin{tabular}{l l l l l | l r }
\rot{ten thousands} & \rot{thousands} & \rot{hundreds} & \rot{tens} & \rot{ones} & \multicolumn{2}{c}{Number} \\
\hline
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 0 && 0 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 1 && 1 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 2 && 2 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 3 && 3 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 4 && 4 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 5 && 5 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 6 && 6 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 7 && 7 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 8 && 8 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 9 && 9 \\
{\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 1 & 0 && 10 \\
\end{tabular}
\bigskip

When you get to the bottom of the column, you re-set the counter for that column to zero, and add one to the next column over (carry). So you go from 9 to 10, or 19 to 20, or 99 to 100. So any column can only hold between 0 and 9, before you have to carry over to the next \emph{order of magnitude}, which for a decimal system is \emph{ten times the size of one step in the column}. So when you run out of room for the ones column, you go to the \emph{tens} column, which contains ten times as many units as any single step (from 1 to 2, or from 8 to 9) in the column to the right of it. When you run out of room in the column, you have to carry to the next order of magnitude. You go from the ones, to the tens, to the hundreds (100 is $10 \times 10$), to the thousands (1000 is $10 \times 100$), and so on.

To express a number, we count up the amount of each order of magnitude and add them all together. The number 628 is made of $(6 \times 100) +  (2 \times 10) +  (8 \times 1)$, for instance.

\newpage

Here are a few examples of numbers expressed in columns. For each one, you count up how many units in the column exist, then count them for each order of magnitude, and add each value together to get the number being described:

\bigskip
\begin{tabular}{p{2.7in} | l l   l l l l | l l r }
\hline
\textbf{Text Description} & & \rot{ten thousands} & \rot{thousands} & \rot{hundreds} & \rot{tens} & \rot{ones} && \multicolumn{2}{c}{\textbf{Number}} \\[\sep]
\hline
& && & & & & &&\\[-2mm]

no ten-thousands, no thousands, no hundreds, no tens, and no ones   && {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 0 &&& 0 \\[\widesep]
no ten-thousands, no thousands, no hundreds, no tens, and one ones   && {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 1 &&& 1 \\[\widesep]
no ten-thousands, no thousands, no hundreds, no tens, and two ones  && {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 2 &&& 2 \\[\widesep]
no ten-thousands, no thousands, no hundreds, three tens, and no ones && {\color{lightgray}0} & {\color{lightgray}0} & {\color{lightgray}0} & 3 & 0 &&& 30 \\[\widesep]
no ten-thousands, no thousands, four hundreds, no tens, and no ones && {\color{lightgray}0} & {\color{lightgray}0} & 4 & 0 & 0 &&& 400 \\[\widesep]
no ten-thousands, no thousands, five hundreds, five tens, and five ones && {\color{lightgray}0} & {\color{lightgray}0} & 5 & 5 & 5 &&& 555 \\[\widesep]
no ten-thousands, six thousands, five hundreds, no tens, and two ones && {\color{lightgray}0} & 6 & 5 & 0 & 2 & & & 6502 \\[\widesep]
six ten-thousands, eight thousands, no hundreds, three tens, and no ones && 6 & 8 & 0 & 3 & 0 & & & 68030 \\[\widesep]
\hline
\end{tabular}

\bigskip

\stbox{6.0in}{\emph{Exercise:} What if, in the above table, you counted past 99,999? What number would you see? That is, what do you see if there is not a ``hundred-thousands" column? What happened to the hundred thousand that should be counted? Do you need to know how many hundred thousands are in the number? How would you handle the need for a larger number, if you have it? (Introduces the concept of \emph{overflow}.)}

\newpage
\subsection*{Representing Numbers in Binary}

Computers only understand ``1'' and ``0'' -- because it can sense the electricity in a wire that is either \emph{on} (having a detectable voltage greater than zero) or \emph{off} (having a reference voltage that is basically at ``zero volts", or ``ground."). That means that a computer, in order to add, subtract, or store information, has to express \emph{literally anything and everything it can handle} in terms of either ones or zeroes. This system is called \emph{binary}, because computers only understand two ``states" -- on, or off. Instead of ``base-10" counting (where moving to the next column happens when you pass 9), binary is ``base-2'' counting; the numbers move to the next column when the number passes 1---because {\color{webblue}\href{https://www.youtube.com/watch?v=MOn_ySghN2Y}{there's no such number as ``two''}} if you're a computer!

In order to add numbers in binary, we can't count to ten. We must count to one, and then, if the resulting number is greater than one, carry the digit to the next column. Counting in binary is interesting because it is different, and because it introduces us to a new way of doing math.

In order to add two numbers, computers have to do the following:
\be
\+ store each number in a binary format;
\+ compare each column (ones, twos, fours, eights, etc.) of each number and see if the numbers in that column add up to more than one;
\+ carry the ``one'' to the next column (the next \emph{order of magnitude}, which is two times the previous column). That is, if the number goes from one to two, the ``one" will go to zero and the ``two" will be moved -- and added -- to the next column over to the left;
\+ keep on adding and carrying digits until the addition is complete;
\+ count up the values of each order of magnitude (either one, or none) and add them together; and
\+ report the new number as a [binary] result.
\ee

\begin{minipage}[c]{6.5in}
\begin{center}
\textbf{Binary and decimal representation for each number from 0 to 15:}

\smallskip
\begin{tabular}{p{1.25in} | p{0.10in} p{0.10in} p{0.10in} p{0.10in} | l r}
\hline\\[\negsep]
\textbf{Description} & \rot{eights} & \rot{fours} & \rot{twos} & \rot{ones} && \textbf{{\color{webblue}base 10}}\\[\sep]
\hline\\[\negsep]
$0 + 0 + 0 + 0$   & 0 & 0 & 0 & 0 && {\color{webblue}0} \\

\grr
$0 + 0 + 0 + 1$ & 0 & 0 &  0 & 1 && {\color{webblue}1} \\

$0 + 0 + 2 + 0$   & 0 & 0 & 1 & 0 && {\color{webblue}2} \\

\grr
$0 + 0 + 2 + 1$   & 0 & 0 & 1 & 1 && {\color{webblue}3} \\

$0 + 4 + 0 + 0$   & 0 & 1 & 0 & 0 && {\color{webblue}4} \\

\grr
$0 + 4 + 0 + 1$   & 0 & 1 & 0 & 1 && {\color{webblue}5} \\

$0 + 4 + 2 + 0$   & 0 & 1 & 1 & 0 && {\color{webblue}6} \\

\grr
$0 + 4 + 2 + 1$   & 0 & 1 & 1 & 1 && {\color{webblue}7} \\

$8 + 0 + 0 + 0 $  & 1 & 0 & 0 & 0 && {\color{webblue}8} \\

\grr
$8 + 0 + 0 + 1 $  & 1 & 0 & 0 & 1 && {\color{webblue}9} \\

$8 + 0 + 2 + 0 $  & 1 & 0 & 1 & 0 && {\color{webblue}10} \\

\grr
$8 + 0 + 2 + 1 $  & 1 & 0 & 1 & 1 && {\color{webblue}11} \\

$8 + 4 + 0 + 0 $  & 1 & 1 & 0 & 0 && {\color{webblue}12} \\

\grr
$8 + 4 + 0 + 1 $  & 1 & 1 & 0 & 1 && {\color{webblue}13} \\

$8 + 4 + 2 + 0 $  & 1 & 1 & 1 & 0 && {\color{webblue}14} \\

\grr
$8 + 4 + 2 + 1 $  & 1 & 1 & 1 & 1 && {\color{webblue}15} \\

\hline
\end{tabular}
\end{center}

\stbox{6.0in}{\emph{Problem 1:} what happens in the above table if you add 1 to 15? What number would the computer report if it only has four columns to use? (As above with counting past 99,999, this problem refers to \emph{overflow}).
}

\stbox{6.0in}{\emph{Problem 2:} Let's say the machine runs by itself at some regular speed, and adds one to the number each second. Let's also say you are using this counter as a way to control a single blinking light, since ``1'' means ``there is electricity available to that wire" and so a ``1'' would turn the light on. Look at each column of numbers (that is, each \emph{order of magnitude!}). Remembering that ``a line that has a voltage" is a 1 and ``no voltage'' (usually called ``ground'') is a zero, which line (column) would make the light blink fastest? Which line would blink the slowest?
}
\end{minipage}

\bigskip

\begin{tabular}{ llll llll llll llll l}

\multicolumn{17}{c}{\textbf{How Computers Count to 2,020}}\\[\sep]

\hline\\[\negsep]
% 2020: 0111 1110 0100
$2^{15}$ & $2^{14}$ & $2^{13}$ & $2^{12}$ & $2^{11}$ & $2^{10}$ & $2^9$ & $2^8$ &
$2^7$ & $2^6$ & $2^5$ & $2^4$ & $2^3$ & $2^2$ & $2^1$ & $2^0$  & \\
\hline\\[\negsep]

0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & zero \\

\grr 0 & 0 & 0 & 0 & 0  & 1 & 1  & 1 & 1 & 1  & 1 & 0 & 0 & 0 & 1 & 1 & 2019 \\

0 & 0 & 0 & 0 & 0  & 1 & 1  & 1 & 1 & 1  & 1 & 0 & 0 & 1 & 0 & 0 & 2020 \\

%\\[\sep]
\hline

\end{tabular}

\bigskip

\begin{tabular}{ llll llll llll llll l}

\multicolumn{17}{c}{\textbf{How Computers Count to 65,535}}\\[\sep]

\grr \hline\\[\negsep]

\grr $2^{15}$ & $2^{14}$ & $2^{13}$ & $2^{12}$ & $2^{11}$ & $2^{10}$ & $2^9$ & $2^8$ &
$2^7$ & $2^6$ & $2^5$ & $2^4$ & $2^3$ & $2^2$ & $2^1$ & $2^0$  & \\
\hline\\[\negsep]
 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & zero \\
\grr
 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 32,767 \\
 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 32,768 \\
\grr
 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 65,535 \\[\sep]
\hline

\end{tabular}

\bigskip

If the computer counts up from zero, then once it gets past the $2^{14}$ column, it jumps to the $2^{15}$ (32,768) column.

\stbox{6.0in}{\emph{Useless skill:} Did you know you can count to 31 on one hand? You have five fingers, and each finger can be open or closed, and $2^5$ is 32. Use your thumb for the ``0 or 1" ($2^0$, ``two to the zeroth power") column; the digit to its left represents two to the first power (the ``twos digit"); the next digit to the left represents two to the second power (the ``fours digit"); and so on. Watch out for ``4'' though!}

\begin{tabular}{llll llll l}

\rot{128} & \rot{64} & \rot{32} & \rot{sixteen} & \rot{eight} & \rot{four} & \rot{two} & \rot{one} &  \\[\sep]
\hline\\[\negsep]

$2^7$ & $2^6$ & $2^5$ & $2^4$ & $2^3$ & $2^2$ & $2^1$ & $2^0$  & \textbf{Result} \\[\sep]
\hline\\[\negsep]
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & {\color{webblue}\textbf{0}} \\
\grr
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & {\color{webblue}\textbf{2}} ($2 + 0$) \\
0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & {\color{webblue}\textbf{3}} ($2 + 1$) \\
\grr
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & {\color{webblue}\textbf{4}} ($4 + 0 + 0$) \\
0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & {\color{webblue}\textbf{7}} ($4 + 2 + 1$) \\
\grr
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & {\color{webblue}\textbf{8}} ($8 + 0 + 0 + 0$) \\
\\
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & \makeblank{1.5in} \\
\grr
0 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & \makeblank{1.5in} \\
0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & \makeblank{1.5in} \\
\grr
0 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & \makeblank{1.5in} \\
0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & \makeblank{1.5in} \\
\grr
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & \makeblank{1.5in} \\
0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & \makeblank{1.5in} \\
\grr
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & \makeblank{1.5in} \\[\sep]
\hline

\end{tabular}
\bigskip

\stbox{6.0in}{\emph{Tip:} if you have a sequence of all ones, like 7 or 15 or 31, rather than adding up each binary column, you can just subtract one from the next largest column base number. So \texttt{0111} equals \texttt{1000} minus one.}

\vfill

\stbox{4.25in}{\noindent{\color{red}\textbf{Joke:}}

    \medskip

    \noindent\emph{Remember:}  There are only 10 types of people in the world;\\
those who understand binary, and those who don't.\\

\bigskip

(If the joke needs explanation, write 10 like \texttt{0010} and then figure up the value in binary)}


 \documentclass[../thesis.tex]{subfiles}
 \begin{document}

 This appendix contains formal specifics of Multi-Agent Influence
 Diagrams and data games.

\section{Multi-Agent Influence Diagrams}

Multi-Agent Influence Diagrams (MAIDs) are a game-theoretic
extension of Bayesian networks developed by Koller and Milch
\cite{koller2003multi}.
A MAID is defined by:
\begin{enumerate}
\item A set $\mc{A}$ of agents
\item A set $\mc{X}$ of chance variables
\item A set $\mc{D}_a$ of decision variables for each agent $a \in \mc{A}$,
  with $\mc{D} = \bigcup_{a \in \mc{A}} \mc{D}_a$
\item A set $\mc{U}_a$ of utility variables for each agent $a \in \mc{A}$,
  with $\mc{U} = \bigcup_{a \in \mc{A}} \mc{U}_a$
\item A directed acyclic graph $\mc{G}$ that defines the parent function
  $Pa$ over $\mc{V} = \mc{X} \cup \mc{D} \cup{U}$
\item For each chance variable $X \in \mc{X}$, a CPD $Pr(X \vert Pa(X))$
\item For each utility variable $U \in \mc{U}$, a CPD $Pr(U \vert Pa(U))$
\end{enumerate}

The decision variables represent moments where agents can
make decisions about how to act given only the information
provided by the variable's parents.

\begin{dfn}[Decision rules]
  \label{dfn:decision-rule}
  A \emph{decision rule} $\delta$ is a function that maps each instantiation
  $\vec{pa}$ of $Pa(D)$ to a probability distribution over $dom(D)$.
\end{dfn}

\begin{dfn}[Strategy]
  \label{dfn:strategy}
  An assignment of decision rules to every decision $D \in \mc{D}_a$
  for a particular agent $a \in \mc{D}_a$ for a particular agent
  $a \in \mc{A}$ is called a \emph{strategy}.
\end{dfn}

\begin{dfn}[Strategy profile]
  An assignment $\sigma$ of decision rules to every decision
  $D \in \mc{D}$ is called a \emph{strategy profile}.
  A \emph{partial strategy profile} $\sigma_\mc{E}$ is
  an assignment of decision rules to a subset $\mc{E} \subset \mc{D}$.
  $\sigma_{-\mc{E}}$ refers to a restriction of $\sigma$ to variables
  not in $\mc{E}$.
\end{dfn}

Decision rules are of the same form as CPDs, and so a MAID
can be transformed into a Bayes network by replacing every
decision variable with a random variable with the CPD of the
decision rule of a strategy profile.

\begin{dfn}
  If $\mc{M}$ is a MAID and $\sigma$ is a strategy profile for
  $\mc{M}$, then the \emph{joint distribution for $\mc{M}$
    induced by $\sigma$}, denoted $P_{\mc{M}[\sigma]}$, is the
  joint distribution over $\mc{V}$ defined by the Bayes
  net where:
  \begin{itemize}
  \item the set of variables is $\mc{V}$;
  \item for $X, Y \in \mc{V}$, there is an edge $X \rightarrow Y$
    if and only if $X \in Pa(Y)$;
  \item for all $X \in \mc{X} \cup \mc{U}$, the CPD for $X$ is $Pr(X)$;
  \item for all $D \in \mc{D}$, the CPD for $D$ is $\sigma(D)$.
  \end{itemize}
\end{dfn}

\begin{dfn}
  Let $\mc{E}$ be a subset of $\mc{D}_a$ and let $\sigma$ be a strategy
  profile.
  We say that $\sigma*_\mc{E}$ is \emph{optimal for the strategy profile}
  $\sigma$ if, in the induced MAID $\mc{M}[\sigma_{-\mc{E}}]$,
  where the only remaining decisions are those in $\mc{E}$,
  the strategy $\sigma*_{\mc{E}}$ is optimal, i.e., for all
  strategies $\sigma'_{\mc{E}}$:
  $$EU_a((\sigma_{-\mc{E}},\sigma*_{\mc{E}})) \geq EU_a((\sigma_{\mc{E}}, \sigma'_{\mc{E}}))$$
\end{dfn}

A major contribution of \citet{koller2003multi} is their analysis
of how to efficiently discover Nash Equilibrium strategy profiles
for MAIDs.
Their method involves analyzing the qualitative graphical
structure of the MAID to discover the \emph{strategic reliance}
of decision variables.
When a decision variable $D$ strategically relies on $D'$,
then in principle the choice of the optimal decisionr rule for
$D$ depends on the choice of the decision rule for $D'$.

\begin{dfn}[Strategic reliance]
  \label{dfn:strategic-reliance}
  Let $D$ and $D'$ be decision nodes in a MAID $\mc{M}$.
  $D$ \emph{strategically relies on} $D'$ if there exist
  two strategy profiles $\sigma$ and $\sigma'$ and a
  decision rule $\delta$ for $D$ such that:
  \begin{itemize}
  \item $\delta$ is optimal for $\sigma$;
  \item $\sigma'$ differs from $\sigma$ only at $D'$;
  \end{itemize}
  but no decision rule $\delta*$ that agrees with $\delta$ on
  all parent instantiations $\vec{pa} \in dom(Pa(D))$
  where $P_{\mc{M}[\sigma]}(\vec{pa}) > 0$ is optimal for $\sigma'$.
\end{dfn}

\begin{dfn}[s-reachable]
  \label{dfn:s-reachable}
  A node $D'$ is \emph{s-reachable} from a node $D$ in a MAID
  $\mc{M}$ if there is some utility node $U \in \mc{U}_D$ such
  that if a new parent $\widehat{D'}$ were added to $D'$, there would
  be an active path in $\mc{M}$ from $\widehat{D'}$ to $U$ given
  $Pa(D) \cup \{D\}$, where a path is active in a MAID if it
  is active in the same graph, viewed as a BN.
\end{dfn}

\begin{thm}
  \label{thm:strategic-non-reliance}
  If $D$ and $D'$ are two decision nodes in a MAID $\mc{M}$
  and $D'$ is not s-reachable from $D$ in $\mc{M}$, then D
  does not strategically rely on $D'$.
\end{thm}

\subsection{Tactical independence}

This dissertation introduces a new concept
related to Multi-Agent Influence Diagrams: tactical independence.

\begin{dfn}[Tactical independence]
  \label{dfn:tactical-independence}
  For decision variables $D$ and $D'$ in MAID $\mc{M}$,
  $D$ and $D'$ are \emph{tactically independent} for
  conditioning set $\mc{C}$ iff
  for all strategy profiles $\sigma$ on $\mc{M}$,
  in $P_{\mc{M}[\sigma]}$, the joint distribution for
  $\mc{M}$ induced by $\sigma$,
  $$D \independent D' \vert C$$
\end{dfn}

Because tactical independence depends on the
independence of variables on an induced probability
distribution that is representable by a Bayesian
network, the d-separation tests for independence
apply readily.

\begin{thm}
  For decision variables $D$ and $D'$ in MAID $\mc{M}$,
  and for conditioning set $\mc{C}$, if
  $D$ and $D'$ are d-separated given $\mc{C}$ on
  $\mc{M}$ considered as a Bayesian network,
  then $D$ and $D'$ are tactically independent
  given $\mc{C}$.
\end{thm}

\begin{proof}
  Suppose $D$ and $D'$ are d-separated given $\mc{C}$
  on $\mc{M}$ considered as a Bayesian network.

  For any strategy profile $\sigma$,
  the joint distribution for $\mc{M}$
  induced by $\sigma$, $P_{\mc{M}[\sigma]}$
  has the same graphical structure as $\mc{M}$
  considered as a Bayesian network.

  Therefore, $D$ and $D'$ are d-separated given $\mc{C}$
  in the graph corresponding to $P_{\mc{M}[\sigma]}$
  for all $\sigma$.

  Because $D$ and $D'$ are d-separated given $\mc{C}$
  in the Bayesian network, $D \independent D' \vert C$.
\end{proof}

% Utility CPDs are deterministic
% Utility nodes have to be leaves (I bend this in my models!)

\subsection{Notation}
\label{sec:maid-notation}

We will use a slightly different graphical notation than that used by
\citet{koller2003multi}.

In the models in this paper, we will denote random variables
with undecorated capital letters, e.g. $A, B, C$.
I will denote strategic nodes with a tilde over a capital
letter, e.g. $\tilde{A}, \tilde{B}, \tilde{C}$.
The random variable defined by the optimal strategy at a
decision node, when such a variable is well-defined,
will be denoted with a hat, e.g. $\hat{A}, \hat{B}, \hat{C}$.
Nodes that represent the payoff or utility to an
agent will be denoted with a breve, e.g.
$\breve{A}, \breve{B}, \breve{C}$.
Particular agents will be identified by a lower case
letter and the assignment of strategic and utility nodes
to them will be denoted by subscript.
E.g., $\tilde{A}_q$ and $\breve{U}_q$ denote an action
taken by agent $q$ and a payoff awarded to $q$,
respectively.

\section{Data Games}
\label{sec:value-of-data}

What distinguishes a data game from a MAID is the use
of optional arrows to support mechanism design.
A dotted arrow in a data game an optional arrow.
The diagram defines two separate models, one including the
arrow and one without.
When considering an instantiation of the model with the dotted
edge present, we will say the model or edge is \emph{open}.
When the edge is absent, we'll say it's \emph{closed}.

As we have distinguished between strategic reliance and
tactical independence, we can distinguish between the
strategic and tactical value of information.

The strategic value of an information flow to an agent
is the difference in utility to that agent in the open
and closed conditions of the game, given each game
is at strategic equilibrium for all players.

\begin{dfn}[Strategic value of information]
  \label{dfn:strategic-value}
  Given two MAID diagrams $\mc{M}_{o}$ and $\mc{M}_{c}$
  that differ only by a single edge, $e$,
  and a strategic profile solution for each diagram, $\hat{\sigma}_{o}$
  and $\hat{\sigma}_{c}$, the \emph{strategic value of $e$ to $a$}
  is the difference in expected utility to $a$ under the
  two respective induced joint distributions:

  $$E(P_{\mc{M}_{o}[\hat{\sigma}_{o}]}(U_a)) - E(P_{\mc{M}_{c}[\hat{\sigma}_{c}]}(U_a))$$
\end{dfn}

Definition \ref{dfn:strategic-value} is an incomplete
definition because it leaves open what \textit{solution concept}
is used to determine the strategic profile solutions.
For the purpose of the results in this paper, we use
Nash Equilibrium as the solution concept for determining
strategic value of information.

In contrast with the strategic value of information,
the tactical value of information is the value of
the information to an agent given an otherwise fixed
strategy profile.
We allow the agent receiving the data to make a tactical
adjustment to their strategy at the decision variable
at the head of the new information flow.

\begin{dfn}[Best tactical response to information]
  \label{dfn:best-tactical-response}
  Given two MAID diagrams $\mc{M}_{o}$ and $\mc{M}_{c}$
  differing only in optional edge $e$ with head in decision
  variable $D_a$,
  the \emph{best tactical response to $e$} given
  strategy profile solution $\hat{\sigma}$, $\hat{\delta}_{\sigma,e}$
  is the decision rule $\delta$ for $D$ such
  that $\delta$ is optimal for $\hat{\sigma}$
  for player $a$.
\end{dfn}

\begin{dfn}[Tactical value of information]
  \label{def:tactical-value}
  Given two MAID diagrams $\mc{M}_{o}$ and $\mc{M}_{c}$
  differing only in optional edge $e$ with head in decision
  variable $D$,
  the \emph{tactical value of $e$} to agent $a$ given
  strategy profile solution $\hat{\sigma}$
  is the difference in expected utility of
  the open condition with the best tactical response to $e$
  and the closed condition using the original strategy:

  $$EU_a((\hat{\sigma}_{-D},\hat{\delta}_{\hat{\sigma},e}) - EU_a(\hat{\sigma})$$
\end{dfn}

Note that the uniqueness of a best tactical response
has not yet been proven.
However, if the best tactical response is not unique,
then the tactical value of the information will be the
same for any best tactical response.
This definition, like Definition \ref{dfn:strategic-value},
depends on an implicit solution concept.

\end{document}


\subsubsection{Feature importance}
\label{sec:methods_pipeline_feature_importance}

Lopez de Prado's eloquent words in section 8.2 of \cite{lopez_de_prado} are very
appropriate to illustrate what this section is about.

\say{Hunters do not blindly eat everything their smart dogs retrieve for them, do they?}

As a financial machine learning researcher once we are satisfied
with the performance of a machine learning model it is advised to understand
which, how and when features contribute to improve the performance of the model.
The author focuses on the \emph{importance} of the features with and without
substitution effects. In this research pipeline, only a method to consider
substitution effects is implemented.

The method is called Mean Decrease Accuracy and it uses model's estimation
accuracy as guiding principle. Description of the method follows:

\begin{itemize}
  \item Let $X$ of be the feature matrix and let $Y$ be the output vector.
  \item Let $X_1, X_2, X_3, ..., X_m$ be the columns of $X$.
  \item Fit via the desired training process $m + 1$ models and measure their
        accuracy. One model will be fitted with $X$ as is. And the other $m$
        models will be fitted with one randomly permutated column $X_i$.
  \item For each of the aforementioned $m$ models, compute the relative loss in
        accuracy with respect to the base without permutation model.
\end{itemize}

This method allows to create a rank in which once can inspect the relative loss
of performance measured in accuracy, but it could also be F1-score or
negative log-loss when working with classifiers. Having a high value means
that the predictive importance of the feature is relevant. Even though this method
is flexible and adaptable to multiple types of models as it is based on out of
sample performance, it comes with some important drawbacks:

\begin{itemize}
  \item It is relatively slow because it requires the training of $m + 1$ models and
        the evaluation of their performance. When this is done with purged $K$-fold cross
        validation with embargo\emph{ed} datasets, it will definitely take time.
  \item It is susceptible to \emph{substitution effects}. The effect can be described with two
        or more features that are highly correlated. The performance loss will be similar so
        a researcher might decide to remove them but with that the overall predictive
        capacity diminishes more than just keeping one of the features in the set
        under study.
  \item A possible result is that all features are detrimental or unimportant
        for the model what is somewhat hard to interpret.
\end{itemize}

Feature orthogonalization could help to reduce the substitution effect. Two
procedures are proposed. First, a direct application of Frisch–Waugh–Lovell theorem
analysis can be used. Each feature is analyzed individually via a linear
regression and residues are inspected to derive relative importance. See
chapters 2 and 3 of \cite{econometric_theory_and_methods} for an in depth description
of the theorem and applications. Secondly, Principal Component Analysis, i.e. PCA,
as suggested in section 8.4.2 of \cite{lopez_de_prado} can also be used to
determine the set of features whose eigenvalues in the orthogonalized space are
greater. Alternatively, the feature space could also be reduced in favor of
faster convergence of the machine learning models under use.

Once all features are ranked, the researcher is required to select which
features to drop and which ones to keep. The final set of features will be used
to build a new model. Heuristic rules are used to drop features but as mentioned
before researchers should be aware of the substitution effect. In this research
project, the applied rule applied consists in computing the mean loss of
negative log-loss and keep those features that produce higher than the mean loss
in performance.

Furthermore, researchers often face the requirement of explaining the economic
mechanism that generates the excess return of the strategy with respect to a
benchmark. Understanding which features contribute more to predict with increased
confidence labels is reasonably simpler when extra unimportant features are
removed. This stage of the process together with feature engineering are very
important to understand how the model behaves.


\section{Time Series}

A time series, also known as discrete time signal, is a sequence of observations taken periodically in time. We can use time series to perform many tasks such as predictions of future values, behaviour analysis or information extraction. Examples of time series are audio signals, industrial instrument measures or diary finantial activity.

\begin{figure}[H]
  \centering
  \input{Figures/TimeSeries}
  \caption{Example of a random time series.}
\end{figure}
A system can be determined comparing the input and the output. We call the system a filter if it is linear and time invariant. Considering the dynamic system as a black box, we can estimate the transference function or the impulse response to taht filter.

We can also consider \textbf{multivariate} time series, where some values of the time series have an influence on the other values in different or the same time instant. We can \textbf{classify} the time series in two wide types:

\begin{itemize}
  \item Determinist: based in dynamic systems, they exploit the phisics of the generation algorithm of the time series.
        \item Stochastic: where the series are realizations of a stochastic process, which can be modelated.
\end{itemize}

In this subject, we will focus on stochastic models.

\subsection{Stochastic Models}

We can make three big considerations on the stochastic models.
\begin{itemize}
  \item Stationary models.
        \begin{ndef}
          Let \(\{X_{t}\}\) be a stochastic process and let \(F_{X}\left(x_{t_{1} + \tau}, \dots, x_{t_{n} +\tau}\right)\) represent the CDF of the \textbf{unconditional} joint distribution of \(\{X_{t}\}\) at times \(t_{1 }+ \tau,\dots, t_{n} + \tau\). Then \(\{X_{t}\}\) is strictly stationary if
          \[
            F_{X}\left( x_{t_{1} + \tau}, \dots, x_{t_{n} +\tau}\right) = F_{X}\left(X_{t_{1}},\dots,x_{t_{n}}\right)
          \]

        \end{ndef}
        However, we will use the case of \textbf{weak stationarity}, where we assume that the expectation of the stochastic process and the covariance at times \(t,t+\tau\) are constant.

        \begin{example}
          AR, MA, ARMA
        \end{example}

  \item Non stationary models, where we do not make the assumption that the average of the process is constant in time and that there is seasonality
        \begin{example}
          ARIMA, SARIMA
        \end{example}

  \item Influenced by exogenous(extern) variables. In this cases, the exogenous variable affects the model, but the model does not affect this variable.
        \begin{example}
          SARIMAX
        \end{example}
\end{itemize}

Let us introduce some \textbf{notation} for the following explanations

\begin{ndef}
  Let \(z_{t}\) be the value of the time series at instant \(t\).
  \begin{itemize}
    \item The \textbf{backward shift} operator is \(z_{t-m} = B^{m}z_{t}\)
    \item The \textbf{forward shift} operator is \(z_{t+m} = F^{m}z_{t} = B^{-m}z_{t}\)
    \item The difference or discrete gradient operator is \(\nabla z_{t} = z_{t} - z_{t-1} = (1-B)z_{t}\)
  \end{itemize}
\end{ndef}

Recall that, having a time series we can consider its \textbf{Z-transform}, that converts the discrete-time signal into a complex frequency-domain representation. In the Z-transform representation, the previously introduced notation is:
\begin{itemize}
  \item The backward shift is \(z_{t-m} = B^{m}z_{t} = Z^{-m}z_{t}\)
  \item The forward shift is \(z_{t+m} = B^{-m}z_{t} = Z^{m}z_{t}\)
        \item The difference or discrete gradient is \(\nabla z_{t} = (1-Z^{-1})z_{t}\)
\end{itemize}

\section{Linear filter based models}

The stochastic models we use are based on time series \(z_{t}\) in which sucessive values are highly dependent. In these cases, we can see that the time series is generated from a series of independependent ``shocks''.

\begin{ndef}
  Let \(a_{t} \sim \mathcal N\left(0,\sigma_{a}^{2}\right)\) be \emph{white noise} (where each \emph{shock} is related to \(a_{t}\)) which is not observed. Consider a linear filter that transforms the unobserved \(a_{t}\) to a observed time series \(z_{t}\). We say that a \textbf{linear filter model is}
  \begin{equation}\label{linear:filter}
    z_{t} = \mu + a_{t} + \psi_{1}a_{t-1} + \psi_{2}a_{t-2} + \dots = \mu + \psi(B)a_{t},
  \end{equation}
  where
  \[
    \psi(B) = 1 + \psi_{1}B + \psi_{2}B^{2} + \dots
  \]
  is called the \textbf{transfer function} of the filter.
\end{ndef}

\begin{figure}[H]

  \centering
  \includegraphics{Figures/LinearFilter}

\end{figure}

As we can see, we are expressing the filter in terms of a infinite sum of the coefficients \(\psi_{i}\). If there are finite coefficients of the sum is \emph{absolutely summable}, that is: \(\sum_{j = 0}^{\infty}\abs{\psi_{j}} < \infty\) or the vector of coefficients has finite \(\ell^{1}\) norm, we say that the filter is \textbf{stable} and the process \(z_{t}\) is \textbf{stationary}.

In the case where the \(\ell^{1}\) norm is not finite, our filter are non-stable and produce non-stationary series.

\subsection{Autoregressive Models (AR)}

Let us firstly consider the simplest case of linear filter. An \textbf{autoregressive model} is a linear filter where the current value of the process \(\tilde z_{t}\) is expressed as a finite sum of the previous values and a random shock \(a_{t}\).

\begin{ndef}
  Let us denote the values of a process af equally spaced times \(t,t-1,\dots\) by \(z_{t}, z_{t-1}, \dots\). Consider that the values are centered, that is \(\tilde z_{t} = z_{t} - \mu\). Then, the \textbf{autoregressive (AR) process} of \textbf{order p} is
  \begin{equation}\label{model:AR}
    \tilde z_{t} = \phi_{1}\tilde z_{t-1} + \phi_{2}\tilde z_{t-2}+ \dots  + \phi_{p}\tilde z_{t-p} + a_{t}
    \end{equation}
\end{ndef}

Note that it is called autoregressive since, if you consider \(\tilde z_{i-k}\) for \(k = 1,\dots,p\) as points, you are doing a \emph{linear regression} over the past values.\\

Now, if we define the \textbf{autoregressive operator of order p} using the backward shift operator \(B\) as:
\[
\phi(B) = 1- \phi_{1}B - \phi_{2}B^{2} - \dots - \phi_{p}B^{p},
\]
we can economically write the autoregressive model in \eqref{model:AR} as
\begin{equation}\label{model:ar:red}
  \phi(B)\tilde z_{t} = a_{t}
\end{equation}

In practice, this model has \(p+2\) unknown parameters \(\mu,\phi_{1},\dots,\phi_{p},\sigma_{a}^{2}\) which have to be estimated from the data.

\begin{nprop}
The autoregressive model is a particula case of a linear filter
\end{nprop}
\begin{proof}
  Although we will not be estrictly formal in this proof, we will give an intuition on the iterative process that has to be done.

  Consider the term \(\tilde z_{t-1}\), let us eliminate it. Recall that
  \[
    \tilde z_{t-1} = \phi_{1}\tilde z_{t-2} + \dots + \phi_{p} \tilde z_{t-p-1} + a_{t-1}.
  \]
  We can substitute this term in the expression of the AR model given in Equation \eqref{model:AR}. The same can be done for \(\tilde z_{t-2}\) and so on, to yield eventually an infinite series in the \(a\) terms.

\end{proof}

  In the case where \(p=1\), we have the AR process \(\tilde z_{t} = \phi \tilde z_{t-1} + a_{t}\). After \(m\) sucessive substitutions of \(\tilde z_{t-j} = \phi \tilde z_{t-j-1} + a_{t-j} \), with \(j = 1,\dots,m\), we obtain
  \[
    \tilde z_{t} = \phi^{m+1}\tilde z_{t-m-1}+ a_{t} + \phi a_{t-1} + \phi^{2}a_{t-2} + \dots + \phi^{m}a_{t-m}
  \]
  Now, if we take the limit \(m\to \infty\) this leads to the \emph{convergent inifinite series representation} \(\tilde z_{t} = \sum_{j=0}^{\infty}\phi^{j}a_{t-j}\), with \(\psi_{j} = \phi^{j}, j \geq 1\), provided that \(\abs{\phi} < 1\). In the general AR case,
  \[
    \phi(B) \tilde z_{t} = a_{t}
  \]
  is equivalent to
  \[
    \tilde z_{t} = \phi^{-1}(B) a_{t} = \psi(B)a_{t}, \quad \quad \psi(B) = \phi^{-1}(B) = \sum_{j=0}^{\infty}\psi_{j}B^{j}.
  \]

  AR processes can be stationary or nonstationary. From the definition, it is clear that for a AR process to be stationary, the coefficients \(\phi\) must be such that the weights \(\psi_{1},\psi_{2},\dots\) in \(\psi(B) = \phi^{-1}(B)\) form a convergent series. A \textbf{necessary requirement} for stationarity is that the autoregressive operator \(\phi(B)\), considered a polynomial in \(B\) of degree \(p\), must have all roots greater than \(1\) in absolute value.

  \subsection{Application: Linear Prediction Coefficients in Speech Coding}

  Let us now set in the case of the \textbf{Speech Coding} topic. It is considered that a speech sample can be approximated as a linear combination of the past samples, which is how an AR model behaves. We have to find the coefficients that best suit our problem, using for instance the mean squared error prediction. We use the obtained \textbf{Linear Prediction Coefficients (LPCs)} to represent the signal frame.

  Using this technique, we would be \textbf{reducing} the signal size significantly. However, since we are only approximating the signal, we would be most probably losing information. Two examples of codification of the audio signals are:

  \begin{itemize}
    \item MP3: which produces a different audio signal, involving loss of information
          \item FLAC: where the output is almost equal to the input, no loss of information
\end{itemize}

Signals are digitalized using a coding system.

\begin{figure}[!h]
  \centering
  \includegraphics[scale=0.5]{Figures/SpeechCodingSystem}
  \caption{Block diagram of a speech coding system.}
\end{figure}

The filter eliminates aliasing and the sampler makes the continuous to discrete time conversion.

\begin{example}
  In this example, we present the digital CD audio signal and why we would like to reduce its size without losing information. This signal has the following properties:

  \begin{enumerate}
    \item Sample rate \(\Omega_{s} = 44.1 kHz\)
    \item Bits per sample: \(16\)
          \item 2 channels (although sometimes 3 are used)
  \end{enumerate}

  With this properties, the input bit rate is
  \[
    R = \Omega_{s} \ \cdot \ \operatorname{Bits/sample} \ \cdot \ \operatorname{Channels} = 44.1*10^{3} * 16 * 2 = 14112000 \frac{\operatorname{bits}}{s} = 1.41 \frac{\operatorname{Mb}}{s}
  \]
  Which implies that, in a single minute we would need
  \[
    60s ; * ; 1,4112 \frac{\operatorname{Mb}}{s} ; * ; \frac{1 \operatorname{byte}}{8 \operatorname{bits}} = 10.09 \operatorname{MB},
  \]
  which is a high size for a single minute audio.
\end{example}

\begin{example}
  In this example, we will present the input bit rate for the speech digital signal. Its common properties are:
    \begin{enumerate}
    \item Sample rate \(\Omega_{s} = 8 ; \operatorname{kHz}\)
    \item Bits per sample: \(16\)
          \item 1 channel
    \end{enumerate}

  With this properties, the input bit rate is \(128\) Kb per second.

\end{example}

As a quick note, remember that \textbf{to quantify} a continuous time series is to assign it discrete amplitude values. When we do this, we are introducing a \textbf{cuantification error},
\[
\operatorname{error}(t) = z_{\operatorname{quantified}}(t) - z_{\operatorname{original}}(t)
\]
In each \(t \in \mathbb R\), this error can be positive or negative. We can consider that the error is additive.\\

Let us consider a simplified version of the speech production model. Consider that there is a source and a filter, such as in the next figure:

\begin{figure}[!h]
\centering
\includegraphics[scale=0.6]{Figures/SpeechGeneration}
\caption{LPC model of speech production.}
\end{figure}

Then,

\begin{itemize}
  \item We assume that we can separate the voice in non overlapping frames that are short enough to keep the model parameters constant.
  \item Then, we estimate the model parameters for each frame . These parameters are: voicing, gain (energy level of the frame), filter coefficients (response of the synthesis filter), pitch period (time length between consecutive excitation impulses)
\end{itemize}

\subsubsection*{Using the AR model to compute the synthesis filter coefficients}

We can use the autoregressive model to predict a speech sample. Let \(x[n]\) be the discrete signal. The prediction aims to find the coefficients \(a_k\), \(k = 1,\dots, p\) such that we can compute that sample using the previous samples

\[
x[n] \approx \sum_{k=1}^p a_k \ x[n-k] \implies x[n] = \sum_{k=1}^p a_k \ x[n-k] + e[n] = \sum_{k=1}^p a_k \ x[n-k] + Ge'[n],
\]
where \(e[n]\) is the error at time step \(n\), \(e'[n]\) is the theoretical excitation and \(G\) is the gain. We \textbf{minimize the mean squared error}(also called mean energy) of the prediction error \(e[n]\) in order to fit this model.

\section{ARMA, (S)ARIMA(X) and Multivariate series}

In this section we will generalize the Autoregressive model, adding complexity (and thus more generalization capability) to it.

\subsection{MA and ARMA}

Firstly, we bring back the general expression of a linear filter given in Equation \eqref{linear:filter}:
\[
\tilde z_t = a_t + \sum_{j=1}^\infty \psi_j a_{t-j}.
\]

We can consider a special case when only the first \(q \in \mathbb N\) are nonzero.

\begin{ndef}
A \textbf{Moving Average (MA)} process of order \(q\) is a linear filter where only the first \(q\) terms are nonzero
\begin{equation}\label{model:MA}
\tilde z_t = a_t - \theta_1 a_{t-1} - \dots - \theta_q a_{t-q}.
\end{equation}
\end{ndef}
As it can be appreciated, we now use the symbols \(-\theta_1,\dots, -\theta_q\) for the finite set of \emph{weights}. What we are doing is to \emph{smooth} the white noise \(a_t\).

Recall that, as we did before, we can express the moving average model as
\[
\tilde z_t = (1- \theta_1 B - \theta_2 B^2 - \dots - \theta_q B^q) a_t = \theta(B) a_t.
\]

The Moving Average models are \textbf{not addecuate} when the series has \emph{autocorrelation} (that is, relation to its past values). Also, real-life time series are ``more than white noise'' to smooth.

A solution for this disadvantages could be combining the MA model with the AR model linearly:

\begin{ndef}
The \textbf{Autoregressive-Moving Average (ARMA)} process of order \(p,q\) is defined as a linear combination of both models
\[
\tilde z_t = \sum_{i = 1}^p \phi_i \tilde z_{t-i} + a_t - \sum_{j = 1}^q \theta_j a_{t-j},
\]
or
\[
\phi(B)\tilde z_t = \theta(B)a_t.
\]
\end{ndef}

Using an ARMA model, we are not only capturing the relationships between a point \(\tilde z_t\) and its previous ones (AR), but also smoothing the influence of the white noise (MA).

A great \textbf{disadvantage} of the ARMA models is that they are \textbf{always stationary}, so we cannot model non-stationary time series.

The following proposition presents a very interesting results on ARMA models:

\begin{nprop}
  An ARMA process is stationary if all the roots of \(\phi(B) = 0\) have module greater than one, and it is (explosive) non stationary if the roots have module lesser than one.

\end{nprop}

The left-to-mention case where the roots of \(\phi(B) = 0\) lie \textbf{on} the unit circle is very interesting. Nonseasonal series are often well represented by models in which one or more roots are unitary.
\section{Non estationarity}

Many time series appearing in real life have non stationary behaviour. Thus, we have to obtain new models to be able to make prediction of future values.

However, we can decompose these time series and treat them separately.

\begin{figure}[H]
\centering
\includegraphics[scale=0.7]{Figures/Decomp}
\caption{Multiplicative decomposition of a time series.}
\end{figure}

Tipically, we use the following components (all of them at time \(t\)):

\begin{enumerate}
\item \(T_t\), the \textbf{trend} component, reflecting the long-term progression of the series. It exists when there is a persistent increasing or decreasing direction on the data. It is not neccesarily linear.

\item \(S_t\), the \textbf{seasonal} component, reflecting the seasonal variation. A seasonal pattern exists when a time series is influenced by seasonal factors. Seasonality occurs over a fixed known period of time.

\item \(R_t\), the \textbf{residual} component, describing randomness or irregular influences
\end{enumerate}

Ocassionally, an additional cyclical component \(C_t\) is considered, but we will not do consider that case. With the considered components, using an \textbf{additive} model (used when the variations around the trend do not vary with the level of the time series), we can think of the time series as
\[
z_t = T_t + S_t + R_t.
\]
Using a \textbf{multiplicative} model (used when the trend is proportional to the level of the time series), our time series can be written as:
\[
z_t = T_t \times S_t \times R_t.
\]

Having the different components of a time series, we can look at the properties of each of the individual components and study them separately. Some properties that will help us in the creation of new models are:

\begin{enumerate}
\item The residual \(R_t\) is usually stationary, so we can use an already known model.
\item The trend \(T_t\) is usually a smooth function, which we can derivate (one or multiple times) in orden to \emph{make it dissapear}

\item The stationality \(S_t\) has a periodic component.
\end{enumerate}

\subsection{ARIMA}

Firstly, we will deal with the trend \(T_t\). As we have said, we can make it \emph{dissapear} by differenciating it.

Firstly, it can be shown that if \(d\) roots of the generalized autoregressive operator \(\varphi(B)\) are unitary, then this operator can be written as
\[
\varphi(B) = \phi(B)(1-B)^{d},
\]
where \(\phi(B)\) is a stationary autoregressive operator. Thus, a model that can represent homogeneous nonstationary behaviour has the form:
\[
\varphi(B)z_{t} = \phi(B)(1-B)^{d}z_{t} = \theta(B)a_{t}.
\]

Now, if we name
\[
w_{t} = (1-B)^{d}z_{t} = \nabla^{d}z_{t},
\]
we can rewrite the previous equation as
\[
\phi(B)w_{t} = \theta(B)a_{t},
\]
and we are representing homogeneous nonstationary behaviour using the \(d-\)th diference of the process and calling it to be stationary. In practise, \(d\) is not usually greater than \(2\).

We can now use this reasoning to give a formal definition of the ARIMA process.

\begin{ndef}
  The \textbf{Autoregressive integrated moving average process (ARIMA)}of order \(p,d,q\) is defined by:
  \[
    w_{t} = \sum_{i = 1}^{p} \phi_{i}w_{t-i} + a_{t} - \sum_{j = 1}^{q} \theta_{j}a_{t-j},
  \]
  where \(w_{t} = \nabla^{d}z_{t}\).
\end{ndef}

\begin{remark}
If we replace \(w_{t}\) by \(z_{t} - \mu\), in the \(d= 0\) case, the model includes the \emph{estationary mixed model}, the AR and the MA models.
\end{remark}

The following explanation gives an intuition of why is the model called \emph{integrated} (although it probably should be called \emph{summed}):\\

Let us find the \textbf{inverse relation} for \(w_{t} = (1-B)^{d}z_{t} = \nabla^d z_{t}\). Consider
\[
S = \nabla^{-1} = (1-B)^{-1} = \sum_{i = 0}^{\infty}B^{i}.
\]
Then, we can consider this \emph{inverse relation} expressed as:
\[
z_{t} = S^{d}w_{t} = \sum_{j = 0}^{\infty}w_{t-j}.
\]

Hence, it can be said that ARIMA may be generated by \emph{summing} (or integrating) the stationary ARMA process \(w_{t}\), \(d\) times.\\

To sum up, ARIMA has \textbf{three steps}

\begin{enumerate}
  \item Derivate \(d\) times to \emph{remove} trend:
        \[
        w_{t} = (1-B)^{d} z_{t} = \nabla^{d}z_{t}.
        \]
  \item Apply stationary model ARMA to \(w_{t}\):
        \[
  w_{t} = \sum_{i = 1}^{p} \phi_{i}w_{t-i} + a_{t} - \sum_{j = 1}^{q} \theta_{j}a_{t-j}.
        \]
  \item Predict \emph{reversing} the derivation
        \[
 S^{d}w_{t} = \sum_{j = 0}^{\infty}w_{t-j}
        \]

\end{enumerate}

\subsubsection{SARIMA}

Having eliminated the Trend component, we would now like to estimate the \textbf{stationality} of the time series, assuming a multiplicative or additive relation. We perform the following extension of ARIMA.

\begin{ndef}
  Consider a non stationary model, which \textbf{stationality} component has period \(S\). Apply ARIMA to obtain a model that has \(S\) temporal units. Then, we obtain the \textbf{Seasonality ARIMA (SARIMA)}, of order \(S\):
  \[
    \Phi(B^{S})\nabla_{S}^{D}s_{t} = \Theta (B^{S}) \alpha_{t}.
  \]
\end{ndef}

It is common to assume that the stationality is \emph{multiplicative}, obtaining the model \emph{SARIMA \((p,d,q)\times (P,D,Q)\)}. This stational component modlules the width/module of the rest of the components of the time series.

\subsection{Exogenous variables}

There is an especial case in which we consider variables outside our model that directly affect our time series. To model this case, we use AR and MA models, and add extra coefficients to the already known equations. Let us define one of the models:

\begin{ndef}
  Consider an ARMA model. Adding exogenous variables to it result in the \textbf{ARMAX} model, which has the following expression:
  \[
    z_{t} = \sum_{i = 1}^{p}\phi_{i} \tilde z_{t-i} + a_{t} - \sum_{j = 1}^{q} \theta_{i}a_{t-j} - \sum_{k=1}^{r} \beta_{k} e_{t-k}.
  \]
\end{ndef}

The same way, \textbf{ARX,MAX,ARIMAX,SARIMAX} can be defined.

\section{Model selection and fitting. Box-Jenkins method.}

Now that we know all these fantastic models, we would like to apply them in time series analysis. We would like to choose which of the model \textbf{best fits} a time series data.

Firstly, we will introduce two defintions of functions that will be used to determine the best \emph{hyperparameters} of our models. Since our purpose is to look at the \emph{already-computed} functions, the following definitions will only give an intuitive idea and will not be very formal.

\begin{ndef}
The \textbf{autocorrelation function ACF} is the correlation between a signal and a delayed copy of the signal. It is useful for finding repeating patterns (periodicity) or missing fundamental frequency.
\end{ndef}

\begin{note}
Unit root processes, trend-stationary processes, AR and MA processes are specific forms of processes with autocorrelation.
\end{note}

\begin{ndef}
The \textbf{partial autocorrelation function (PACF)} gives the partial correlation of a stationary time series with its own lagged values, \emph{regressed the values of the time series at all shorter lags}. That is, eliminates the influence of other lag values.
\end{ndef}

With these two definitions, we proceed to describe the Box-Jenkins Method. We execute the following steps:

\begin{enumerate}
  \item Model class postulation. In this step, we select a family of models that we postulate our model will be in. As an example, we can consider \emph{linear model based filters}.

  \item Model identification: There are variations of what it should be done in this step. We will consider the following:
        \begin{enumerate}
          \item Identifying estacionarity:
                \begin{enumerate}
                  \item Trend: It can be detected by differenciating the time series and checking that the autocorrelation function is transformed to a constant function \(0\) in \(t = 0\) and \(0\) in the rest of times
                        \item Seasonality: Using the autocorrelation, we must find if there is a peak in the AFC in a specific time.
                \end{enumerate}
          \item Eliminating \emph{estationality and trend}

          \item Determining the type of stationary model that we will use, looking at the ACF signal. As a \textbf{guide}, Table \ref{acf:select:model} can be used.

                \begin{table}[H]
\begin{tabular}{l|l}
ACF                                                                  & Model                      \\ \hline
Exponential decay as \(|lag|\) increases                             & AR                         \\
Positive/negative decay as \(|lag|\) increases, or smoothed sinusoid & AR                         \\
A few peaks in shiftings (lags) that are not \(t = 0\)               & MA                         \\
Decay as \(|lag|\) increases with an initial \(lag_0\)               & ARMA                       \\
All values equal to zero and peak in \(t = 0\)                       & White Noise                \\
High values in fixed intervals                                       & Estationality component    \\
No decay to zero                                                     & Non stationary time series
\end{tabular}
\caption{Guide to select model using ACF.}
\label{acf:select:model}
\end{table}
        \end{enumerate}

\end{enumerate}

Having selected our model, we have to find the optimal hyperparameters \(p\) and \(q\) that best fit our data. Usually, we will use:

\begin{itemize}
  \item  \(p\) such that  the last \emph{important peak} in the PACF has \(p\) shifting.
        \item \(q\) such that  the last \emph{important peak} in the ACF  has \(q\) shifting.
\end{itemize}

There exist other theoretical estrategies that can be followed, but we will not explain them in this notes.

Lastly, it has to be mentioned that there are different measures that quantify the \emph{goodness} of the fitted model, such as the \textbf{Akaike Information criterion} or the \textbf{Bayesian Information criterion}.

\begin{note}
The exogenous-variable models may have some variations in the Box-Jenkins method.
\end{note}


\documentclass{article}

\usepackage{texing361}

\title{CS 361 Formula Mega Thread}
\author{Anonymous Comp}
\date{January 11, 2021}

\begin{document}

\maketitle

\section{TeXing361 Commands}
\begin{itemize}
    \item Set: $\set{1, 2, 3, \cdots}$
    \item Vector (Arrow): $\avec{a}$
    \item Vector (Bold): $\bvec{a}$
    \item Matrix: $\mat{A}$
    \item Eigenspace: $\eig_{2}\mat{A}$
    \item Determinant: $\det\mat{A}$
    \item Kernel: $\ker\mat{A}$
    \item Diagonal Matrix: $\diag{(1, 2, 3)}$
    \item Norm: $\norm{\bvec{a}}$
    \item Inner Product: $\vecdot{\avec{a}}{\avec{b}}$
    \item Expected Value: $\E{X}$
    \item Variance: $\V{X}$
    \item Covariance: $\Cov{X}$
    \item Argmin/Argmax: $\argmin{x}{f(x)}$
\end{itemize}

\newpage
\section{Common Probability Distributions \protect\footnote{Excerpted from \emph{Probability and Statistical Inference, 9th Edition}}}
    \subsection{Discrete}
        \begin{enumerate}[(a)]
            \item Bernoulli $(0 < p < 1)$
            $$
            \begin{aligned}
                & p(x) = p^x(1 - p)^{1 - x}, \;\;\;\; x = 0, 1 \\
                & M(t) = 1 - p + pe^t \\
                & \mu = p, \; \sigma^2 = p(1 - p) \\
            \end{aligned}
            $$

            \item Binomial $(0 < p < 1)$
            $$
            \begin{aligned}
                & p(x) = \binom{n}{x} p^x(1 - p)^{n - x}, \;\;\;\; x = 0, 1, \cdots, n \\
                & M(t) = (1 - p + pe^t )^n \\
                & \mu = np, \; \sigma^2 = np(1 - p) \\
            \end{aligned}
            $$

            \item Geometric $(0 < p < 1)$
            $$
            \begin{aligned}
                & p(x) = (1 - p)^{x - 1}p, \;\;\;\; x = 1, 2, \cdots \\
                & M(t) = \frac{pe^t}{1 - (1 - p)e^t}, \;\;\;\; t < -\ln{(1 - p)}\\
                & \mu = \frac{1}{p}, \; \sigma^2 = \frac{1 - p}{p^2}
            \end{aligned}
            $$

            \item Hypergeometric $(N_1 > 0, \; N_2 > 0, \; N = N_1 + N_2)$
            $$
            \begin{aligned}
                & p(x) = \frac{\binom{N_1}{x}\binom{N_2}{n - x}}{\binom{N}{n}}, \;\;\;\; x < N_1, \; n - x < N_2 \\
                & \mu = n\left(\frac{N_1}{N}\right), \; \sigma^2 = n\left(\frac{N_1}{N}\right)\left(\frac{N_2}{N}\right)\left(\frac{N - n}{N - 1}\right)
            \end{aligned}
            $$

            \item Negativebinomial $(0 < p < 1, \; r = 1, 2, 3, \cdots)$
            $$
            \begin{aligned}
                & p(x) = \binom{x - 1}{r - 1}p^r(1 - p)^{x - r}, \;\;\;\; x = r, r + 1, r + 2, \cdots \\
                & M(t) = \frac{(pe^t)^r}{[1 - (1 - p)e^t]^r}, \;\;\;\; t < -\ln{(1 - p)} \\
                & \mu = r\left(\frac{1}{p}\right), \; \sigma^2 = \frac{r(1 - p)}{p^2}
            \end{aligned}
            $$

            \item Poisson $(\lambda > 0)$
            $$
            \begin{aligned}
                & p(x) = \frac{\lambda^x e^{-\lambda}}{x!}, \;\;\;\; x = 0, 1, 2, \cdots \\
                & M(t) = e^{\lambda(e^t - 1)} \\
                & \mu = \lambda, \sigma^2 = \lambda
            \end{aligned}
            $$

            \item Uniform $(m > 0)$
            $$
            \begin{aligned}
                & p(x) = \frac{1}{m}, \;\;\;\; x = 1, 2, \cdots, m \\
                & \mu = \frac{m + 1}{2}, \sigma^2 = \frac{m^2 - 1}{12}
            \end{aligned}
            $$
        \end{enumerate}

    \subsection{Continuous}
        \begin{enumerate}[(a)]
            \item Beta $(\alpha > 0, \beta > 0)$
            $$
            \begin{aligned}
                & f(x) = \frac{\Gamma(\alpha + \beta)}{\Gamma(\alpha)\Gamma(\beta)}x^{\alpha - 1}(1 - x)^{\beta - 1}, \;\;\;\; 0 < x < 1 \\
                & \mu = \frac{\alpha}{\alpha + \beta}, \sigma^2 = \frac{\alpha\beta}{(\alpha + \beta + 1)(\alpha + \beta)^2}
            \end{aligned}
            $$

            \item Chi-square $(r = 1, 2, \cdots)$
            $$
            \begin{aligned}
                & f(x) = \frac{1}{\Gamma(r / 2) 2^{r / 2}}x^{r / 2 - 1}e^{-x/2}, \;\;\;\; 0 \leq x < \infty \\
                & M(t) = \frac{1}{(1 - 2t)^{r / 2}}, \;\;\;\; t < \frac{1}{2} \\
                & \mu = r, \sigma^2 = 2r
            \end{aligned}
            $$

            \item Exponential $(\theta > 0)$
            $$
            \begin{aligned}
                & f(x) = \frac{1}{\theta}e^{-x/\theta}, \;\;\;\; 0 \leq x < \infty \\
                & M(t) = \frac{1}{1 - \theta t}, \;\;\;\; t < \frac{1}{\theta} \\
                & \mu = \theta, \sigma^2 = \theta^2
            \end{aligned}
            $$

            \item Gamma $(\alpha > 0, \beta > 0)$
            $$
            \begin{aligned}
                & f(x) = \frac{1}{\Gamma(\alpha)\theta^\alpha}x^{\alpha - 1}e^{-x/\theta}, \;\;\;\; 0 \leq x < \infty \\
                & M(t) = \frac{1}{(1 - \theta t)^\alpha}, \;\;\;\; t < \frac{1}{\theta} \\
                & \mu = \alpha\theta, \sigma^2 = \alpha\theta^2
            \end{aligned}
            $$

            \item Normal $(-\infty < \mu < \infty, \sigma > 0)$
            $$
            \begin{aligned}
                & f(x) = \frac{1}{\sigma\sqrt{2\pi}}e^{-(x - \mu)^2 / 2\sigma^2}, \;\;\;\; -\infty < x < \infty \\
                & M(t) = e^{\mu t + \sigma^2t^2 / 2} \\
                & \E{X} = \mu, \V{X} = \sigma^2
            \end{aligned}
            $$

            \item Uniform $(a < b)$
            $$
            \begin{aligned}
                & f(x) = \frac{1}{b - a}, \;\;\;\; a < x < b \\
                & M(t) = \frac{e^{tb} - e^{ta}}{t(b - a)}, \;\;\;\; t \neq 0; \; M(0) = 1 \\
                & \mu = \frac{a + b}{2}, \sigma^2 = \frac{(b - a)^2}{12}
            \end{aligned}
            $$
        \end{enumerate}

\newpage
\section{Boilerplate}
    \subsection{Maximum Likelihood Estimation}
    \begin{itemize}
        \item Finding the likelihood function,
        $$
        \begin{aligned}
            \mathcal{L}(\Psi) &= \prod_{i = 1}^n f(x_i; \Psi)\\
            &= \prod_{i = 1}^n \frac{2}{\sqrt{\pi\Psi}}e^{-x_i^2/\Psi}\\
            &= \left(\frac{2}{\sqrt{\pi\Psi}}\right)^n\prod_{i = 1}^n e^{-x_i^2 / \Psi}.
        \end{aligned}
        $$
        \item Taking the natural log of both sides,
        $$
        \ln\mathcal{L}(\Psi) = n\ln\frac{2}{\sqrt{\pi\Psi}} - \frac{1}{\Psi}\sum_{i = 1}^n x_i^2.
        $$
        \item Taking derivative w.r.t $\Psi$ and set to zero,
        $$
        \frac{\text{d}}{\text{d}\Psi} \ln\mathcal{L}(\Psi) = \frac{2 \sum_{i = 1}^n x_i^2 - n \Psi }{2 \Psi ^2} = 0.
        $$
        \item Solving for $\Psi$,
        $$
        \boxed{\hat{\Psi} = \frac{2\sum_{i = 1}^n x_i^2}{n}}.
        $$
    \end{itemize}

    \subsection{Hypothesis Testing for Population Mean}
    \begin{itemize}
        \item Calculate test statistic
        If the population standard deviation is known,
        $$
        Z = \frac{\Bar{X} - \mu_0}{\sigma / n}.
        $$
        If population standard deviation is unknown,
        $$
        T = \frac{\Bar{X} - \mu_0}{s / n}
        $$
        where $s$ is the sample standard deviation.
        \item Determine the $p$-value by integration, table, or technology (or rejection region). Be careful with the underlying distribution you are choosing.
        \item Compare and reach a conclusion (reject or fail to reject).
    \end{itemize}

    \subsection{Code Highlight}
    \begin{itemize}
        \item Insert Code Block Directly
        \usemintedstyle{vs} % Or choose your own favourite
        \begin{minted}{python}
            import numpy as np

            def incmatrix(genl1, genl2):
                m = len(genl1)
                n = len(genl2)
                M = None # to become the incidence matrix
                VT = np.zeros((n * m, 1), int)  # dummy variable

                # compute the bitwise xor matrix
                M1 = bitxormatrix(genl1)
                M2 = np.triu(bitxormatrix(genl2), 1)
            ...
        \end{minted}
        \item Insert Code Block from External File
        \inputminted{python}{minted_example.py}
    \end{itemize}

\end{document}


\documentclass[a4paper,12pt]{article}
% decent example of doing mathematics and proofs in LaTeX.
% An Incredible degree of information can be found at
% http://en.wikibooks.org/wiki/LaTeX/Mathematics

% Use wide margins, but not quite so wide as fullpage.sty
\marginparwidth 0.1in
\oddsidemargin 0.05in
\evensidemargin 0.05in
\marginparsep 0.05in
\topmargin 0.05in
\textwidth 6in \textheight 8 in
% That's about enough definitions

\usepackage{amsmath, amsthm, amssymb, amsfonts}
\usepackage{mathtools}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\makeatletter
\renewenvironment{proof}[1][\proofname] {\par\pushQED{\qed}\normalfont\topsep6\p@\@plus6\p@\relax\trivlist\item[\hskip\labelsep\bfseries#1\@addpunct{.}]\ignorespaces}{\popQED\endtrivlist\@endpefalse}
\makeatother

\newtheoremstyle{break}
  {\topsep}{\topsep}%
  {\itshape}{}%
  {\bfseries}{}%
  {\newline}{}%
\theoremstyle{break}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}[theorem]{Definition}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\begin{document}

\title{Calculus of Multivariate Functions}
\author{Hyeonsu Lyu, Department of Electrical Engineering, UNIST}
\date{July 3, 2018}
\maketitle

\section{Inverse and Implicit function theorem}
\begin{theorem} [The inverse function theorem]
    \label{thm:InverseFunctionTheorem}
    Suppose $f$ is a $\mathcal{C}^1-mapping$ of an open set $E\subset \mathbb{R}^n$ into $R^n$. $f'(a)$ is invertible for some $a\in E$, and $b=f(a)$. Then,\\
    \indent (a)  there exists open sets $U$ and $V$ in $\mathbb{R}^n$ such that $a\in U, b\in V$, $f$ is one-to-one on $U$, and $f(U)=V$ \\
    \indent (b)  if $g$ is the inverse of $f$, [which exists, by (a)], defined in $V$ by
    \begin{align}
        g(f(x))=x\ \  (x\in U),
    \end{align}
    then $g\in \mathcal{C}(V).$
\end{theorem}

\begin{theorem} [The implicit function theorem]
    \label{thm:ImplicitFunctionTheorem}
    Let $f$ be a $\mathcal{C}^1-mapping$ of an open set $E\subset \mathbb{R}^{n+m}$ into $\mathbb{R}^n$, such that $f(a,b)=0$ for some point $(a,b)\in E$.\\
    \indent Put $A=f'(a,b)$ and assuem that $A_{\textit{x}}$ is invertible.\\
    \indent Then there exists open sets $U\subset \mathbb{R}^{n+m}$ and $b \in W$, habing the following property:\\
    \indent To every $y\in W$ corresponds a unique $x$ such that\\
    \begin{align}
        (x,y)\in\ U\ \ \ \ and \ \ \ f(x,y)=0.
    \end{align}
    \indent if this $x$ is defined to be $g(y)$, then $g$ is a $\mathcal{C}^1-mapping$ of $W$ into $\mathbb{R}^{n}$, $g(b)=a$,
    \begin{align}
        f(g(y),y)=0\ \ (y\in W),
    \end{align}
    \indent and
    \begin{align}
        g'(b)=-(A_x)^{-1}A_y.
    \end{align}
    \indent The function $g$ is “implicitly” defined by (4). Hence the name of the theorem.
\end{theorem}

\begin{proof} [Proof of theorem \ref{thm:InverseFunctionTheorem}]
    \indent (a) Put $f'(a)=A$, and choose $\lambda$ so that
    \begin{align}
        2\lambda\norm{A^{-1}}=1.
        \label{p1:1}
    \end{align}
    \indent since $f'$ is continuous at $a$, there is an open ball $U\subset E$, with center at $a$, such that
    \begin{align}
        \norm{f'(x)-A}<\lambda\ \ (x\in U).
        \label{p1:2}
    \end{align}
    We associate to each $y\in \mathbb{R}^n$ a function $\varphi$, defined by
    \begin{align}
        \varphi(x)=x+A^{-1}(y-f(x)) \ \ (x \in E)
        \label{p1:3}
    \end{align}
    Note that $f(x)=y$ if and only if x is a fixed point of $\varphi$.
    Since $\varphi'(x)=I-A^{-1}f'(x)=A^{-1}(A-f'(x))$, (\ref{p1:1}) and (\ref{p1:2}) imply that
    \begin{align}
        \norm{\varphi'(x)}<\frac{1}{2}\ \ (x\in U)
        \label{p1:4}
    \end{align}
    Hence
    \begin{align}
        |\varphi(x_1)-\varphi(x_2)|\leq \frac{1}{2}|x_1-x_2|\ \ \ \ (x_1,x_2 \in U),
        \label{p1:5}
    \end{align}
    Then, by contraction theorem, it follows that $\varphi$ has at most one fixed point in U, so that $f(x)=y$ for at most one $x\in U$.
    Thus $f$ is $1-1$ in $U$.

    Next, put $V=f(U)$, and pick $y_0 \in V$. Then $y_0=f(x_0)$ for some $x_0\in U$. Let $B$ be an open ball with center at $x_0$ and radius $r>0$, so small that its closure $\bar{B}$ lies in U. We will show that $y\in V$ whenever $|y-y_0|<\lambda r$. This proves that V is open. (This proves that every $y\in V$ is interior point.) \\

    Fix $y$, $|y-y_0| < \lambda r$. with $\varphi$ as in (\ref{p1:3}),
    \begin{align*}
        \varphi(x)-x_0|=|A^{-1}(y-y_0)|<\norm{A^{-1}}\lambda r=\frac{r}{2}.
    \end{align*}
    if $x \in \bar{B}$, it therefore follows from (\ref{p1:5}) that
    \begin{align*}
        \varphi(x)-x_0| &\leq |\varphi(x) - \varphi(x_0)|+|\varphi(x_0)-x_0| \\
        &<\frac{1}{2}|x-x_0|+\frac{r}{2}\leq r;
    \end{align*}
    hence $\varphi(x) \in B$. Note that (\ref{p1:5}) holds if $x_1,x2\in\bar{B}$.

    Thus $\varphi$ is a contraction of $\bar{B}$ into $\bar{B}$. Being a closed subset of $\mathbb{R}^n$, $\bar{B}$ is complete. By contraction theorem, $\varphi$ has a fixed point $x\in \bar{B}$. For this $x, f(x)=y$. Thus, $y\in f(\bar{B})\subset f(U)=V$.

    This proves part (a) of the theorem.

    (b) Pick $y\in V$, $y+k\in V$. Then there exists $x\in U$, $x+h \in U$, so that $y=f(x),y+k=f(x+h)$. With $\varphi$ as in (\ref{p1:3}),
    \begin{align}
        \varphi{x+h}-\varphi{x}=h+A^{-1}[f(x)-f(x+h)h-A^{-1}k.
        \label{p1:6}
    \end{align}
    by (\ref{p1:5}), $|h-A^{-1}k|\leq\frac{1}{2}|h|$. Hence $|A^{-1}k|\geq\frac{1}{2}|h|,$ and
    \begin{align}
        |h|\leq2\norm{A^{-1}}|k|=\lambda^{-1}|k|
        \label{p1:7}
    \end{align}

    By (\ref{p1:1}), (\ref{p1:2}) and theorem 9.8[Rudin], $f'(x) has an inverse, say T.$ Since
    \begin{align*}
        g(y+k)-g(y)-Tk=h-Tk=-T[f(x+h)-f(x)-f'(x)h],
    \end{align*}
    (\ref{p1:7}) implies
    \begin{align*}
        \frac{|g(y+k)-g(y)-Tk}{|k|}\leq\frac{\norm{T}}{\lambda} \cdot\frac{|f(x+h)-f(x)-f'(x)h|}{|h|}.
    \end{align*}

    As $k\to0$, (\ref{p1:7}) shows that $h\to0$. The right side of the last inequality thus tends to 0. Hence the same is true of the left. We have thus proved that $g'(y)=T$. But $T$ was chosen to be the inverse of $f'(x)=f'(g(y))$. Thus
    \begin{align}
        g'(y)={f'(g(y))}^{-1}\ \ \ (y\in V).
        \label{p1:8}
    \end{align}

    Finally, note that $g$ is a continuous mapping of V onto U (Since g is differentiable), that $f'$ is a continuous mapping of $U$ into the set $\Omega$ of all invertible elements of $L(\mathbb{R}^n$, and that inversion is a continuous mapping of $\Omega$ onto $\Omega$, by theorem 9.8[Rudin]. If we combine these facts with (\ref{p1:8}), we see that $g\in\mathcal{c}'(V)$.

\end{proof}

\end{document}