% LaTeX handouts by Will Monroe
% Based on B. E. Burr's CS 109 problem set template

\documentclass[12pt]{article}
\usepackage{caption}
\captionsetup[figure]{labelformat=empty}% redefines the caption setup of the figures environment in the beamer class.

\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem*{answer}{Answer}
\usepackage{xcolor}
\definecolor{shadecolor}{gray}{0.95}
\usepackage{newtxtext,newtxmath}

\usepackage{amsmath}
\usepackage{amssymb}
	% packages that allow mathematical formatting
\usepackage{comment}
  % comment out sections

\usepackage{graphicx}
\usepackage{float}
%\usepackage{subfigure} % lisa commented out

\usepackage{tikz}
	% package that allows you to include graphics

\usepackage[hidelinks]{hyperref}
	% and links
\usepackage{algpseudocode}
  % and algorithms
\usepackage{minted}
	% and code

\usepackage[tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in]{geometry}
\frenchspacing
	% one space after periods
\raggedbottom
	% don't put extra space between sections

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt} 
\setlength{\headheight}{14.5pt} 
	% allows custom headers

\lhead{}
\rhead{-- \thepage{} --}
\cfoot{}
	% page numbering

\usepackage{titlesec}
\titleformat*{\section}{\large\bfseries}
\titleformat*{\subsection}{\large\itshape\bfseries}
\titleformat*{\subsubsection}{\normalsize\bfseries}
\titleformat*{\paragraph}{\normalsize\bfseries}
\titleformat*{\subparagraph}{\normalsize\bfseries}
\setlength{\parindent}{0cm}
\setlength{\parskip}{3mm plus 3mm minus 1mm}
\titlespacing*{\section}{0pt}{2mm plus 4mm minus 1mm}{-2mm plus 1mm minus 0mm}
\titlespacing*{\subsection}{0pt}{0mm plus 4mm minus 1mm}{-2mm plus 1mm minus 0mm}
\titlespacing*{\subsubsection}{0pt}{0mm plus 4mm minus 1mm}{-2mm plus 1mm minus 0mm}
\titlespacing*{\paragraph}{0pt}{0mm plus 3mm minus 1mm}{1mm plus 1mm minus 0mm}
  % adjust fonts and spacing

\usepackage{framed}
\begin{comment}
\newenvironment{framed}
    {
    \hspace*{-3mm}
    \begin{tabular}{|p{\textwidth}|}
    \hline
    }
    { 
    \\[2mm]\hline
    \end{tabular} 
    \vspace*{-2mm}
    }
  % boxes around paragraphs with titles
\end{comment}

\usepackage{textpos}
\usepackage[super]{nth}
\usepackage{mathtools}
\usepackage{mathdots}

\usepackage{textcomp}
  % \textonehalf for '8 1/2" x 11"'

\usepackage{enumitem}
% \setlist{nolistsep}
  % configure display of enumerations [a), b), c)...]
\usepackage[normalem]{ulem}
  % \sout{} for strikethrough
\usepackage{booktabs}
\usepackage{diagbox}
  % configure display of tables

