\DocumentMetadata{
  lang = en-US,
  pdfstandard = ua-2,
  pdfversion = 2.0,
  testphase = {latest}
}

\documentclass[12pt]{article}

\tagpdfsetup{math/alt/use=true}

% -------------------------
% Course / assignment metadata
% Edit these once per assignment
% -------------------------
\newcommand{\coursecode}{EE 520}
\newcommand{\coursetitle}{Random Processes}
\newcommand{\quartername}{Fall 2026}
\newcommand{\assignmenttype}{Homework}
\newcommand{\assignmentnumber}{2}
\newcommand{\assignmenttitle}{How long until we find it?}
\newcommand{\duedate}{Session 6}
\newcommand{\studentname}{}
\newcommand{\instructorname}{John Lipor}

% Derived metadata strings
\newcommand{\fullcoursename}{\coursecode: \coursetitle}
\newcommand{\assignmentname}{\assignmenttype\ \assignmentnumber}
\newcommand{\fullassignmentname}{\assignmentname\ifx\assignmenttitle\empty\else: \assignmenttitle\fi}

% -------------------------
% Packages
% -------------------------
\usepackage[english]{babel}
\usepackage[margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{xparse}
\usepackage{etoolbox}
\usepackage{amsmath,amssymb,amsthm,amsfonts}
\usepackage{bbm}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{algorithmic}
% \usepackage{enumitem}
\usepackage{titlesec}

% Links and PDF metadata
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue]{hyperref}
\usepackage{bookmark}
\urlstyle{same}
\hypersetup{
  pdftitle={\coursecode\ \fullassignmentname},
  pdfauthor={\instructorname},
  pdfsubject={\fullcoursename\ assignment},
  pdfcreator={LaTeX},
  pdfproducer={LaTeX with hyperref},
  pdfdisplaydoctitle=true
}

% Improve math environment tagging
\usepackage{tagpdf}
\tagpdfsetup{activate-all,uncompress}

% Header command
\newcommand{\makehomeworkheader}{%
  \thispagestyle{plain}
  \begingroup
  \setlength{\fboxsep}{8pt}
  \noindent\fbox{%
    \begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}

      \noindent\textbf{\fullcoursename}\hfill \quartername\par

      \begin{center}
        {\LARGE \assignmentname\par}
        \ifx\assignmenttitle\empty\else
          {\large \assignmenttitle\par}
        \fi
        {\large Due: \duedate, 11:59 PM PT\par}
      \end{center}

      \noindent\textit{Student Name: \studentname}\hfill \textit{Instructor: \instructorname}\par
    \end{minipage}%
  }
  \endgroup
  \vspace{4mm}
}

% Section heading format used by \problem
\titleformat{\section}
  {\normalfont\normalsize\bfseries}
  {}
  {0pt}
  {}

