\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}{3}
\newcommand{\assignmenttitle}{Measurements as random variables}
\newcommand{\duedate}{October 30, 2026}
\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[Shadowing][5 pts each]

In wireless propagation, the received power in decibels is well modeled as Gaussian, $P_{\mathrm{dB}} \sim \sN(\mu, \sigma^2)$ (this is \emph{log-normal shadowing}). The linear-scale power is $P = 10^{P_{\mathrm{dB}}/10}$.

\begin{enumerate}
  \item Derive the PDF of $P$ using the monotone change-of-variables formula. This distribution has a name: identify it. \emph{(Session~7 introduces this transform and leaves the derivation to you.)}
  \item A receiver loses lock when the linear power drops below a threshold $t$. Compute the outage probability $\bP(P < t)$ two ways: directly from the PDF of $P$, and by transforming the event into decibels and using $\Phi$. Confirm that the two agree, and state which you would actually use.
  \item One sentence: why is there a derivative in the change-of-variables formula? \emph{(Hint: densities are not probabilities.)}
\end{enumerate}

\problem[Build your own sampler][5 pts each]

\noindent The envelope of a complex Gaussian channel gain is Rayleigh, with CDF
\[
  F(r) = 1 - \exp\!\left( -\frac{r^2}{2\sigma^2} \right), \qquad r \geq 0 .
\]
\begin{enumerate}
  \item Derive the inverse-CDF sampler: given $U \sim \text{Unif}[0,1]$, give the explicit formula $g(U)$ that produces a Rayleigh draw, and justify why $F^{-1}(U)$ has CDF $F$. \emph{(Session~7 derives the exponential sampler in class and leaves the Rayleigh case to you.)}
  \item Implement it using uniform draws only (no \texttt{np.random.rayleigh}), and histogram $10^5$ samples against the PDF. \textbf{Turn in} your plot and your code. From now on you know what the library samplers are doing.
\end{enumerate}

\problem[Heavy tails][5 pts each]

Two candidate noise models for a range sensor have the \emph{same variance}: $\sN(0, 1)$ and a Laplace distribution with matching variance.

\begin{enumerate}
  \item Compute $\bP(\abs{Z} > 3)$ under each model. By what factor do they differ?
  \item You observe one reading $4$ standard deviations away from the predicted range. Under which noise model is this reading more plausibly ``just noise'' rather than a faulty sensor? Answer with a computed ratio, then give one sentence on why tail behavior, not variance, is the modeling decision that matters here.
  \item Parts~(a) and~(b) suggest that the ratio of the two tail probabilities keeps growing. Prove it. First show that for every $t > 0$,
  \[
    Q(t) \leq \frac{\varphi(t)}{t},
  \]
  where $Q(t)$ is the upper-tail probability and $\varphi$ is the standard normal density (see Session 6). \emph{Hint:} in $Q(t) = \int_t^\infty \varphi(x)\,dx$, every $x$ in the range of integration satisfies $x/t \geq 1$. Then use this bound to show that $\bP_{\text{Laplace}}(\abs{Z} > t) \,/\, \bP_{\text{Gauss}}(\abs{Z} > t) \to \infty$ as $t \to \infty$.
\end{enumerate}

\problem[Nearest return][5 pts]

\noindent An acoustic source at the origin insonifies $K = 5$ scatterers whose ranges are iid $\text{Unif}[0, R_{\max}]$. The first echo to arrive comes from the nearest scatterer. Find the PDF of the first-echo range using the CDF method, and compute its mean.

\problem[Is the measurement worth it?][5 pts each]

A target is present ($\theta = 1$) with prior $0.3$. You must decide ``present'' or ``absent.'' A correct call is worth $+10$, a false alarm costs $-20$, a miss costs $-50$, and a correct rejection is worth $0$.

\begin{enumerate}
  \item Compute the expected utility of each immediate action and the optimal act-now decision.
  \item Before deciding, you may buy (for $3$ units) one sensor reading $Y$ with $\bP(Y=1 \given \theta=1) = 0.8$ and $\bP(Y=1 \given \theta=0) = 0.1$. Compute the value of the measurement: the expected utility of acting optimally \emph{after} $Y$, averaged over $Y$, minus the act-now value. Should you buy?
  \item Session~7 left a question open: how does the value of a measurement depend on the prior? Keep the utilities and the sensor of part~(b), let $p = \bP(\theta = 1)$ be a general prior, and let $\mathrm{VoM}(p)$ be the value of the measurement before its price is paid. Show that $\mathrm{VoM}(p)$ is piecewise linear in $p$ and write it out explicitly. \emph{Hint:} for each reading $Y = y$, find the priors $p$ for which the best action after seeing $y$ is ``present.'' Then answer the following.
  \begin{itemize}
    \item $\mathrm{VoM}(p) = 0$ on two whole intervals of priors, not just at $p = 0$ and $p = 1$. Find them, and explain in one sentence why the reading is worthless there.
    \item Find where $\mathrm{VoM}(p)$ peaks and its peak value. Explain why the peak sits at that prior and not at $p = 0.5$.
    \item For which priors is the reading worth its price of $3$?
  \end{itemize}
