\documentclass[twocolumn]{article}

\setlength{\oddsidemargin}{-0.5in}
\setlength{\evensidemargin}{-0.5in}
\setlength{\topmargin}{0.0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\textwidth}{7.0in}
\setlength{\textheight}{9.5in}
\setlength{\parindent}{0in}
\setlength{\parskip}{0.05in}
\setlength{\columnseprule}{0.3pt}

\setlength\columnsep{25pt}

\usepackage{fancyvrb}
\usepackage{relsize}
\usepackage{hyperref}

\usepackage{listings}

\begin{document}

\lstset{xleftmargin=5mm,framexleftmargin=10mm,basicstyle=\footnotesize}

Name: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

Directions: Do NOT turn in this sheet of paper (unless you
lack a laptop or have a laptop failure during the Exam).  You will
submit electronic files to {\bf handin}. 

\bigskip

{\bf \Large INSTRUCTIONS FOR SUBMISSION:}

\begin{itemize}
 
\item Submit to the CSIF {\bf handin}, under my account, using the
alphabetically earliest UCD e-mail address among your group members.

\item Submit ONLY the files {\bf Problem1.tex} and {\bf Problem2.R}. 

\end{itemize}

{\bf 1.} (50) Suppose $f_{X,Y}(s,t) = 2$ on $0 < t < s < 1$, 0 elsewhere.
Find $f_{X+Y}(w)$ for the case $0 < w < 1$.  Tip:  Find $F_{X+Y}$ first.  

Submit your derivation in a LaTeX file {\bf Problem1.tex}.  My grading
script will check it by running

\begin{lstlisting}
% pdflatex Problem1.tex
% xpdf Problem1.pdf  # or other PDF viewer
\end{lstlisting}

{\bf 2.} (50) Lifetimes of some electronic component formerly had an
exponential distribution with mean 100.0.  However, it's claimed that
now the mean has increased.  (Suppose we are somehow sure it has not
decreased.)  Someone has tested 50 of these new components, and has
recorded their lifetimes, $X_1,...,X_{50}$.  Unfortunately, they only
reported to us the range of the data, $R = \max_i X_i - \min_i X_i$.

We will need to do a significance test with this limited data, at the
0.05 level.  Note (p.222) that it will necessarily be a bit different 
from 0.05.  Take the one that is nearest but no larger than 0.05.  
You may wish to use the R {\bf ceiling()} function here.

Use simulation (because the problem is too difficult mathematically) to
find a cutoff value v for our significance test, and state whether we
reject $H_0$ if $R < v$ or $R > v$.

Submit your full code in a file {\bf Problem2.R}.  My grading script
will check it by running

\begin{lstlisting}
> source("Problem2.R")
\end{lstlisting}

and your code will print out something like ``reject if R 202.8.''

{\bf Solutions:}

{\bf 1.}  Since X and Y are not independent, we cannot use convolution.

\begin{eqnarray}
F_{X+Y}(w) &=& P(X+Y) \leq w\\ 
&=& 
\int_{0}^{w/2} 
\int_{t}^{w-t} 2 ~ ds ~ dt \\
&=& w^2 / 2
\end{eqnarray}

So $f_{X+Y}(w) = w$.

{\bf 2.}

\begin{lstlisting}[numbers=left]
# random sample of size 50, test H0: mu = 100.0, 
# against HA: mu > 100.0, exponential distribution; 
# just have range R 

# code to determine the cutoff point for significance 
# at 0.05 level

nreps <- 200000
n <- 50

rvec <- vector(length=nreps)
for (i in 1:nreps) {
   x <- rexp(n,0.01)
   rng <- range(x)
   rvec[i] <- rng[2] - rng[1]
}

rvec <- sort(rvec)
cutoff <- rvec[ceiling(0.95*nreps)]
cat("reject H0 if R >",rvec[cutoff],"\n")

# check (not requested):

tvec <- vector(length=nreps)
for (i in 1:nreps) {
   x <- rexp(n,0.01)
   rng <- range(x)
   rej <- (rng[2] - rng[1]) > cutoff
   tvec[i] <- rej
}

print(mean(tvec))  # should be near 0.05
\end{lstlisting}

\end{document}

