\documentclass{memoir}
\usepackage{linalg}

%
% Create Problem Sections
%

\newcommand{\enterProblemHeader}[1]{
    \nobreak\extramarks{}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
    \nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
}

\newcommand{\exitProblemHeader}[1]{
    \nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
    \stepcounter{#1}
    \nobreak\extramarks{Problem \arabic{#1}}{}\nobreak{}
}

\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\nobreak\extramarks{Problem \arabic{homeworkProblemCounter}}{}\nobreak{}

%
% Homework Problem Environment
%
% This environment takes an optional argument. When given, it will adjust the
% problem counter. This is useful for when the problems given for your
% assignment aren't sequential. See the last 3 problems of this template for an
% example.
%
\newenvironment{homeworkProblem}[1][-1]{
    \ifnum#1>0
        \setcounter{homeworkProblemCounter}{#1}
    \fi
    \section{Problem \arabic{homeworkProblemCounter}}
    \setcounter{partCounter}{1}
    \enterProblemHeader{homeworkProblemCounter}
}{
    \exitProblemHeader{homeworkProblemCounter}
}

\newcommand{\solution}{\textbf{\large Solution}}
% \begin{figure}[ht]
%     \centering
%     \incfig{riemmans-theorem}
%     \caption{Riemmans theorem}
%     \label{fig:riemmans-theorem}
% \end{figure}

\begin{document}
\chapter*{Practice Problems}
\section{1B}
\begin{homeworkProblem}
Suppose $a \in F$, $v \in V$, and $av = 0$. Prove that $a = 0$ or $v = 0$.
\end{homeworkProblem}
\begin{homeworkProblem}
	Suppose $v,w \in V$. Explain why there exists a unique $x \in V$ such that
	 \begin{align*}
		v + 3x = w.
	\end{align*}
\end{homeworkProblem}

\section{1C}
\begin{homeworkProblem}
	Show that the set of differentiable real-valued functions $f$ on the interval $(-4,4)$ such that
	\begin{align*}
		f'(-1) = 3f(2)
	\end{align*}
	is a subspace of $\R^{(-4,4)}$.
\end{homeworkProblem}
\begin{homeworkProblem}
	Suppose $b \in \R$. Show that the set of continuous real-valued functions $f $ on the interval $[0,1]$ such that $\int_0^{1}f = b$ is a subspace of $\R^{[0,1]}$ if and only if $b = 0$.
\end{homeworkProblem}
\begin{homeworkProblem}
	Give an example of a nonempty subset $U$ of $\R^2$ such that $U$ is closed under scalar multiplication, but $U$ is not a subspace of $\R^2$.
\end{homeworkProblem}
\begin{homeworkProblem}
	Suppose $U_1, U_2$ are subspaces of $V$. Prove that the intersection $U_1\cap U_2$ is a subspace of $V$.
\end{homeworkProblem}
\begin{homeworkProblem}
	Suppose
	\begin{align*}
		U = \{(x,x,y,y) \in F^{4} \mid x,y \in F \} .
	\end{align*}
	Find a subspace $W$ of $F^{4}$ such that $F^{4} = U \bigoplus W$.
\end{homeworkProblem}

\begin{homeworkProblem}
	Suppose
	\begin{align*}
	U = \left\{ (x,y,x+y,x-y,2x) \in F^{5} \mid x,y \in F \right\}
\end{align*}
	Find a subspace $W$ of $F^{5}$ such that $F^{5} = U \bigoplus W$ \\

	\color{gray}
	\textbf{Solution} \\

	Consider $W = \left( 0, 0, a, b, c \right) $, $a,b,c \in F$. First we show that $U+W = F^{5}$. Observe that any vector $(v,w,x,y,z) \in F^{5}$ can be written as $(v,w,v+w,v-w,2v) + (0, 0, x-v-w,y+w-v,z-2v)$, and therefore the sum of the spaces is equal to $F^{5}$. Now let $a \in U \cap W$. Because $a \in W$, the first two elements of $a$ must be $a = (0, 0, ?, ?, ?)$. But if $a \in U$, this implies that $x,y$ in any vector of $U$ must be zero. Then, $x+y = x-y = 2x = 0$. Therefore, $a = (0,0,0,0,0)$. This implies that $U \cap W = \left\{ 0 \right\} $, and therefore $U + W$ is a direct sum.

\end{homeworkProblem}

\section{2A}

\begin{homeworkProblem}
	Find a number $t$ such that
	\begin{align*}
	(3,1,4),(2,-3,5),(5,9,t)
	\end{align*}
	is not linearly independent in $\R^3$.\\

	\color{gray}
	\textbf{Solution} \\
	$t = 2$ guarantees that $(3,1,4),(2,-3,5),(5,9,t)$ is not linearly independent in $R^3$. It suffices to show that there are values $a,b,c \in \R$ such that $a(3,1,4) + b(2,-3,5) + c(5,9,2) = 0$, where $a,b,c$ are not all zero. Consider $a = -3, b = 2, c = 1$. Then $-3(3,1,4) + 2(2,-3,5) + (5,9,2) = (-9,-3,-12) + (4,-6,10) + (5,9,2)$. This can be rewritten as $(-9+4+5,-3-6+9,-12+10+2) = (0,0,0)$. Thus when $t=2$, the list is not linearly independent.
\end{homeworkProblem}

\begin{homeworkProblem}
	\textbf{(a)}\\
Show that if we think of $\C$ as a vector space over $\R$, then the list $(1+i,1-i)$ is linearly independent. \\

	\textbf{(b)} \\
	Show that if we think of $\C$ as a vector space over $\C$, then the list $(1+i, 1-i)$ is linearly dependent. \\

	\color{gray}
	\textbf{Solution}\\

	\textbf{(a)}\\
	Recall that we can write $1+i, 1-i$ as an ordered pair $(1,1), (1,-1)$ using addition and multiplication defined on $\C$. Now consider $a(1,1) + b(1,-1) = 0$, where $a,b \in \R$. But recall that $a = (a,0)$ and $b = (b,0)$. Then we can rewrite this as $(a,0)(1,1) + (b,0)(1,-1) = 0$. Then using the rules of multiplication on $\C$, we can rewrite this as $(a-0,a+0) + (b-0,b+0) = 0 \implies (a,a) + (b,-b) = 0$. Using our rules for addition on $\C$, this is equivalent to $(a+b,a-b) = 0 = (0,0)$. This implies that $a+b = 0 = a-b$. But $a+b = a-b \implies 2b = 0 \implies b = 0 \implies a = 0$ using addition on reals. Thus, $1+i, 1-i$ are linearly independent vectors in $\C$ over $\R$.\\

	\textbf{(b)} \\
	Let $(a,b), (c,d) \in \C, a,b,c,d \in \R$. It suffices to find an $(a,b), (c,d)$ such that $(a,b)(1,1) + (c,d)(1,-1) = 0$. Consider $(0,1),(1,0)$. Then $(0,1)(1,1) + (1,0)(1,-1) = (-1,1) + (1,1) = (0,0) = 0$, and because $(a,b), (c,d)$ were noth both zero, this implies that the list $(1+i, 1-i)$ is not linearly independent over $\C$.
\end{homeworkProblem}

\begin{homeworkProblem}
	Suppose $v_1,v_2,v_3,v_4$ is linearly independent in $V$. Prove that the list
	\begin{align*}
		v_1-v_2,v_2-v_3,v_3-v_4,v_4
	\end{align*}
	is also linearly independent.
\end{homeworkProblem}

\begin{homeworkProblem}
	Suppose $v_1,\ldots,v_m$ is linearly independent in $V$ and $w \in V$. Show that $v_1,\ldots,v_m,w$ is linearly independent if and only if
	\begin{align*}
		w \not\in \text{span}(v_1,\ldots,v_m)
	.\end{align*}
	\color{gray}
\textbf{Solution}\\
%\[
First, assume $v_1,\ldots,v_m,w$ is linearly independent. Assume for the sake of contradiction that $w \in \text{span}(v_1,\ldots,v_m)$. This implies that $w$ can be written as a linear combination of $v_1,\ldots,v_m$, and thus there exist $a_1,\ldots,a_m \in \R$ such that $a_1v_1+\ldots a_mv_m = w$. If all the coefficients are zero, then $w$ is zero, and zero cannot be linearly independent with any set of vectors. Then consider $-a_1v_1-\ldots-a_mv_m + w$. This is a linear combination of the vectors in the list, but by definition the first part is equivalent to $-w$. Then this sum would be zero, and thus there exists a linear combination of the list with coefficients not all zero that is zero. But then the list is not linearly independent, a contradiction. \\

Now assume $w \not\in \text{span}(v_1,\ldots,v_m)$. Now consider $a_1v_1+\ldots a_mv_m + a_{m+1}w = 0$, $a_i \in \R$. This can be rewritten as $a_1v_1+\ldots a_mv_m = -a_{m+1}w$. But if this is true, then because $-a_{m+1}$ is a scalar, this would imply that $w$ is in the span of the vectors. This contradicts our original assumption, so the only way for the equality to hold is if $-a_{m+1} = 0$, and then because $v_1,\ldots,v_m$ are linearly independent, they can only sum to zero if all their coefficients are zero. Thus, the list $v_1,\ldots,v_m,w$ is linearly independent.

%\]
\end{homeworkProblem}
\begin{homeworkProblem}
	Explain why there does not exist a list of six polynomials that is linearly independent in $P_4(F)$. \\
	\color{gray}

	 \textbf{Solution}\\

	 We showed in class that $\text{Span}\left( 1,x,x^2,x^3,x^{4} \right) = P_4(F)$. But we also showed that $\text{Span}\left( 1,x,x^2,x^3,x^{4} \right) = P_4(F)$ is the smallest subspace of  $P_4(F)$ that contains $1,x,x^2,x^3,x^{4}$. Thus, any other element of $P_4(F)$ can be written as a linear combination of those five polynomials.. So if we had a sixth polynomial $z$, we would simply find the linear combination of the other five variables that sum to $z$, then multiply them by $-1$. This would give us a linear combination of six polynomials that sum to zero where all coeffiencts are not zero, and thus, cannot be linearly independent in $P_4(F)$.

\end{homeworkProblem}
\begin{homeworkProblem}
	Explain why no list of four polynomials spans $P_4(F)$.
\end{homeworkProblem}
\begin{homeworkProblem}
	Recall that $V$ is infinite-dimensional if and only if there is a sequence $v_1,v_2,\ldots$ of vectors in $V$ such that $v_1,\ldots,v_m$ is linearly independent for every positive integer $m$. Then prove that $F^{\infty}$ is infinite-dimensional.\\
	\color{gray}

	\textbf{Solution}\\

	Consider the sequence of vectors $v_1,\ldots,v_m$, $m\in \N$ where $v_i = (0,\ldots,0,1,0,\ldots)$, the 1 being in the $i$-th position.  The only way $m$ such vectors can sum to zero is if all their coefficients are zero. This is clear because if the $i$-th position of the sum is zero, then $a_iv_i = \vec{0}$, as all other vectors have zero in that position, and thus the coefficient does not matter. But this is true for any $a_iv_i$, so the list is always linearly independent. But $m$ is chosen arbitrarily, and can be any positive integer. Thus the premise from 2A 14 holds, and thus $F^{\infty}$ is infinite-dimensional.
\end{homeworkProblem}

\section{2B}

\begin{homeworkProblem}
	\textbf{(a)}
	Let $U$ be the subspace of $\R^{5}$ defined by
	\begin{align*}
		U = \left\{ (x_1,x_2,x_3,x_4,x_5) \in \R^{5}\mid x_1=3x_2 \text{ and }x_3=7x_4 \right\}
	.\end{align*}
	Find a basis of $U$.\\

	\textbf{(b)}
	Extend the basis in (a) to a basis of $\R^{5}$.\\

	\textbf{(c)}
	Find a subspace $W$ of $R^{5}$ such that $R^{5} = U \bigoplus W$.\\

	\color{gray}
	\textbf{Solutions}\\

	\textbf{(a)}
	The list $(3,1,0,0,0),(0,0,7,1,0),(0,0,0,0,1)$ spans $U$ and is linearly independent. Linear independence is clear, as we have shown on multiple occasions (and in previous proofs) that lists where all elements have zero in an entry except one are linearly independent. Now we show it is a basis for $U$. Because for any linear combination of these vectors, the only ones that affect $x_1,x_2$ are the first element of the list, the ratio must hold,as multiplying by $\lambda \in \R$ will maintain the ratio. Likewise, this holds for $x_3,x_4$. So therefore span$(3,1,0,0,0),(0,0,7,1,0),(0,0,0,0,1)) \subset U$. To show the other direction, consider an arbitrary $(x_1,x_2,x_3,x_4,x_5) \in U$, that satisfies $x_1=3x_2$ and $x_3 = 7x_4$. Observe that $\frac{x_1}{3}(3,1,0,0,0) + \frac{x_3}{7}(0,0,7,1,0) + x_5(0,0,0,0,1) = (x_1,x_2,x_3,x_4,x_5)$. Thus every element in $U$ is an element of the span. This implies that the list given is a basis of $U$.\\

	\textbf{(b)}
	Adding the elements $(0,1,0,0,0)$ and $(0,0,0,1,0)$ to the previous list forms a basis of $\R^{5}$. Observe that any element $(x_1,x_2,x_3,x_4,x_5)$ can be written as $\frac{x_1}{3}(3,1,0,0,0) - (\frac{x_1}{3}-x_2)(0,1,0,0,0) + \frac{x_3}{7}(0,0,7,1,0) - (\frac{x_3}{7}-x_4)(0,0,0,1,0) + x_5(0,0,0,0,1)$. And because each of the elements in the list are in $\R^{5}$, and $\R^{5}$ is a vector space, then the span must also be in $\R^{5}$. Thus with these two elements it becomes a basis for $\R^{5}$.\\

	\textbf{(c)}
	$W = \text{span}((0,1,0,0,0),(0,0,0,1,0))$ is a subspace of $\R^{5}$ where $\R^{5} = U \bigoplus W$. Because the list are elements of $\R^{5}$ its span must be a subspace of $\R^{5}$. We have also already shown that $\R^{5}=U+W$ in part (b). All that remains to show is that the only element that intersects $U,W$ is the zero vector. Consider an arbitrary $x \in U,W$. Observe that because the first element of both of the elements in the basis of $W$ is zero, the first element of $x$ must also be zero. This implies that the coefficient of $(3,1,0,0,0)$ must also be zero. This implies that $x_2 = 0$. This forces the coefficient of  $(0,1,0,0,0)$ to be zero. This also follows for $x_3$, as both $x_3$ in the basis of $W$ is zero, so it forces the coefficient of  $(0,0,7,1,0)$ to be zero, forcing the rest of the elements to be zero. The same logic follows for $x_5$. Thus the only element that can be in both at once is $(0,0,0,0,0)$, proving that $U+W$ is a direct sum.
\end{homeworkProblem}

\begin{homeworkProblem}
	\textbf{(a)}
	Let $U$ be the subspace of $\C^{5}$ defined by
	\begin{align*}
		U = \left\{ (x_1,x_2,x_3,x_4,x_5) \in \C^{5}\mid 6x_1=x_2 \text{ and }x_3 + 2x_4 + 3x_5=0 \right\}
	.\end{align*}
	Find a basis of $U$.\\

	\textbf{(b)}
	Extend the basis in (a) to a basis of $\C^{5}$.\\

	\textbf{(c)}
	Find a subspace $W$ of $C^{5}$ such that $C^{5} = U \bigoplus W$.\\
\end{homeworkProblem}
\begin{homeworkProblem}
	Suppose $v_1,v_2,v_3,v_4$ is a basis of $V$. Prove that
	\begin{align*}
		v_1+v_2,v_2+v_3,v_3+v_4,v_4
	\end{align*}
	is also a basis of $V$.
\end{homeworkProblem}

\begin{homeworkProblem}
	Suppose $U$ and $W$ are subspaces of $V$ such that $V=U\bigoplus W$. Suppose also that $u_1,\ldots,u_m$ is a basis of $U$ and $w_1,\ldots,w_n$ is a basis of $W$. Prove that
	\begin{align*}
		 u_1,\ldots,u_m,w_1,\ldots,w_n
	.\end{align*}
	is a basis of $V$.\\

	\color{gray}
	\textbf{Solution}\\

	First, observe that the list is linearly independent. If the list were not linearly independent, then an element of $U$ could be written as a linear combination of elements in $W$ or vice versa. However, the only element in their intersection by definition is $\left\{ 0 \right\} $, so the linear combination has to have coefficients of all zero. Because $V = U\bigoplus W$, every element in $V$ can be written as a unique sum of elements of $U$ and $W$. But every element in $U$ can be expressed as a linear combination of $u_1,\ldots,u_m$ and every element in $W$ can be expressed as a linear combination of $w_1,\ldots,w_n$. So then any element in $V$ can be expressed as the sum of the linear combination of the two bases, and thus can be expressed as the span of $(u_1,\ldots,u_m,w_1,\ldots,w_n$. And because $U,W$ are subspaces of $V$, each element in the basis is an element of $V$, and so because $V$ is a subspace, span$(u_1,\ldots,u_m,w_1,\ldots,w_m)$ is contained in $V$. Therefore it is a basis for $V$.
\end{homeworkProblem}
\section{2C}
\begin{homeworkProblem}
	\textbf{(a)}
	Let $U = \{p \in P_4(F) \mid p(6) = 0 \}  $. Find a basis of $U$.\\

	\textbf{(b)}
	Extend the basis in part (a) to a basis of $P_4(F)$.\\

	\textbf{(c)}
	Find a subspace $W$ of $P_4(F)$ such that $P_4(F) = U \bigoplus W$.\\
\end{homeworkProblem}
\begin{homeworkProblem}
	\textbf{(a)}
	Let $U = \{p \in P_4(\R) \mid p''(6) = 0 \}  $. Find a basis of $U$.\\

	\textbf{(b)}
	Extend the basis in part (a) to a basis of $P_4(\R)$.\\

	\textbf{(c)}
	Find a subspace $W$ of $P_4(\R)$ such that $P_4(\R) = U \bigoplus W$.\\
\end{homeworkProblem}
\begin{homeworkProblem}
	\textbf{(a)}
	Let $U = \left\{ p \in P_4(F) \mid p(2) = p(5) \right\} $. Find a basis of $U$.\\

	\textbf{(b)}
	Extend the basis in part (a) to a basis of $P_4(F)$.\\

	\textbf{(c)}
	Find a subspace $W$ of $P_4(F)$ such that $P_4(F) = U \bigoplus W$.\\
\end{homeworkProblem}
\begin{homeworkProblem}
	\textbf{(a)}
	Let $U = \left\{ p \in P_4(F) \mid p(2) = p(5) = p(6) \right\} $. Find a basis of $U$.\\

	\textbf{(b)}
	Extend the basis in part (a) to a basis of $P_4(F)$.\\

	\textbf{(c)}
	Find a subspace $W$ of $P_4(F)$ such that $P_4(F) = U \bigoplus W$.\\
\end{homeworkProblem}

\begin{homeworkProblem}
	\textbf{(a)}
	Let $U = \left\{ p \in P_4(\R) \mid \int_{-1}^{1}p = 0 \right\} $. Find a basis of $U$.\\

	\textbf{(b)}
	Extend the basis in part (a) to a basis of $P_4(\R)$.\\

	\textbf{(c)}
	Find a subspace $W$ of $P_4(\R)$ such that $P_4(\R) = U \bigoplus W$.\\

	\color{gray}
	\textbf{Solutions}\\

	\textbf{(a)}
	Consider the list $\left\{ (x, x^3, 5x^{4}-1, 3x^2-1) \right\} $. First, we show it is linearly independent. In order to sum the elements to 0, the coefficient of $5x^{4}-1$ must be the negative of the coefficient of $3x^2-1$, otherwise the constant won't become zero. However, because they each contain a term of different degrees, the $x^{4},x^{2}$ terms cannot become zero. Thus, the coefficient of those terms must be zero, and likewise for $x,x^3$. Thus the list is linearly independent. \\

	Now we show that every element of the span of the list is in $U$. Let the elements of the list be referred to as $p_1,p_2,p_3,p_4$. Then consider $\int_{-1}^{1}(\lambda_1p_1+\lambda_2p_2+\lambda_3p_3+\lambda_4p_4)dx$, $\lambda_i \in \R$. Due to the laws of integration we can rewrite this as $\sum_{i=1}^{4} \lambda_i\int_{-1}^{1}(p_i)dx$. But each of those polynomials evaluates to zero over the interval, and so any linear combination of the four polynomials is in the set.\\

	Now we would like to show that any element in $U$ is an element of the span of our four vectors. Observe that the property placed on $U$ is equivalent to the statement that for $p(x) = ax^{4}+bx^3+cx^2+dx+e$, $\frac{2a}{5}+\frac{2c}{3}+2e = 0$, which can be seen by integration of the general $p(x)$ from -1 to 1. Every element of the list satisfies these properties, and contains every degree of polynomial from 1 to 5, with the constraint meaning that any constant must be written as a combination of $p_3,p_4$. Thus any polynomial that fits these constraints can be written as the coefficient multiplied by the respective degree element from the list, and the constraints will force the rest of the terms to be what is necessary for the property to hold. Thus, the list spans $U$, and so forms a basis. \\

	\textbf{(b)}
	Simply adding the vector $\left\{ 1 \right\} $ extends the basis to $P_4(\R)$. This is clear as for the coefficients $a,b,c,d$ of $p(x)$, they can be multiplied with the respective ratio to the elements of the previous list. This will result in a constant $e$, but to change the constant to an arbitrary one in $P_4(\R)$, simply choose the coefficient of $\left\{ 1 \right\} $ to be the one desired minus $e$. Thus this new basis covers $P_4(\R)$. And because the degree of this vector is zero, the argument for linear independence from (a) still holds. \\

	\textbf{(c)}
	W = span$(1)$ actually suffices as a subspace of $P_4(\R)$ such that $P_4(\R) = U \bigoplus W$. We have already shown that $P_4(\R) = U+W$ and because $W$ is a span of a list of linearly independent vector $W$ is a subspace, so all that remains to show is that it is a direct sum. Consider  $U\cap W$. Because $W$ has no polynomials, only constants, any terms with polynomials of degree 1 or more in $U$ must have a coefficient of zero, otherwise it cannot be an element of $U\cap W$. But all elements in $U$ have degree of 1 or more, so this means that all coefficients are zero, meaning the element must be zero. This implies that any element in the intersection must be zero, and thus, it is a direct sum.

\end{homeworkProblem}
\begin{homeworkProblem}
	Suppose $p_0,p_1,\ldots,p_m \in P(F)$ are such that each $p_j$ has degree $j$. Prove that $p_0,p_1,\ldots,p_m$ is a basis of $P_m(F)$.
\end{homeworkProblem}

\begin{homeworkProblem}
Suppose that $U$ and $W$ are subspaces of $\R^{8}$ such that $\text{dim}U = 3$, $\text{dim}W = 5$, and $U+W = \R^{8}$. Prove that $\R^{8} = U \bigoplus W$.\\

\color{gray}
\textbf{Solution}\\
%\[

First, observe that $\text{dim}\R^{8} = 8$, as per 2.37. Then we know that $8 = \text{dim}(U+W) = \text{dim}U + \text{dim}W - \text{dim}(U\cap W) = 3 + 5 - \text{dim}(U\cap W)$. Therefore $\text{dim}(U\cap W) = 0$ which implies that $U\cap W = \left\{ 0 \right\}$ which implies that $U+W$ is a direct sum, as desired.
%\]
\end{homeworkProblem}
\begin{homeworkProblem}
	Suppose $U$ and $W$ are both five-dimensional subspaces of $\R^{9}$. Prove that $U \cap W \neq \left\{ 0 \right\} $.\\

	\color{gray}
	\textbf{Solution}\\

	Again, by 2.37, $\text{dim}\R^{9} = 9$. Because $U,W$ are both subspaces of $\R^{9}$, $U+W \subset \R^{9}$, and so $\text{dim}(U+W) \leq 9$. We can also express this as $\text{dim}(U+W) = \text{dim}U + \text{dim}W - \text{dim}(U\cap W) = 5 + 5 - \text{dim}(U\cap W)$. Therefore, in order for the inequality to hold true, $\text{dim}(U\cap W) \geq 1$. But $\text{dim}\left\{ 0 \right\} = 0$, so the intersection cannot be solely zero.
\end{homeworkProblem}

\section{3A}
\begin{homeworkProblem}
	Suppose $b,c \in \R$. Define $T:P(\R)\to \R^2$ by
	\begin{align*}
		Tp = \left( 3p(4) + 5p'(6) + bp(1)p(2), \int_{-1}^{2} x^3p(x) \,d x + c \sin p(0) \right) .
	\end{align*}
	Show that $T$ is linear if and only if $b = c = 0$.
\end{homeworkProblem}

\begin{homeworkProblem}
	Suppose $T \in \mathcal{L}(F^{n},F^{m})$. Show that there exist scalars $A_{j,k}\in F$ for $j = 1,\ldots,m$ and $k = 1,\ldots,n$ such that
	\begin{align*}
		T(x_1,\ldots,x_n) = (A_{1,1}x_1 + \ldots + A_{1,n}x_n, \ldots, A_{m,1}x_1 + \ldots + A_{m,n}x_n)
	.\end{align*}
	for every $(x_1,\ldots,x_n) \in F^{n}$.\\

	\color{gray}
	\textbf{Solution}\\

	Consider some $T \in \mathcal{L}(F^{n},F^{m})$. Observe that because $T(\vec{0}) = 0$, this implies that $T(1,0,\ldots,0)$ must solely depend on $x_1$. This means that $T(1,0,\ldots,0)$ must be of the form $(a_1x_1,a_2x_1,\ldots,a_mx_1)$. There cannot be any fixed constant non-dependent on $x_1$, as if there were, then $T(\vec{0}) \neq 0$. Each $x_1$ term must be to the power of $1$, as if it were any other power, additivity would fail. Otherwise we cannot say anything about the coefficients of each $x_1$ beyond the fact that $a_i \in F$. Likewise, this argument applies to $T(0,1,0,\ldots,0) = (b_1x_2,b_2x_2,\ldots,b_mx_2)$ and so on for each entry of $x$. The span of each of these entries covers $F^{n}$, and so the output of any vector in $F^{n}$ must be a linear combination of these values. Thus, $T(x_1,\ldots,x_n) = \lambda_1(a_1x_1,\ldots,a_mx_1) + \ldots + \lambda_m(z_1x_m,\ldots,z_m,x_m)$. Rewriting these coefficients in the concise notation of $A_{ij}$ allows us to express this linear combination as $(A_{1,1}x_1 + \ldots + A_{1,n}x_n,\ldots,A_{m,1}x_1 + \ldots + A_{m,n}x_n)$ as desired.
\end{homeworkProblem}
\section{3B}
\begin{homeworkProblem}
	Show that
\begin{align*}
	 \left\{T \in \mathcal{L}(\R^{5},\R^{4}) \mid \text{dim null}T > 2 \right\}
\end{align*}
is not a subspace of $\mathcal{L}(R^{5},R^{4})$.
\end{homeworkProblem}
\begin{homeworkProblem}
	Give an example of a linear map $T:\R^{4}\to \R^{4}$ such that
	\begin{align*}
		\text{range}T = \text{null}T.
	\end{align*}
\end{homeworkProblem}
\begin{homeworkProblem}
	Suppose $v_1,\ldots,v_n$ spans $V$ and $T \in \mathcal{L}(V,W)$. Prove that the list $Tv_1,\ldots,Tv_n$ spans range$T$.
\end{homeworkProblem}

\begin{homeworkProblem}
	Suppose $T$ is a linear map from $F^{4}$ to $F^2$ such that
	\begin{align*}
		\text{null}T = \left\{(x_1,x_2,x_3,x_4) \in F^{4} \mid x_1 = 5x_2 \text{ and }x_3 = 7x_4 \right\} .
	\end{align*}
	Prove that $T$ is surjective.
\end{homeworkProblem}
\begin{homeworkProblem}
	Suppose $U$ is a 3-dimensional subspace of $\R^{8}$ and that $T$ is a linear map from $\R^{8}$ to $\R^{5}$such that $\text{null}T = U$. Prove that $T$ is surjective.
\end{homeworkProblem}
\begin{homeworkProblem}
	Prove that there does not exist a linear map from $F^{5}$ to $F^{2}$ whose null space equals
	\begin{align*}
		\left\{(x_1,x_2,x_3,x_4,x_5) \in F^{5} \mid x_1=3x_2 \text{ and }x_3=x_4=x_5 \right\} .
	\end{align*}
\end{homeworkProblem}

\begin{homeworkProblem}
	Suppose $V$ and $W$ are both finite-dimensional. Prove that there exists an injective linear map from $V$ to $W$ if and only if $\text{dim}V \leq \text{dim}W$.
\end{homeworkProblem}

\begin{homeworkProblem}
	Suppose $V$ and $W$ are both finite-dimensional. Prove that there exists an surjective linear map from $V$ to $W$ if and only if $\text{dim}V \geq \text{dim}W$.
\end{homeworkProblem}
\end{document}


\documentclass[12pt]{article}

\input{preamble}

\usepackage[auth-sc,affil-sl]{authblk}

\newcommand{\coursewebpage}{\href{https://github.com/kapelner/QC_Math_390.4_Spring_2020}{course homepage}}

\title{MATH 390.4 (soon to be 342W) Spring 2020 \\ Course Syllabus}

\author[]{Adam Kapelner, Ph.D.}

\affil[]{Queens College, City University of New York}
\settimeformat{ampmtime}
\date{\small document last updated \today ~\currenttime }

\begin{document}
\maketitle

\begin{table}[htp]
\centering
\begin{tabular}{rl}
Instructor & Professor Adam Kapelner \\
%Office & 604 Kiely Hall \\
Contact & \url{kapelner@qc.cuny.edu} \\
Lecture Time / Loc & Tues and Thurs 11AM - 12:50PM / KY 283 \\
Required Lab Time / Loc & Friday 9-10:50AM KY 061 \\
My Office Hours / Loc & Tues and Thurs 12:50-1:30PM  / Kiely 283 \\
TA Office Hours / Loc & TBA  / Kiely 5th fl lounge\\
Course Homepage & \href{https://github.com/kapelner/QC_Math_390.4_Spring_2019}{https://github.com/kapelner/QC\_Math\_390.4\_Spring\_2020} \\
\end{tabular}
\end{table}

\section*{Course Overview}

MATH 342W. Data Science via Machine Learning and Statistical Modeling. 6 hr.; 4 cr. Prereq.: MATH 241 (intro to probablity and statistics), MATH 231 (intro to linear algebra), CSCI 111 (intro to programming) or equivalents. Recommended: ECON 382 (intro to economentrics) or equivalent, MATH 341 (Bayesian modeling), MATH 633 (statistical inference) or equivalent. Philosophy of modeling and learning using data. Prediction via the ordinary linear model including orthogonal projections, sum of squares identity, $R^2$ and RMSE. Polynomial and interaction regressions. Prediction with machine learning including neural nets (the perceptron), support vector machines and the tree methods CART, bagged trees and Random Forests. Probability estimation using logistic regression, asymmetric cost classifiers and the ROC / DET performance curves. Underfitting vs. overfitting and the bias-variance decomposition / tradeoff. Model validation including out of sample techniques such as cross validation and bootstrap validation. Correlation vs. causation, causal models, lurking variables and interpretations of linear model coefficients. Extrapolation. The \texttt{R} language will be taught formally from the ground and up (its use will be a substantial part of the homework) as well as visualization using the \texttt{ggplot} library and manipulation using the \texttt{dplyr} and \texttt{data.table} libraries. \pagebreak

You should be familiar with the following before entering the class:

\begin{itemize}
\itemsep -0.0em
\item Basic Probability Theory: axioms, conditional probability, in/dependence
\item Modeling with discrete random variables: Bernoulli, Hypergeometric, Binomial, Poisson, Geometric, Negative Binomial, Uniform Discrete and others
\item Expectation and variance
\item Modeling with continuous random variables: Exponential, Uniform and Normal
\item Frequentist confidence intervals and hypothesis testing for one-sample proportions
\item Basic visualization of data: plots, histograms, bar charts
\item Linear algebra: Vectors, matrices, rank, transpose
\item Programming: basic data types, vectors, arrays, control flow (for, while, if, else), functions
\end{itemize}

\noindent We will review the above \textit{throughout the semester} when needed and we will do so rapidly. \\

\textbf{This is not your typical mathematics course.} This course will do lots of modeling of real-world situations using data via the \texttt{R} statistical language.

\section*{The 650.4 section}

You are the students taking this course as part of a masters degree in mathematics. Thus, there will be extra homework problems for you and you will be graded on a separate curve.

\section*{Course Materials}

We will be using many reference texts and three popular books which you will read portions from. However the main materials are the course notes. You should always supplement concepts from class by reading up on them online; \href{https://en.wikipedia.org}{wikipedia} I find the best for this.

\paragraph{Theory Reference:} It is not necessary to have these two books, but it is recommended. The first is \qu{Learning from Data: A Short Course} by Abu-Mostafa, Magdon-Ismael and Lin which can be purchased used on \href{https://www.amazon.com/Learning-Data-Yaser-S-Abu-Mostafa/dp/1600490069}{Amazon}. We will also be using portions from \qu{Deep Learning} by Goodfellow, Bengio and Courville that can be purchased on \href{https://www.amazon.com/Deep-Learning-Adaptive-Computation-Machine/dp/0262035618}{Amazon} and read for free at \url{http://www.deeplearningbook.org/}.

\paragraph{Popular Books:} We will also be reading the non-fiction novel \qu{The Signal and the Noise} by Nate Silver which can also be purchased on \href{https://www.amazon.com/Signal-Noise-Many-Predictions-Fail-but/dp/0143125087}{Amazon}. This is \textit{required} --- you will have homework questions directly from this book. We will also be reading \qu{Preditive Analytics, Data Mining and Big Data} by Steven Finlay that can be purchased on \href{https://www.amazon.com/Predictive-Analytics-Data-Mining-Misconceptions/dp/1349478687}{Amazon} and it is also available online from the \href{https://link-springer-com.queens.ezproxy.cuny.edu/book/10.1057%2F9781137379283}{Queens College library system}.

\paragraph{Computer Software:} You need your own personal computer, laptop preferred. We will be using \texttt{R} which is a free, open source statistical programming language and console available for all operating systems. Please download the latest version from: \url{http://cran.mirrors.hoobly.com/}. You will be expected to do programming. I recommend the IDE \texttt{RStudio} available for free at \url{https://www.rstudio.com/products/rstudio/download/}.

\paragraph{Source Control:} You will be expected to use \texttt{git} and have a \url{github.com} account with a repository named \texttt{QC\_MATH\_342}. You will use this repository to submit coding homework assignments (and theory assignments if you use \LaTeX).

\paragraph{Book on \texttt{R}:} We will be making use of \qu{R for Data Science} by Wickham and Grolemund which can be purchased on \href{https://www.amazon.com/R-Data-Science-Hadley-Wickham/dp/1491910399}{Amazon} or read online at \url{http://r4ds.had.co.nz/}.

\section*{Announcements}

Announcements will be made via email. I am known to send a couple emails per week on important issues. Thus, I will need the email address that you reliably check. The default is whatever is in CUNYfirst which many of you do not check. (See Homework \#0 for more information).

\section*{Classes}

There are 42 scheduled meetings. Of these, 25 will be lectures, 13 will be labs, 2 will be midterm exams which are in class and 2 will be review periods (the meeting before the exams). The exam schedule is given on page~\pageref{subsec:exam_schedule}.

I am \inred{canceling} Friday, April 17 (the Friday after the break which ends the day before) because many people will be away for the whole week returning the Monday after. We will do a makeup 2hr session at the end of the semester possibly during finals week to help with the projects.

\subsection*{Lectures}

Lectures will be in KY258 and will besplit into two periods: theory and practice. The first is a standard chalkboard lectue where we learn concepts and the second will be using the computer/projector to see the concepts in action in the \texttt{R} language. I have a no computer / tablet / phone policy during the theory component of the lectures (only pen / pencil and paper) but you are highly recommended to have the laptop during the second part.

Below is a tentative schedule of the theory and practice topics covered by lecture number.

\begin{enumerate}[(1)]
\item \textbf{Theory:} Review of syllabus, introducing science and modeling, definition of phenomena / the response $y$, reality vs. approximation, measurement vs. prediction and simulation, definition of learning from data, model validation, heuristics, ambiguous models, mathematical models, causal inputs, response spaces $\mathcal{Y}$, definition of features $\x$ and its feature space $\mathcal{X}$.

\textbf{Practice:} Short history of \texttt{R}, introduction to RStudio, arithmetic, assignment of variables, mathematical functions, logical operations, numeric / integer / boolean data types, vectors, sequences, subsetting, sorting, taxonomy of illegal values.

\item \textbf{Theory:} Feature spaces, binary, categorical and continuous data types, definition of metrics, ordinal codings, sample size $n$ vs. number of features $p$, error due to ignorance of information $\delta$, optimal response surface $f$, definition of training data $\mathbb{D}$, definition of candidate function set $\mathcal{H}$, definition of prediction function $g$, algorithms that produce prediction functions $\mathcal{A}$, definition of misspecification error, definition of optimal candidate function $h^*$, irreducible error $\mathcal{E}$, estimation error and residuals $e$.

\textbf{Practice:} Realizations of popular random variables, PDF / PMF / CDF / empirical CDF computations, quantile computations, factor-type variables, matrix data type and its critical functions, if / if-else / else / switch programmatic control, for / while / repeat loops, console printing, errors and warnings, try-catch control.

\item \textbf{Theory:} Visualization of training data $\mathbb{D}$, threshold models for classification, null model for classification $g_0$, concept of a parameter $\theta$ and parameter space $\Theta$, degrees of freedom, definition of objective function / error function, accuracy, sum of squared error (SSE), optimization within $\mathcal{A}$, linear threshold models, perception learning algorithm (PLA), introduction to neural networks.

\textbf{Practice:} Review of hashing and the list data type, the array data type for general tensors, naming for vectors / matrices / tensors, introduction to specifying functions, arguments, argument defaults, creating data matrices, tabling multiple features, the dataframe data type.

\item \textbf{Theory:} Review of lines in multiple dimensions with Hesse Normal Form, derivation of the support vector machine (SVM) using maximum margin objective, hinge error, SVM using the Vapnik objective, defintion of hyperparameters $\lambda$, $K$-nearest neighbors algorithm (KNN).

\textbf{Practice:} Installing and loading libraries from CRAN and githuv, public vs private functions and scoping, loading datasets from libraries / files / URLs, creating threshold models, writing the PLA, matrix operations: arithmetic / transpose / inverse / rank / trace, optimization algorithms e.g. Nelder-Mead, writing the KNN algorithm, using the SVM library and setting the hyperparameter.

\item \textbf{Theory:} Null model for regression $g_0$, linear models for continuous responses $\bbeta$, minimization of SSE for $p=1$ using basic calculus to arrive at the ordinary least squares (OLS) solution $\b$, review of covariance of two random variables $\sigma_{X,Y}$ and its estimate $s_{X,Y}$, review of correlation $\rho_{X,Y}$ and its estimate $r_{X,Y}$.

\textbf{Practice:} Computing sample covariance and correlation in the context of the OLS algorithm for $p=1$, computing OLS error metrics, the formula object, using the \texttt{lm} function, visualizing the OLS line atop a scatterplot, computing predictions in OLS, OLS in the boston housing data

\item \textbf{Theory:} Error metrics for regression: SSE, mean squared error (MSE) and root mean squared error (RMSE), approximate prediction confidence intervals using RMSE, sum of squares total (SST), concept of proportion of variance explained $R^2$, class of models with $R^2 < 0$, perfect fit models with $R^2 = 1$.

\textbf{Practice:} OLS on the Galton height data and the etymology of the word \qu{regression} in statistics, computing OLS in the case of categorical variables (ANOVA), dummifying variables, computing model matrices.

\item \textbf{Theory:} OLS estimates being the group averages with one binary feature, independence, dependence, association, correlation, OLS estimates with $p>1$, design matrix $X$, vector derivative properties: constant scalars, multiples, multiplication, quadratic forms, general OLS solution, review of matrix inverses, transposes, rank and symmetric matrices.

\textbf{Practice:} Visualizing $R^2$ for a model using error density estimation, computing general OLS estimates in multiple dimensions from scratch, making predictions using the \texttt{predict} interface for modeling.

\item \textbf{Theory:} OLS predictions as linear transformations, review of the linear algebra concepts of dimension, length, norm, subspace, linear in/dependence, column space, derivation of the orthogonal projection matrix for one dimension via law of cosines, outer products, idempotency.

\textbf{Practice:} Eigendecomposition, computing error metrics for general OLS, computing the null model.

\item \textbf{Theory:} Derivation of the orthogonal projection in multiple dimensions, equivalence of the OLS algorithm with orthongal projection, definition of the hat matrix $H$, review of the linear algebra concepts of eigenvectors and eigenvalues, computing the eigenvectors and eigenvectors of $H$.

\textbf{Practice:} Computing the hat matrix $H$ for the null model and in general, confirming its eigendecomposition and idempotency and rank, using $H$ to find the OLS predictions and residuals and verifying their orthogonality.

\item \textbf{Theory:} Verification of the symmetry and idempotency of $H$, proving that one multidimensional orthogonal projection is in general not the same as the sum of orthogonal projections in the component dimensions except if the component dimensions themselves are orthogonal, review of orthonormal matrices $Q$, proving the equivalence of $H = QQ^\top$, definition of $X = QR$ decomposition, the Gram-Schmidt algorithm, computing $R$, deriving the least squares estimate using $Q$ and $R$.

\textbf{Practice:} Computing $QR$ decomposition and confirming the orthonormality of $Q$, verifying the OLS predictions are the same with $Q$, writing the Gram-Schmidt algorithm, an overview of the piping / chaining concept in modern programming and in \texttt{R} with demos.

\item \textbf{Theory:} Definition of sum of squares for the regression $SSR$, proving the sum of squares identity $SST = SSR + SSE$, showing that if $p$ increases by one dimension, then SSR is obligated to increase forcing $R^2$ higher, definition of overfitting in modeling, definition of chance capitalization, demonstrating that full overfitting in OLS leads to $H = I$, a superficial introduction to regularization (lasso regression and ridge regression).

\textbf{Practice:} Demo showing the iterative addition of a feature and $R^2$ monotonically increasing and RMSE monotonically decreasing (overfitting), demonstrating that random vectors are never truly orthogonal and thus their projections are non-zero, a lasso fit and a ridge fit of a dataset with $p \geq n$.

\item \textbf{Theory:} Definition of in-sample error metrics vs. out-of-sample (oos) error metrics, splitting $\mathbb{D}$ into $\mathbb{D}_{\text{train}}$ and $\mathbb{D}_{\text{test}}$ via split constant $K$, definition of \qu{honest} validation via oos error metrics, definition of the final model $g_{\text{final}}$ definition of underfitting, tracing the underfitting-overfitting complexity curve, definition of optimal-complexity models.

\textbf{Practice:} A more full demo of overfitting with visualizations, demo of consistency of OLS estimates, code to create train-test splits, demonstration that oos error is larger than in-sample error in the scenario of the model being overfit.

\item \textbf{Theory:} Definition of raw features versus derives features, increasing complexity in $\mathcal{H}$ using polynomial functions of raw features, interpretation of OLS coefficients $\b$, Weierstrauss Approximation Theorem, OLS with polynomial features, definition of the full rank Vandermonde matrix, definitions of interpolation vs. extrapolation.

\textbf{Practice:} Square, cube and higher order polynomial fitting both raw and orthogonal with visualization, overfitting with high-degree polynomials, demonstration of extrapolation in models of many different polynomial degrees, prediction with polynomial models, extrapolation in the Galton height data.

\item \textbf{Theory:} OLS using the log transformation on both features and response and interpretation of $\b$, derivation the log change is approximately percentage change, definition of first-order interactions in OLS, interpretations of coefficients in interaction models.

\textbf{Practice:} Log-linear model fitting and log-log linear model fitting, logging response to reduce the effect of influential observations, the grammar of graphics and the \texttt{ggplot} package to create histograms, scatterplots, box-whisker, violin plots, smoothing plots, overloading plots with many features, faceting, coloring, aesthetics and themes, using color illustrations and faceting to visualize potential first-order interactions in a linear model, fitting interaction models.

\item \textbf{Theory:} oos error metrics as estimates of model generalization error, sources of variance in these estimates, mitigation by adjusting $K$, further mitigation by using cross-validation (CV), $K$-fold CV and its aggregated error estimates, approximation confidence intervals for generalization error, discussion of reasonable values of $K$ in practice.

\textbf{Practice:} Simulating many different train-test splits to underscore that $K$ trades bias vs. variance in the generalization estimate, writing code for $K$-fold CV, using the package \texttt{mlr3} to automate $K$-fold CV.

\item \textbf{Theory:} Introduction of the fundamental problem of \qu{model selection} of candidates $g_1, \ldots, g_M$, model selection with honest validation via splitting $\mathbb{D}$ into $\mathbb{D}_{\text{train}}$, $\mathbb{D}_{\text{select}}$ and $\mathbb{D}_{\text{test}}$ via split constants $K_{\text{select}}$ and $K_{\text{test}}$, procedure to select best model among $M$ candidates and validation of the best model.

\textbf{Practice:} Writing code for the model selection procedure, review of basic \texttt{C++}, optimizing \texttt{R} code via the \texttt{Rcpp} package, benchmarking routines that require heavy looping between \texttt{Rcpp} and base \texttt{R}, benchmarking routines that require heavy recursion between \texttt{Rcpp} and base \texttt{R}.

\item \textbf{Theory:} Double-CV in the model selection procedure using inner folds and outer folds, discussion of reasonable values of $K_{\text{select}}$ and $K_{\text{test}}$ in practice, applying the model selection procedure to grid searching to locate the best value of hyperparameters $\lambda$ in algorithms that require $\lambda$, definition of stepwise modeling using the model selection procedure via the underfitting-overfitting complexity curve concept, stepwise OLS with a large basis of candidate terms.

\textbf{Practice:} Using the package \texttt{mlr3} to automate the double-CV using inner and outer loops, using the package \texttt{mlr3} to automate the locating of optimal hyperparameters, demo of forward stepwise linear modeling and tracing the underfitting-overfitting complexity curve.

\item \textbf{Theory:} Definition of hyperrectangle basis for $\mathcal{X}$ and its OLS solution, unfeasibility of this algorithm in high $p$, introduction of the regression tree algorithm.

\textbf{Practice:} Binning model demo and visualization for varying bin sizes, introduction to data wrangling using the packages \texttt{dplyr} and \texttt{data.table}: filtering, sorting, grouping, summarizing, feature derivation, dataframe joining (left, right, inner, full, between / overlap), benchmarking the two libraries.

\item \textbf{Theory:} Full specification of regression tree algorithm: definition of a binary tree, definition of orthogonal-to-axes splits, nodes vs. leaves, left-right SSE weighting, leaf assignments, overfitting and tree-pruning.

\textbf{Practice:} Using the \texttt{YARF} package to produce regression trees, querying tree stats, visualizing trees and tree model predictions, tree differences by the pruning hyperparameter.

\item \textbf{Theory:} MSE of $g$ decomposition into bias and irreducible error for one $\mathbb{D}$, MSE of $g$ decomposition into bias, irreducible error and variance for multiple $\mathbb{D}$'s, MSE decomposition of $M$ different $g$'s averaged, strategies to eliminate bias and variance, non-parametric bootstrap sampling, Breiman's concept of bootstrap aggregation (bagging), correlation $\rho$ among the bootstrapped models, out-of-bag (oob) observations, validation in bagging via oob samples.

\textbf{Practice:} Visualizing $M$ bagged trees, demonstrating near zero bias, demonstrating variance reduction as $M \rightarrow \infty$, a comparison to OLS and high degree polynomial models, demonstration of generalization error improvement, demonstration of validation in bagging.

\item \textbf{Theory:} Demonstrating the bias for regression trees is near zero, reducing correlation among the bootstrapped models using feature sampling, introduction of random forests (RF) algorithm.

\textbf{Practice:} Demonstration that RF decreases $\rho$ and demonstration that it outperforms bagging in both regression and classification.

\item \textbf{Theory:} A basic discussion of \qu{causality} from a philosophical perspective, directed causal graphs, correlation vs. causation, incidental effects, lurking variables, spurious correlation, causation is defined by manipulation, a quick definition of randomized experimentation, real-world causal diagrams, wrong interpretations of $\b$ in OLS, the highly limited but true / complete paragraph-long interpretation of $\b$ in OLS, a discussion of how OLS regression accomplishes estimation of single features with other features \emph{ceteris paribus}.

\textbf{Practice:} Demos of whimsical spurious correlations, demonstration that spurious correlations are easy to find in simulation, a nice illustration of correlation without causation using an OLS model that reveals the true interpretation of $\b$.

\item \textbf{Theory:} Introduction of classification tree algorithm, the gini metric, leaf assignments, the two errors: false negatives and false positives, the 2$\times$2 confusion matrix and its metrics: precision, recall, accuracy, $F_1$ metric, false discovery rate, false omission rate.

\textbf{Practice:} Using the \texttt{YARF} package to produce classification trees, querying tree stats, visualizing trees and tree model predictions, tree differences by the pruning hyperparameter, measuring the two errors, computing confusion matrices and the other metrics.

\item \textbf{Theory:} Missing data mechanisms (MDMs): missing completely at random, missing at random, not missing at random with examples, strategies to handle missingness: listwise deletion, imputation, multiple imputation, miss forests algorithm and its convergence, the concept of \qu{retaining} missingness even after imputation, introduction of probability estimation using the independent bernoulli random variable model, optimal probability function, likelihood of $\mathbb{D}$, $\mathcal{H}$ for probability functions, generalized linear modeling, link functions: logistic / probit / complementary log-log, numerical approximations to the likelihood optimization.

\textbf{Practice:} An example of a dataset with missingness, assessing the different MDMs, listwise deletion, imputation and the \texttt{missForest} package for the recommended imputation, creating the missingness dummies as derives features in $X$.

\item \textbf{Theory:} Definition of logistic regression (LR), log-odds interpretation of LR $\b$, prediction in LR, error metrics for probability estimation: Brier and Log scoring rules, classification modeling from probability regression, optimal asymmetric cost modeling, response-operator curves (ROC), detection-error tradeoff curves (DET).

\textbf{Practice:} Fitting LR models using the \texttt{glm} package, predicting with LR models, validating creating asymmetric cost classifiers in LR models, constructing ROC and DET plots using LR models, locating optimal models with minimal cost.
\end{enumerate}

\subsection*{Labs}

Labs  will be in KY061 (the computer lab) duiring the Friday morning meetings. Sometimes we will spend some of the two hours doing a practice lecture but the majority of this time will be your time. You will take turns \qu{driving} the coding in front of the class, working on exercises that you will finish for homework. Thus we will spend most a lot of time talking through problem solving skills in data science.

\subsection*{Lecture Upload}

As many previous students have noted, my handwritten notes are useful to me and not to many others. Thus, I will be rewarding students for taking notes, scanning them in and sending them to me. You will be rewarded in two ways: (1) if you do this for more than 10 lectures, you will be given the automatic 5 points (see grading policy on page \pageref{sec:grading}) for your classroom participation grade and (2) you have the option for me to say your name publicly on the \coursewebpage. Make sure you follow these instructions:

\begin{itemize}
\item You have \emph{one week only} from the time of the lecture to email me lecture notes.
\item There must be \emph{one} file and it must be in PDF format only.
\item The file must be $<$2MB. No exceptions.
\item Email it to me only at \texttt{kapelner@qc.cuny.edu}. I will not upload it otherwise.
\end{itemize}

If you send me your notes, you are (1) agreeing to the \href{https://github.com/kapelner/QC_Math_390.4_Spring_2020/blob/master/LICENSE}{MIT license} which means someone can freely copy your notes and even make money off of it (and not owe you a cent!) and (2) since github is mirrored, once your upload is on the web, it is there indeliby forever. \inred{If you are not comfortable with these two points, do not send me your notes.}

\section*{Homework}

Homework will be split into \textit{theory} and \textit{practice} (called \qu{labs}). This course will be the \qu{writing in the major course} next year. Thus, a portion of each theory and practice homework will involve writing \textit{English} and being graded on \textit{English}.

\subsection*{Theory Homework}

There will be 4-7 theory homework assignments. Homeworks will be assigned and placed on the \coursewebpage~ and will usually be due a week later in class. Homework will be \textbf{graded} out of 100 with extra credit getting scores possibly $> 100$. I will be doing the grading and will grade an \textit{arbitrary subset of the assignment} which is determined after the homework is handed in. Homework must be printed, neat and stapled (\textbf{it cannot be emailed to me}) but if you use \LaTeX~it can be pushed to your own repository (see \qu{Homework \LaTeX~bonus points} section below) and I will grade it digitally. Homework can be given to me in class or delivered under my office door (KY 604).

Graded homework will be returned in class. Regrades are handled during office hours or right after class is over. Scores for homeworks are finalized one week after the graded copies are handed back. Thereafter there will be no changes and no re-grading. Do not delay checking your graded homeworks. I am not perfect and I do make mistakes. It is your obligation to find these mistakes and report them.

You are encouraged to seek help from me if you have questions. After class and office hours are good times. \ingreen{You are highly recommended to work with each other and help each other.} \inred{You must, however, submit your own solutions, \textit{with your own write-up} and in \textit{your own words}. There can be no collaboration on the actual \textit{writing}. Failure to comply will result in severe penalties.} The university honor code is something I take seriously and I send people to the Dean every semester for violations.

\subsection*{Practice Homework (Labs)}

These will almost exclusively consist of short and medium coding exercises in \texttt{R}. Most of the assignment will be done for you and your peers during the Friday lab session.

\subsection*{Philosophy of Homework and Labs}

Homework is the \textit{most} important part of this course.\footnote{In one student's \href{http://www.ratemyprofessors.com/ShowRatings.jsp?tid=1951051}{observation}, I give a \qu{mind-blowing homework} every week.} Success in Statistics and Mathematics courses comes from experience in working with and thinking about the concepts. It's kind of like weightlifting; you have to lift weights to build muscles. My job as an instructor is to provide assistance through your \href{http://en.wikipedia.org/wiki/Zone_of_proximal_development}{zone of proximal development}. With me, you can grow more than you can alone. To this effect, homework problems are color coded \ingreen{green} for easy, \inyellow{yellow} for harder, \inred{red} for challenging and \inpurple{purple} for extra credit. You need to know how to do all the greens by yourself. If you've been to class and took notes, they are a joke. Yellows and reds: feel free to work with others. Only do extra credits if you have already finished the assignment. The \qu{[Optional]} problems are for extra practice --- highly recommended for exam study.

\subsection*{Time Spent on Homework }

This is a four credit course. Thus, the amount of work outside of the 4hr in-class time per week is 8-12 hours. I will aim for 10hr of homework per week on average. However, doing the homework well is your sole responsibility since I will make sure that by doing the homework you will study and understand the concepts in the lectures and you won't have all that much to do when the exams roll around.

\subsection*{Late Homework}

Late homework will be penalized 10 points per business day (Monday--Friday save holidays) for a maximum of five days. \textit{Do not ask for extensions}; just hand in the homework late. After five days, \textbf{you can hand it in whenever you want} until May 15 at noon. As far as I know, this is one of the most lenient and flexible homework policies in college. I realize things come up. Do not abuse this policy; you will fall far, far behind.

\subsection*{\LaTeX~Homework Bonus Points}

Part of good mathematics is its beautiful presentation. Thus, \ingreen{there will be a 1--7 point bonus} added to your theory homework grade  for typing up your homework using the \LaTeX ~typesetting system based on the elegance of your presentation. The bonus is arbitrarily determined by me.

I recommend using \href{http://overleaf.com}{overleaf} to write up your homeworks (make sure you upload both the hw\#.tex and the preamble.tex file). This has the advantage of (a) not having to install anything on your computer and thus not having to maintain your \LaTeX ~installation (b) allowing easy collaboration with others (c) alway having a backup of your work since it's always on the cloud. If you insist to have \LaTeX ~running on your computer, you can download it for Windows \href{http://www.miktex.org/download}{here} and for MAC \href{http://www.tug.org/mactex/}{here}. For editing and producing PDF's, I recommend \TeX works which can be downloaded \href{http://www.tug.org/texworks/#Getting_TeXworks}{here}. Please use the \LaTeX ~code provided on the \coursewebpage ~for each homework assignment.

If you are handing in homework this way, read the comments in the code; there are two lines to comment out and you should replace my name with yours and write your section. The easiest way to use overleaf is to copy the raw text from hwxx.tex and preamble.tex into two new overleaf tex files with the same name. If you are asked to make drawings, you can take a picture of your handwritten drawing and insert them as figures or leave space using the \qu{$\backslash$vspace} command and draw them in after printing or attach them stapled.

Since this is extra credit, do not ask me for help in setting up your computer with \LaTeX~ in class or in office hours. Also, \textbf{never share your \LaTeX~code with other students} --- it is cheating and if you are found I will take it seriously.

\subsection*{Homework Extra Credit}

There will be many extra credit questions sprinkled throughout the homeworks. They will be worth a variable number of points arbitrarily assigned based on my perceived difficulty of the exercise. Homework scores in the 140's are not unheard of. They are a good boost to your grade; I once had a student go from a B to and A- based on these bonuses.

\subsection*{Homework \#0}

For your first homework, you must:

\begin{enumerate}[(1)]
\item email me at \href{kapelner@qc.cuny.edu}{kapelner@qc.cuny.edu} from the email address you wish to be contacted at for this course (most commonly this is a gmail address),
\item in the email, you must say \qu{My name is $<$Your Full Name as appears in the registrar$>$ and I have read and understand all the material in the course syllabus} and
\item provide a link to your public repository on github (this means you need to sign up for github first)
\end{enumerate}

\noindent \inred{This constitutes a contract --- you are agreeing to this syllabus.} \\

This assignment is due Friday, Jan 31, noon and will receive a grade of 0 or 100 with the usual 10 point penalty for lateness.

\section*{Writing Assignments}

There will be two writing assingments. (1) A \qu{philosophy of modeling} essay. Here you will coalesce the non-mathematical material that is crucial to this class. The purpose is to make you truly understand the modeling process and its limitations from start to finish. (2) A final project. Here you will use build a predictive model using a dataset. This is the capstone project for the entire data science and statistics major and it is where you will tie everything together.

This class will soon be the writing in the major course. Thus, writing is a major part of the curriculum herein.

\section*{Examinations}

Examinations are solely based on homeworks (which are rooted in the lectures)! If you can do all the green and yellow problems on the homeworks, the exams should not present any challenge. I will \textit{never} give you exam problems on concepts which you have not seen at home on one of the weekly homework assignments.

Since the is the capstone course, there is no final exam, but a large final project. There will be two midterm exams and the schedule is below.

\subsection*{Exam and Major Assignment Schedule}\label{subsec:exam_schedule}

\begin{itemize}
\itemsep -0.0em
\item Midterm examination I will be Thurs, March 12 in class with the first review session on the Tuesday prior
\item Midterm examination II will be Tues, May 12 in class with a review on the Friday prior
\item The philosophy of modeling paper is due Tues, Mar 24 at 11:59PM
\item The final project is due Sat, May 23 11:59PM by email
\end{itemize}

\subsection*{Exam Materials}

I allow you to bring any calculator you wish but it cannot be your phone. The only other items allowed are pencil and eraser. I do not recommend using pen but it is allowed.

I also allow \qu{cheat sheets} on examinations. For both midterms, you are allowed to bring \ingreen{two} 8.5'' $\times$ 11'' sheet of paper (front and back). \inred{Four sheets single sided are not allowed.} On this paper you can write anything you would like which you believe will help you on the exam. %For the final, you are allowed to bring three 8.5'' $\times$ 11'' sheet of paper (front and back). \inred{Six sheets single sided are not allowed.} I will be handing back the cheat sheets so you can reuse your midterm cheat sheets for the final if you wish.

\inred{Food is not allowed during exams but beverages are allowed.}

%
%\subsection*{Cheating on Exams}
%
%If I catch you cheating, you can either take a zero on the exam, or you can roll the dice before the University Honor Council who may choose to suspend you.

\subsection*{Missing Exams}

There are no make-up exams. If you miss the exam, you get a zero. If you are sick, I need documentation of your visit to a hospital or doctor. Expect me to call the doctor or hospital to verify the legitimacy of your note. %If you need to leave the country for an emergency, I will expect proper documentation as well.

\subsection*{Special Services}

If you are a student who takes exams at the special services center, I need to see your blue slip one week before the exam to make proper arrangements with the center.

\section*{Class Participation (and attendance)}

I will be taking attendance selectively throughout the semester. Attendance counts towards the class participation portion of your grade in equal part with how often you ask and answer questions during the lecture.

\section*{Grading and Grading Policy}\label{sec:grading}

Your course grade will be calculated based on the percentages as follows:

\begin{table}[h]
\centering
\begin{tabular}{l|l}
Theory Homework & 9\% \\
Labs & 13\% \\
Class participation & 5\% \\
Midterm Examination I & 18\%\\
Midterm Examination II & 18\%\\
Philosophy of Modeling Paper & 7\% \\
Final Project with Writeup & 30\%
\end{tabular}
\end{table}
\FloatBarrier

\noindent The second midterm is not cumulative. It only covers material \textit{after} midterm I.

%Each of the periods is assessed evenly. Thus, each period must count the same towards your grade. Since there is 75\% of the grade allotted to exams, there is 25\% allotted to each period. Thus, the final is upweighted towards the material covered in the third period. In summary, the final will have 5/35 points $\approx$ 14\% for the first period's material, 5/35 points $\approx$ 14\% for the second period's material and 25/35 points $\approx$ 71\% for the last period's material. A good strategy for the final is to just study the material after Midterm II and minimal studying for the previous material.

\subsection*{The Grade Distribution}

As this is a small and advanced class, the class curve will be quite generous. If you do your homework and demonstrate understanding on the exams, you should expect to be rewarded with an A or a B. $\leq$C's are for those who \qu{dropped out} somewhere mid-semester or who cannot demonstrate basic understanding.

\subsection*{Checking your grade and class standing}

You can always check your grades in real-time using the \href{http://gradesly.com}{grading site}. You will enter in your QC ID number (or email) and the password I will provide to you after HW \#0.

\section*{Auditing}

Auditors are welcome in both sections. They are encouraged to do all homework assignments. I will even grade them. Note that the university does not allow auditors to take examinations.

\end{document}