\end{enumerate}

\problem[The relaxed switch][5 pts each]

Neural networks sometimes need a learnable on/off switch: whether to keep a unit when pruning a network, or a binary hidden variable in a generative model. The switch should be on with a probability set by a real parameter $\mu$, which training adjusts by following derivatives. The trouble is that a $0/1$ switch is a step function of $\mu$: its derivative is zero everywhere except at a single jump, so derivatives carry no information about which way to move $\mu$. A fix used in practice, the \emph{binary Concrete} (or \emph{Gumbel-sigmoid}) relaxation, builds the switch from Gumbel noise.

\noindent Let $G_1$ and $G_2$ be independent standard Gumbel random variables (Session~6), and let $L = G_1 - G_2$. Define the \emph{hard switch} $B = \ind{\mu + L > 0}$ and, for a temperature $\tau > 0$, the \emph{relaxed switch}
\[
  Y_\tau = \frac{1}{1 + e^{-(\mu + L)/\tau}} .
\]

\begin{enumerate}
  \item Using Session~7's representation $G = -\ln E$ with $E \sim \text{Exp}(1)$, write $L$ in terms of two independent $\text{Exp}(1)$ random variables $E_1$ and $E_2$. Find $\bP(L \leq z)$ by integrating the joint density of $(E_1, E_2)$ over the appropriate region of the plane (sketch the region). You should obtain
  \[
    F_L(z) = \frac{1}{1 + e^{-z}},
  \]
  the \emph{standard logistic} CDF. Find the density of $L$, show that it is symmetric about $0$, and conclude that $\bP(B = 1) = e^{\mu}/(1 + e^{\mu})$.
  \item Derive the density of $Y_\tau$ on $(0, 1)$ using the monotone change-of-variables formula. Show that $\bP(Y_\tau > 1/2) = \bP(B = 1)$ for every $\tau > 0$, so rounding the relaxed switch recovers the hard switch exactly. Then show that when $\tau = 1$ and $\mu = 0$, $Y_\tau$ is $\text{Unif}(0, 1)$, and explain in one sentence why this had to happen, using an idea from Session~7.
  \item \textbf{Before running:} with $\mu = 1$, predict the shape of the histogram of $Y_\tau$ for a small temperature, $\tau = 0.2$, and for a large one, $\tau = 3$. Where does the probability pile up, and does the fraction of samples above $1/2$ change with $\tau$?

  Implement the relaxed switch using uniform draws only, and draw $10^5$ samples of $Y_\tau$ for each of $\tau = 0.2, 1, 3$ with $\mu = 1$. Histogram each against your density from part~(b). Finally, hold the noise $L$ fixed and show that
  \[
    \frac{\partial Y_\tau}{\partial \mu} = \frac{Y_\tau (1 - Y_\tau)}{\tau} .
  \]
  In one or two sentences, explain the trade-off training faces when choosing $\tau$.

  \textbf{Turn in:} your prediction versus the outcome, the three plots, the fraction of samples above $1/2$ for each $\tau$, and your code.
\end{enumerate}

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

The assistant was asked: \emph{``$X \sim \text{Exp}(1)$ models a normalized interference power; a nonlinear stage outputs $Y = X^3$. Find the PDF of $Y$.''} It answered:

\begingroup
\setlength{\fboxsep}{8pt}
\noindent\fbox{%
  \begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
    \noindent\textbf{TA-bot writes:} Since $Y = X^3$ and $X \geq 0$, the map is monotone with inverse $x = y^{1/3}$. Substituting into $f_X(x) = e^{-x}$ gives $f_Y(y) = e^{-y^{1/3}}$ for $y \geq 0$. Check: this is positive and decreasing in $y$, exactly as the density of a positive quantity should be.
  \end{minipage}%
}
\endgroup

\medskip
\noindent This solution contains \textbf{exactly one error}.
\begin{enumerate}
  \item Identify the first line that goes wrong.
  \item Name the violated principle in one sentence, citing the session.
  \item Fix the density, \textbf{and} give a one-line diagnostic (dimensional or normalization) that would have exposed the error without redoing the derivation.
  \item One sentence: why is this a mistake a language model plausibly makes?
\end{enumerate}
\noindent\emph{Flagging a correct step as an error costs credit; certifying correctness is part of the skill.}

\end{document}
