\documentclass[10pt,twoside]{article}\usepackage[]{graphicx}\usepackage[dvipsnames,svgnames,table]{xcolor}
% maxwidth is the original width if it is less than linewidth
% otherwise use linewidth (to make sure the graphics do not exceed the margin)
\makeatletter
\def\maxwidth{ %
  \ifdim\Gin@nat@width>\linewidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}
\makeatother

\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}
\newcommand{\hlnum}[1]{\textcolor[rgb]{0.686,0.059,0.569}{#1}}%
\newcommand{\hlsng}[1]{\textcolor[rgb]{0.192,0.494,0.8}{#1}}%
\newcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textit{#1}}}%
\newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}%
\newcommand{\hldef}[1]{\textcolor[rgb]{0.345,0.345,0.345}{#1}}%
\newcommand{\hlkwa}[1]{\textcolor[rgb]{0.161,0.373,0.58}{\textbf{#1}}}%
\newcommand{\hlkwb}[1]{\textcolor[rgb]{0.69,0.353,0.396}{#1}}%
\newcommand{\hlkwc}[1]{\textcolor[rgb]{0.333,0.667,0.333}{#1}}%
\newcommand{\hlkwd}[1]{\textcolor[rgb]{0.737,0.353,0.396}{\textbf{#1}}}%
\let\hlipl\hlkwb

\usepackage{framed}
\makeatletter
\newenvironment{kframe}{%
 \def\at@end@of@kframe{}%
 \ifinner\ifhmode%
  \def\at@end@of@kframe{\end{minipage}}%
  \begin{minipage}{\columnwidth}%
 \fi\fi%
 \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
 \colorbox{shadecolor}{##1}\hskip-\fboxsep
     % There is no \\@totalrightmargin, so:
     \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
 \MakeFramed {\advance\hsize-\width
   \@totalleftmargin\z@ \linewidth\hsize
   \@setminipage}}%
 {\par\unskip\endMakeFramed%
 \at@end@of@kframe}
\makeatother

\definecolor{shadecolor}{rgb}{.97, .97, .97}
\definecolor{messagecolor}{rgb}{0, 0, 0}
\definecolor{warningcolor}{rgb}{1, 0, 1}
\definecolor{errorcolor}{rgb}{1, 0, 0}
\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX

\usepackage{alltt}
\usepackage[marginparsep=1em]{geometry}
\geometry{lmargin=1.0in,rmargin=1.0in, bmargin=1.2in,  tmargin=1.2in}
\usepackage[dvipsnames,svgnames,table]{xcolor}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{epstopdf}
\usepackage{verbatim}
\usepackage{enumerate}
\usepackage{bm}
\usepackage{amsthm}
\usepackage{float}
\usepackage{amsmath}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{mathtools}

%%%%  SHORTCUT COMMANDS  %%%%
\newcommand{\ds}{\displaystyle}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\T}{\mathcal{T}}
\newcommand{\arc}{\rightarrow}
\newcommand{\R}{\mathbb{R}}
\newcommand{\RP}{\mathbb{R}(+)}
\newcommand{\Rs}{\mathbb{R}^{**}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\E}{\mathbb{E}}
\newcommand{\B}{\mathcal{B}}
\newcommand{\PX}{\mathcal{P}(X)}
\newcommand*\rot{\rotatebox{90}}
\newcommand*\OK{\ding{51}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\Answer}{\vspace{2mm}\textbf{\underline{Answer}}\\}
\newcolumntype{L}{>{$}l<{$}}
\newcolumntype{C}{>{$}c<{$}}
\newcommand{\GL}{\text{GL}}
\newcommand{\SL}{\text{SL}}

\newcommand{\stirling}[2]{\genfrac{\{}{\}}{0pt}{}{#1}{#2}}

\pagestyle{fancy}
\fancyhf{}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\lhead{\fancyplain{}{}}
\fancyhead[RE,RO]{Math 4451, Spring 2026}
\fancyfoot[RE,RO]{\thepage}
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\begin{document}
\begin{flushright}
\begin{minipage}{.33\textwidth}
\rightline{YOUR NAME}
\rightline{\href{mailto:YOUR EMAIL}{YOUR EMAIL}}
\rightline{\today}
\end{minipage}
\end{flushright}

\begin{center}
{\large{\textbf{Homework 3}}}
\end{center}

\noindent\textbf{Note:} The first two problems are distinct from what we have seen so far. Here, the support of $X_i$ depends on $\theta$. Think carefully about the MLE in these situations.

\begin{enumerate}

    \item (3 points) Suppose $X_1, X_2, \ldots, X_n$ are iid from a Uniform$(0, \theta)$ distribution. What is the MLE of $\theta$?

    \item (4 points) Suppose that $X_1, \ldots X_n$ are iid from a distribution with the density function:
    $$
    f(x; \theta) = \begin{cases}e^{-(x-\theta)}, & x \geq \theta \\
    0, & \text{otherwise}\end{cases}
    $$

    \begin{enumerate}
      \item (2 points) Find the method of moments estimate of $\theta$.
      \item (2 points) Find the MLE of $\theta$ (\emph{HINT:} be careful about this one. What values of $\theta$ gives a positive likelihood?)
    \end{enumerate}

  \item (3 points) Suppose we observe a collection of observations, $(X_1, Y_1)$, $(X_2, Y_2), \ldots (X_n, Y_n)$. We're particularly interested in a model for $Y|X$, conditioning on the observed $X$. The model we would like to fit is
  $$
  Y_i = f_\theta(X_i) + \epsilon_i,
  $$
  where $\epsilon_i$ is an error term, and $f_\theta$ is some function of input data $X_i$ and parameters $\theta$.
  In practice, this function is fixed to be within a particular family (i.e., a neural network, linear model, etc.)

  One way to estimate $\theta$ with this model is minimizing the mean-square-error:
  $$
  \hat{\theta} = \text{argmin}_{\theta}\, \frac{1}{n} \sum_{i = 1}^n \big(Y_i - f_{\theta}(X_i)\big)^2.
  $$
  \textbf{Show that this is the same answer that you get by fitting the MLE to a conditional normal distribution:}
  $$
  Y_i | X_{i} \overset{iid}{\sim} N\big(f_\theta(X_i), \sigma^2\big).
  $$
  For convenience, you can assume that $\sigma^2$ is fixed, and we want to estimate $\theta$. (\emph{Note:} This is also the same as assuming that the $\epsilon_i$ are iid normal)

  \item (4 points) For this problem, you will implement logistic regression from scratch. The math was worked out in class in the Maximum Likelihood slides and notes; the intent is to build this from scratch rather than using pre-built logistic regression functions, though they will be useful if you want to check your solution.

  The data you should estimate is called \texttt{mtcars}.
  It is pre-built in R and can be access simply by typing \texttt{mtcars}.
  A \texttt{.csv} will also be uploaded to Canvas.
  Your task is to predict $Y_i = \texttt{am}$, a binary variable in the data indicating whether or not the car is an automatic (0) or manual (1) based on other car features, $X_i$: \texttt{mpg, wt, disp, cyl}.


  More information about the data can be found in R by running the command \texttt{?mtcars}.

  To show your work, upload your code and provide some details such as parameter estimates or predictive accuracy.

\end{enumerate}


\end{document}