\newcommand{\vocab}[1]{\textbf{#1}}
\renewcommand{\|}{\mid}

\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\newcommand\tab[1][1cm]{\hspace*{#1}}
\newcommand\tabhead[1]{\small\textbf{#1}}

\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\E}{E}
\newcommand{\Var}{\operatorname{Var}}
\newcommand{\SD}{\operatorname{SD}}
\newcommand{\Cov}{\operatorname{Cov}}
\newcommand{\bigO}{O}

\newcommand{\Uni}{\operatorname{Uni}}
\newcommand{\Ber}{\operatorname{Ber}}
\newcommand{\Bin}{\operatorname{Bin}}
\newcommand{\Geo}{\operatorname{Geo}}
\newcommand{\NegBin}{\operatorname{NegBin}}
\newcommand{\Zipf}{\operatorname{Zipf}}
\newcommand{\HypG}{\operatorname{HypG}}
\newcommand{\Poi}{\operatorname{Poi}}
\newcommand{\Beta}{\operatorname{Beta}}
\newcommand{\N}{\mathcal{N}}
\newcommand{\Gaussian}{\mathcal{N}}
\newcommand{\Exp}{\operatorname{Exp}}

\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}

\makeatletter
\newcommand{\ack}[1]{\def \@ack {#1}}
\newcommand{\handoutid}[1]{\def \@handoutid {#1}}
\newcommand{\spaceadjust}[1]{\def \@spaceadjust {#1}}
\makeatother

\ack{}
\handoutid{}
\spaceadjust{0mm}

\usepackage{multirow}
\usepackage{bm}

\newenvironment{boxpar}
    {
    \hspace*{0mm}
    \begin{tabular}{|p{0.95\textwidth}|}
    \hline
    }
    {
    \\[2mm]\hline
    \end{tabular}
    \vspace*{0mm}
    }
  % boxes around paragraphs with titles
  
\usepackage{soul} % for line-break underline



% reset section spacing
\titlespacing*{\section}{0pt}{12pt plus 4pt minus 2pt}{8pt plus 2pt minus 2pt}
% -----------------------------------
% -----------------------------------
% -----------------------------------
% USE FOR SETTING FLAG
\usepackage{etoolbox}

\providetoggle{soln}
\settoggle{soln}{true}

\newcounter{enumcurr}
% -----------------------------------
% -----------------------------------
% -----------------------------------

\title{CS109 Midterm Quiz}
\handoutid{Quiz}
\author{Oishi Banerjee and Cooper Raterink}
\date{Summer 2020}


\begin{document}

\makeatletter
% the handout title goes here
\begin{textblock*}{0.5\textwidth}(0\textwidth,0mm)
\@author
\end{textblock*}

\begin{textblock*}{0.5\textwidth}(.5\textwidth,0mm)
\hfill
\@date
\end{textblock*}

\begin{center}
\vspace*{2mm}
{\Large \@title} \\
\end{center}
\vskip -7mm
\vskip \@spaceadjust

\rule{\textwidth}{0.5pt}

\vspace*{-4mm}
\hfill {\footnotesize \@ack}
\makeatother

%%%

\vspace*{-1em}
\section*{Take-Home Quiz information}
\vspace*{-1em}
Each quiz will be a 24-hour open-book, open-note, open-calculator exam. Quiz material will approximate about 2-3 hours of active work (\textit{before} typesetting), though it may be more depending on how you prepare your submission. Unlike the problem sets, the take-home quizzes are \textbf{\textit{strictly individual work}}. Even course staff assistance will be limited to clarifying questions of the kind that might be allowed on a traditional, in-person exam. If you have questions during the exam, please ask them via our discussion forum. We will not have any office hours for answering quiz questions during the quiz.


\textbf{For each problem, briefly explain/justify how you obtained your answer} at a level such that a future CS109 student would be able to understand how to solve the problem. Please derive your mathematical expressions analytically, not via computerized simulation. For example, please use mathematical principles to solve counting problems, rather than writing a brute-force program to generate all possible outcomes. (That said, you may use code to \emph{check} your analytically-derived answers.)

It is fine for your answers to be well-defined mathematical expressions including finite summations (but not integrals), products, factorials, exponentials, and combinations, unless the question \textit{specifically} asks for a numeric quantity or for closed form. Where numeric answers are required, the use of fractions is fine. You may use a calculator (e.g. WolframAlpha) to evaluate your mathematical expressions.


\section*{Honor Code Guidelines for Take-Home Quizzes}
\vspace*{-1em}
The take-home exams are open-book (open lecture notes, handouts, textbooks, course lecture videos, and internet searches for conceptual information, e.g., Wikipedia). Consultation of other humans in any form or medium (e.g., communicating with classmates, asking questions on forum websites such as StackOverflow) is prohibited. All work done with the assistance of any external material in any way (other than provided CS109 course materials) must include citation (e.g., ``Referred to Wikipedia page on DeMorgan's Law for Question 2.''). Copying solutions is unacceptable, even with citation. If by chance you encounter solutions to the problem, navigate away from that page before you feel tempted to copy. If you become aware of any honor code violations by any student in the class, your commitments under the Stanford Honor Code obligate you to inform course staff. \textit{Please remember that there is no reason to violate your conscience to complete a take-home exam.}


\section*{Submission}
\vspace*{-1em}
You should upload your submission as a PDF to Gradescope. We provide a LaTeX template if you find it useful, but we will accept any legible submission. You can submit multiple times; we will only grade the last submission you submit before the deadline$^\text{th}$. Late submissions will not be accepted. \textit{\textbf{Please double-check that you submit the right file.}} When uploading, PLEASE assign pages to each question. 

\vspace*{1em}

I acknowledge and accept the letter and spirit of the Honor Code:

\newcommand{\blank}{\hrulefill{}}
\newcommand{\ulfrule}{\xleaders\hbox{\underline{ }}\hfill\kern0pt}

\vspace*{1.5em}
Name (typed or written): \blank{} % if in LaTeX, write your name here

\setlist{nolistsep}

%%%%%%%%%%%%%%%%%%%%%% 1 %%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{Potpourri}

\begin{itemize}
\item[a.] 
\begin{itemize}
    \item[i.] Solution goes below:
    \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}
    \item[ii.] Solution goes below:
    \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}
    \item[iii.] Solution goes below:
    \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}
\end{itemize}
\item[b.] 
\begin{itemize}
    \item[i.] Solution goes below:
    \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}
    \item[ii.] Solution goes below:
    \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}
    \item[iii.] Solution goes below:
    \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}
\end{itemize}

  
\item[c.] Solution goes below:
   \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}
	
	
\item[d.] Solution goes below:
 \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.25\paperheight}}
	
\item[e.] Solution goes below:

 \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}	

\end{itemize}


%%%%%%%%%%%%%%%%%%%%%% 2 %%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{Admissions}

\begin{itemize}
\item[a.] Solution goes below:
 \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}

