\documentclass[twocolumn]{article}
% \documentclass{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}
\usepackage{amsmath}

\begin{document}

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

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

Directions: Frequently save your work to {\bf handin} and your USB key!
No quizzes accepted with timestamp past 5:05 p.m.  Submit a {\bf .tar}
file (even though just one file will be in it) with naming convention as
in the homework (but with only names of those present).

{\bf Assumptions:}  In all problems, we are working with electronic
components with lifetime $L$, whose population distribution is assumed
to be exponential with some unknown population value $\lambda$.  We test
a random sample of $n$ components, finding their lifetimes to be
$L_1,...,L_n$.

Place your answer to Problem $i$ in a file {\bf Probi.R}.

{\bf 1.} (35) Write a function with call form

\begin{lstlisting}
lmbdci(lvec)
\end{lstlisting}

where the argument {\bf lvec} is the vector $(L_1,...,L_n)'$, as above,
returning a two-component vector representing the endpoints of an
approximate 95\% confidence interval $E(L)$.  

Feel free to call R's {\bf mean()}, {\bf var()} and/or {\bf sd()} functions.
However, for full credit, do not use the usual $s^2$; instead, use a
quantity that exploits the fact that we are assuming an exponential
distribution.

{\bf 2.} (35) Write a function with call form

\begin{lstlisting}
estcdf(lvec,t)
\end{lstlisting}

which returns the estimated value of $F_L(t)$, where $t$ is a number
between $-\infty$ and $\infty$. 

{\bf 3.} (30) Write a function with call form

\begin{lstlisting}
plotestcdf(lvec,ubound)
\end{lstlisting}

uses {\bf ggplot2} to plot the function in Problem 2, from 0 to {\bf
ubound}.

\onecolumn

\newpage

{\bf Solutions:}

{\bf 1.} From the text, we know that 

\begin{equation} 
Var(L) = 1 / \lambda^2
\end{equation}

So, instead of $s$ use $1 / \widehat{\lambda} = \overline{L}$.  The CI
is then

\begin{equation}
\overline{L} \pm 1.96 \overline{L} / \sqrt{n}
\end{equation}

{\bf 2.}

\begin{lstlisting}
estcdf <- function(lvec,t) {
   if (t < 0) return(0)
   lambdahat <- 1 / mean(lvec)
   1 - exp(-lambdahat * t)
}
\end{lstlisting}

\end{document} 