% Problem headings
\newcounter{problem}
\NewDocumentCommand{\problem}{O{} O{}}{%
  \refstepcounter{problem}%
  \par\medskip
  \section*{\normalfont\normalsize\bfseries
    Problem \theproblem%
    \ifstrempty{#1}{}{\,: #1}%
    \ifstrempty{#2}{}{\normalfont\; [#2]}%
  }%
  \addcontentsline{toc}{section}{Problem \theproblem}%
}

% Use alpha labels for enumerate subproblems
\renewcommand{\labelenumi}{(\alph{enumi})}
\renewcommand{\theenumi}{\alph{enumi}}

% Solution command
\newcommand{\solution}{%
  \par\smallskip
  \noindent\textbf{Solution.}\enspace
}

% My math macros
% theorem type environments
\newtheorem{thm}{Theorem}
\newtheorem{prop}{Proposition}
\newtheorem{lemma}{Lemma}
\newtheorem{cor}{Corollary}
\newtheorem{defn}{Definition}
\newtheorem{assump}{Assumption}
\newtheorem{example}{Example}
\newtheorem{conjecture}{Conjecture}

% frequently used symbols
\newcommand{\bE}{\mathbb{E}}
\newcommand{\bP}{\mathbb{P}}
\newcommand{\bQ}{\mathbb{Q}}
\newcommand{\bR}{\mathbb{R}}
\newcommand{\bS}{\mathbb{S}}
\newcommand{\bN}{\mathbb{N}}
\newcommand{\bZ}{\mathbb{Z}}
\newcommand{\sC}{{\mathcal C}}
\newcommand{\sD}{{\mathcal D}}
\newcommand{\sE}{{\mathcal E}}
\newcommand{\sF}{{\mathcal F}}
\newcommand{\sL}{{\mathcal L}}
\newcommand{\sH}{{\mathcal H}}
\newcommand{\sN}{{\mathcal N}}
\newcommand{\sO}{{\mathcal O}}
\newcommand{\sP}{{\mathcal P}}
\newcommand{\sR}{{\mathcal R}}
\newcommand{\sS}{{\mathcal S}}
\newcommand{\sU}{{\mathcal U}}
\newcommand{\sX}{{\mathcal X}}
\newcommand{\sY}{{\mathcal Y}}
\newcommand{\sZ}{{\mathcal Z}}

% operators
\newcommand{\sign}{\mathop{\mathrm{sign}}}
\newcommand{\supp}{\mathop{\mathrm{supp}}}
\newcommand{\argmin}{\operatornamewithlimits{arg\,min}}
\newcommand{\argmax}{\operatornamewithlimits{arg\,max}}
\newcommand{\dist}{\operatorname{dist}}
\newcommand{\tr}{\operatorname{tr}}
\newcommand{\vecop}{\operatorname{vec}}
\newcommand{\st}{\operatorname{s.t.}}
\newcommand{\cut}{\setminus}
\newcommand{\ind}[1]{\mathbbm{1}\left\{#1\right\}}
\newcommand{\given}{\,|\,}

% grouping operators
\newcommand{\brac}[1]{\left[#1\right]}
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}
\newcommand{\paren}[1]{\left(#1\right)}
\newcommand{\norm}[1]{\left\|#1\right\|}
\newcommand{\ip}[2]{\left\langle #1,#2 \right\rangle}

% code commands
\newcommand{\matlab}{\textsc{Matlab}}
\newcommand{\python}{\textsc{Python}}


\begin{document}

\makehomeworkheader

\section*{Instructions}
Submit your work as a PDF through the course submission system. If you need an accommodation or an alternate format, contact the instructor.

\noindent \textbf{Note:} For all questions asked in this course, unless the question is simply asking about definitions, please justify all answers. Stating the correct answer without justification will earn no credit. For example, if you write down a string of equations, each successive equation should be accompanied by some justification such as ``by the additivity axiom'' or ``because the outcomes are equally likely'' or ``by the distributive property of set operations.'' You do not need to justify algebra.

\problem[Time to detection][5 pts each]

A target sits in a known cell; each sonar pass independently detects it with probability $q = 1 - \alpha$, where $\alpha$ is the overlook probability. Let $X$ be the number of passes until (and including) the first detection.

\begin{enumerate}
  \item Identify the distribution of $X$; compute $\bE[X]$ and $\bP(X > k)$.
  \item Prove the tail-sum formula
  \[
    \bE[X] = \sum_{k \geq 1} \bP(X \geq k)
  \]
  for any nonnegative integer-valued random variable $X$, and use it to re-derive $\bE[X]$ for the distribution of part~(a). 
  \item Two autonomous vehicles search the same cell independently: on each pass, each vehicle independently detects the target with probability $q$. Let $T$ be the time of first detection (by either vehicle). Find the distribution of $T$ and $\bE[T]$. Then generalize to $m$ vehicles.
\end{enumerate}

\problem[The sweep][5 pts each]

A sweep covers $n = 40$ cells; each cell independently contains a mine with probability $0.1$, and the sensor overlooks a present mine with probability $0.25$. Let $X$ be the number of mines detected in one sweep.

\begin{enumerate}
  \item Using indicator variables, find $\bE[X]$ and $\operatorname{Var}(X)$.
  \item A second, independent sweep is performed over the same field. Let $Y$ be the number of mines detected \emph{for the first time} in sweep~2. Find $\bE[Y]$.
\end{enumerate}

\problem[The lying oracle][5 pts each]

A number $\theta$ is equally likely to be any element of $\set{1, \dots, 16}$. You ask ``is $\theta > 8$?'' and the answer is correct with probability $0.8$ and wrong with probability $0.2$. The answer comes back ``yes.''

\begin{enumerate}
  \item Compute the posterior PMF of $\theta$ (it takes two values; find both and check normalization).
  \item You ask a second question and may pick any threshold. Show that the threshold splitting the \emph{posterior mass} most evenly is \emph{not} the midpoint~$8$, and find it.
  \item Now suppose you keep asking threshold questions ``is $\theta > \tau$?'', choosing each threshold however you like, and that given $\theta$, each answer is correct with probability $0.8$ independently of all earlier answers. Show that after $k$ answers,
  \[
    \bP(\theta = j \given \text{answers}) \propto 4^{c_j},
  \]
  where $c_j$ is the number of the $k$ answers that are consistent with $\theta = j$. Then suppose your second question, ``is $\theta > 11$?'', comes back ``no.'' Write down the posterior PMF and find the threshold that splits the posterior mass most evenly for a third question.
\end{enumerate}

\problem[Every cell at least once][5 pts each]

A search region has $10$ cells. A prior map says that, if a target is present, it lies in each of five \emph{likely} cells with probability $0.16$ and in each of five \emph{unlikely} cells with probability $0.04$. Drones are dispatched one at a time; each inspects a single cell, chosen at random according to a fixed probability vector $p = (p_1, \dots, p_{10})$, independently of all other drones. Two dispatch policies are proposed: (i)~\emph{follow the map}, where $p_j$ is the prior probability of cell~$j$, and (ii)~\emph{uniform}, where $p_j = 1/10$ for every cell.

The region may be declared clear only after every cell has been inspected at least once. Suppose the region is in fact empty, so drones keep coming until that happens. Let $U_k$ be the number of cells not yet inspected after $k$ drones, and let $T$ be the number of drones needed until every cell has been inspected.

\begin{enumerate}
  \item Using indicator variables, find $\bE[U_k]$ for a general $p$. Write it out for both policies and evaluate both at $k = 30$.
  \item Show that $\ind{U_k \geq 1} \leq U_k$ for every outcome, and conclude that $\bP(T > k) \leq \bE[U_k]$. Use this bound to find, for each policy, the smallest number of drones $k$ for which it guarantees $\bP(T \leq k) \geq 0.99$. Which cells control the answer for the follow-the-map policy, and why?
  \item For the uniform policy, write $T = G_1 + G_2 + \dots + G_{10}$, where $G_i$ counts the drones dispatched while exactly $i - 1$ distinct cells have been inspected (so $G_1 = 1$). Identify the distribution of each $G_i$ and compute $\bE[T]$. \emph{Hint:} condition on everything that happened up to the moment the $(i-1)$st distinct cell is inspected. Explain why, for every $m \geq 0$,
  \[
    \bP(G_i > m \given \text{that history}) = \left(\frac{i-1}{10}\right)^{m},
  \]
  and what it tells you that the right side does not depend on the history. Then explain in one or two sentences why the same decomposition does not give $\bE[T]$ directly for the follow-the-map policy, even though the indicator argument of part~(a) worked for both policies.
\end{enumerate}

\problem[Race of the strategies][10 pts]

On the $10 \times 10$ grid from Homework~1 Problem~5, compare two search strategies over $500$ random trials: (i)~a fixed grid sweep, and (ii)~greedy posterior maximization. Report the mean and median number of looks to detection.

\noindent\textbf{Before running:} predict which strategy wins and whether the gap grows or shrinks as $\alpha$ increases from $0.1$ to $0.5$.

\noindent\textbf{Turn in:} a plot of mean detection time versus $\alpha$ for both strategies, your prediction versus the outcome, and your code.

\clearpage
\problem[Audit the TA-bot][5 pts]

The assistant was asked: \emph{``A cell either contains a target (probability $0.5$) or is empty. Each pass over the cell detects a present target with probability $q = 0.35$, independently across passes. After $6$ failed passes: what should we believe, and how many more passes should we expect to need if we keep searching?''} It answered:

\begingroup
\setlength{\fboxsep}{8pt}
\noindent\fbox{%
  \begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
    \noindent\textbf{TA-bot writes:} Let $X$ be the number of passes to detection when the target is present; $X$ is geometric with success probability $0.35$, so $\bP(X > m + k \given X > m) = \bP(X > k)$: the geometric distribution is memoryless. Because the search process is memoryless, the six failures tell us nothing. Our belief that the target is in the cell is therefore still $0.5$, and the expected number of additional passes needed is unchanged at $1/0.35 \approx 2.86$.
  \end{minipage}%
}
\endgroup

\medskip
\noindent This solution contains \textbf{exactly one error}, and note that not every clause is wrong.
\begin{enumerate}
  \item Identify the first line that goes wrong.
  \item Name the violated principle.
  \item Give the corrected belief.
  \item One sentence: why is this a mistake a language model plausibly makes?
\end{enumerate}

\end{document}