\item[b.] Solution goes below:

 \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}

\item[c.] Solution goes below:
 \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.3\paperheight}}
	
\item[d.] Solution goes below:
 \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}

\item[e.] Solution goes below:
 \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{\vspace{.15\paperheight}}
\end{itemize}


%%%%%%%%%%%%%%%%%%%%%% 3 %%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{Psuspicious Pseudocode}
\vspace*{0em}
Solution goes below:

    \iftoggle{soln}{
    	\begin{shaded}
    \begin{answer}
    
    % ANSWER HERE
    \end{answer}
    \end{shaded}
	}
	{
	\vspace{.1\paperheight}
	}

%%%%%%%%%%%%%%%%%%%%%% 4 %%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{A Natural Progression of Regression}

\begin{itemize}

\item[a.] Solution goes below:
    \iftoggle{soln}{
    \begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{
	\vspace{.1\paperheight}
	}

\end{itemize} 

\begin{itemize}
\item[b.] Solution goes below:
    \iftoggle{soln}{
    \begin{shaded}
    \begin{answer}
    
    
    \end{answer}
    \end{shaded}
	}
	{
	\vspace{.15\paperheight}
	}
 
 \item[c.] Solution goes below:
    \iftoggle{soln}{
    \begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{
	\vspace{.25\paperheight}
	}

\end{itemize} 

%%%%%%%%%%%%%%%%%%%%%% 5 %%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{Naive Bayes...Nets?}

\begin{itemize}

\item[a.] Solution goes below:
    \iftoggle{soln}{
    \begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{
	\vspace{.1\paperheight}
	}

\end{itemize} 

\begin{itemize}
\item[b.] Solution goes below:
    \iftoggle{soln}{
    \begin{shaded}
    \begin{answer}
    
    
    \end{answer}
    \end{shaded}
	}
	{
	\vspace{.15\paperheight}
	}
 
 \item[c.] Solution goes below:
    \iftoggle{soln}{
    \begin{shaded}
    \begin{answer}
    
    \end{answer}
    \end{shaded}
	}
	{
	\vspace{.25\paperheight}
	}

\end{itemize} 

\end{document}